Skip to content

Templates

Manage email templates with MJML support, Handlebars variables, versioning, and preview.

List all templates for the organization, with pagination.

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Items per page (max 100)
{
"data": [
{
"id": "tpl-uuid",
"organizationId": "org-uuid",
"name": "Welcome Email",
"description": "Sent on signup",
"tags": ["onboarding"],
"currentVersionId": "ver-uuid",
"createdAt": "2025-01-15T10:00:00Z",
"updatedAt": "2025-01-20T14:30:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 5,
"totalPages": 1
}
}

Create a new template.

FieldTypeRequiredDescription
namestringYesTemplate name (max 255 chars).
descriptionstringNoTemplate description (max 2,000 chars).
tagsstring[]NoUp to 20 tags for categorization.

Status: 201 Created

{
"data": {
"id": "tpl-uuid",
"organizationId": "org-uuid",
"name": "Welcome Email",
"description": "Sent on signup",
"tags": ["onboarding"],
"currentVersionId": null,
"createdAt": "2025-01-15T10:00:00Z",
"updatedAt": "2025-01-15T10:00:00Z"
}
}

Get a template with its current version content.

{
"data": {
"id": "tpl-uuid",
"name": "Welcome Email",
"description": "Sent on signup",
"tags": ["onboarding"],
"currentVersionId": "ver-uuid",
"currentVersion": {
"id": "ver-uuid",
"templateId": "tpl-uuid",
"versionNumber": 3,
"mjmlSource": "<mjml>...</mjml>",
"htmlContent": "<html>...</html>",
"textContent": "Plain text version...",
"variablesSchema": { "name": "string", "activationUrl": "string" },
"createdBy": "user-uuid",
"createdAt": "2025-01-20T14:30:00Z"
}
}
}

Update template metadata (name, description, tags).

FieldTypeRequiredDescription
namestringNoNew template name.
descriptionstringNoNew description.
tagsstring[]NoNew tags.

Delete a template and all its versions (cascade).

Status: 200 OK

{ "success": true }

Create a new template version. The version number auto-increments and the new version is automatically set as the current version.

If mjmlSource is provided, it is compiled to HTML. Validation errors are returned if the MJML is invalid.

FieldTypeRequiredDescription
htmlContentstringYesCompiled HTML content.
mjmlSourcestringNoMJML source (compiled server-side if provided).
textContentstringNoPlain text fallback.
variablesSchemaobjectNoJSON schema describing expected variables.

Status: 201 Created

{
"data": {
"id": "ver-uuid",
"templateId": "tpl-uuid",
"versionNumber": 4,
"mjmlSource": "<mjml>...</mjml>",
"htmlContent": "<html>...</html>",
"textContent": null,
"variablesSchema": null,
"createdBy": "user-uuid",
"createdAt": "2025-01-22T09:00:00Z"
}
}

List all versions of a template (version number and metadata, without full content).

{
"data": [
{
"id": "ver-uuid-4",
"templateId": "tpl-uuid",
"versionNumber": 4,
"createdBy": "user-uuid",
"createdAt": "2025-01-22T09:00:00Z"
},
{
"id": "ver-uuid-3",
"templateId": "tpl-uuid",
"versionNumber": 3,
"createdBy": "user-uuid",
"createdAt": "2025-01-20T14:30:00Z"
}
],
"currentVersionId": "ver-uuid-4"
}

Get a specific version with full content (HTML, MJML source, text).

Render a template with sample variables and return the HTML output. Useful for previewing templates before sending.

FieldTypeRequiredDescription
variablesobjectNoSample variable values.
versionIdstringNoSpecific version to preview. Defaults to current version.
{
"html": "<html><body><h1>Hello Jane!</h1>...</body></html>",
"text": "Hello Jane! ..."
}

POST /v1/templates/:id/rollback/:versionId

Section titled “POST /v1/templates/:id/rollback/:versionId”

Set a previous version as the current version.

{
"data": {
"templateId": "tpl-uuid",
"currentVersionId": "ver-uuid-2",
"versionNumber": 2
}
}