Skip to main content

API / Templates

MethodEndpointDescription
GET/api/templatesGets all templates.
GET/api/templates/:template_idGets a single template.
GET/api/templates/:template_id/previewGets the HTML preview of a template.
POST/api/templates/preview
POST/api/templatesCreates a template.
PUT/api/templates/:template_idModifies a template.
PUT/api/templates/:template_id/defaultSets a template to the default template.
DELETE/api/templates/:template_idDeletes a template.

GET /api/templates

Gets all templates.

Example Request
curl -u "username:username" -X GET 'http://localhost:9000/api/templates'
Example Response
{
"data": [
{
"id": 1,
"created_at": "2020-03-14T17:36:41.288578+01:00",
"updated_at": "2020-03-14T17:36:41.288578+01:00",
"name": "Default template",
"body": "{{ template \"content\" . }}",
"type": "campaign",
"is_default": true
}
]
}

GET /api/templates/:template_id

Gets a single template.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
template_idPath ParameterNumberRequiredThe id value of the template you want to get.
Example Request
curl -u "username:username" -X GET 'http://localhost:9000/api/templates/1'
Example Response
{
"data": {
"id": 1,
"created_at": "2020-03-14T17:36:41.288578+01:00",
"updated_at": "2020-03-14T17:36:41.288578+01:00",
"name": "Default template",
"body": "{{ template \"content\" . }}",
"type": "campaign",
"is_default": true
}
}

GET /api/templates/:template_id/preview

Gets the HTML preview of a template body.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
template_idPath ParameterNumberRequiredThe id value of the template whose html preview you want to get.
Example Request
curl -u "username:username" -X GET 'http://localhost:9000/api/templates/1/preview'
Example Response
<p>Hi there</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis et elit ac elit sollicitudin condimentum non a magna.
Sed tempor mauris in facilisis vehicula. Aenean nisl urna, accumsan ac tincidunt vitae, interdum cursus massa.
Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam varius turpis et turpis lacinia placerat.
Aenean id ligula a orci lacinia blandit at eu felis. Phasellus vel lobortis lacus. Suspendisse leo elit, luctus sed
erat ut, venenatis fermentum ipsum. Donec bibendum neque quis.</p>

<h3>Sub heading</h3>
<p>Nam luctus dui non placerat mattis. Morbi non accumsan orci, vel interdum urna. Duis faucibus id nunc ut euismod.
Curabitur et eros id erat feugiat fringilla in eget neque. Aliquam accumsan cursus eros sed faucibus.</p>

<p>Here is a link to <a href="https://listmonk.app" target="_blank">listmonk</a>.</p>

PUT /api/templates/:template_id/default

Sets a template to the default template.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
template_idPath ParameterNumberRequiredThe id value of the template you want to set to the default template.
Example Request
curl -u "username:username" -X PUT 'http://localhost:9000/api/templates/1/default'
Example Response
{
"data": {
"id": 1,
"created_at": "2020-03-14T17:36:41.288578+01:00",
"updated_at": "2020-03-14T17:36:41.288578+01:00",
"name": "Default template",
"body": "{{ template \"content\" . }}",
"type": "campaign",
"is_default": true
}
}

DELETE /api/templates/:template_id

Deletes a template.

Parameters
NameParameter TypeData TypeRequired/OptionalDescription
template_idPath ParameterNumberRequiredThe id value of the template you want to delete.
Example Request
curl -u "username:username" -X DELETE 'http://localhost:9000/api/templates/35'
Example Response
{
"data": true
}