API Reference
Templates Create, update, list, and preview email templates built with MJML and Liquid variables.
Templates define the content and layout of your emails. They are written in MJML for responsive rendering and support Liquid variables for personalisation.
Creates a new template or updates an existing one. This endpoint is idempotent — calling it multiple times with the same ID and body produces the same result.
Parameter Type Description idstring A unique identifier for the template (e.g. welcome-email, password-reset).
Field Type Required Description idstring Yes Must match the path parameter. namestring Yes Human-readable name for the template. subjectstring Yes Email subject line. Supports Liquid variables (e.g. Welcome, {{ firstName }}!). mjmlstring Yes The MJML source for the email body. variablesstring[] No List of variable names used in the template. Used for validation and the preview UI.
Returns the created or updated template.
{
"id" : "welcome-email" ,
"name" : "Welcome Email" ,
"subject" : "Welcome, {{ firstName }}!" ,
"mjml" : "<mjml><mj-body>...</mj-body></mjml>" ,
"variables" : [ "firstName" , "dashboardUrl" ],
"version" : 3 ,
"createdAt" : "2025-09-10T08:00:00.000Z" ,
"updatedAt" : "2025-09-15T14:00:00.000Z"
}
Code Description VALIDATION_ERRORMissing required fields or invalid MJML syntax.
curl -X PUT https://api.kraiter.com/api/templates/welcome-email \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "welcome-email",
"name": "Welcome Email",
"subject": "Welcome, {{ firstName }}!",
"mjml": "<mjml><mj-body><mj-section><mj-column><mj-text>Hello {{ firstName }}, welcome to Kraiter!</mj-text></mj-column></mj-section></mj-body></mjml>",
"variables": ["firstName"]
}'
const template = await kraiter.templates. put ( "welcome-email" , {
id: "welcome-email" ,
name: "Welcome Email" ,
subject: "Welcome, {{ firstName }}!" ,
mjml: "<mjml><mj-body><mj-section><mj-column><mj-text>Hello {{ firstName }}, welcome to Kraiter!</mj-text></mj-column></mj-section></mj-body></mjml>" ,
variables: [ "firstName" ],
});
Returns a paginated list of templates.
Parameter Type Default Description cursorstring — Pagination cursor from a previous response. limitnumber 20 Number of templates to return (max 100).
{
"data" : [
{
"id" : "welcome-email" ,
"name" : "Welcome Email" ,
"subject" : "Welcome, {{ firstName }}!" ,
"version" : 3 ,
"createdAt" : "2025-09-10T08:00:00.000Z" ,
"updatedAt" : "2025-09-15T14:00:00.000Z"
}
],
"nextCursor" : null
}
curl "https://api.kraiter.com/api/templates?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
const templates = await kraiter.templates. list ({ limit: 10 });
Returns a single template including its full MJML source.
Parameter Type Description idstring The template ID.
Code Description NOT_FOUNDNo template with this ID exists.
curl https://api.kraiter.com/api/templates/welcome-email \
-H "Authorization: Bearer YOUR_API_KEY"
const template = await kraiter.templates. get ( "welcome-email" );
DELETE /api/templates/:id
Permanently deletes a template. Sequences referencing this template will fail on their next send.
Parameter Type Description idstring The template ID.
Returns 204 No Content on success.
Code Description NOT_FOUNDNo template with this ID exists.
curl -X DELETE https://api.kraiter.com/api/templates/welcome-email \
-H "Authorization: Bearer YOUR_API_KEY"
await kraiter.templates. delete ( "welcome-email" );
GET /api/templates/:id/versions
Returns the version history for a template. Each time a template is updated via PUT, a new version is created.
Parameter Type Description idstring The template ID.
{
"data" : [
{
"version" : 3 ,
"subject" : "Welcome, {{ firstName }}!" ,
"updatedAt" : "2025-09-15T14:00:00.000Z"
},
{
"version" : 2 ,
"subject" : "Welcome to Kraiter!" ,
"updatedAt" : "2025-09-12T09:00:00.000Z"
}
],
"nextCursor" : null
}
curl "https://api.kraiter.com/api/templates/welcome-email/versions" \
-H "Authorization: Bearer YOUR_API_KEY"
const versions = await kraiter.templates. listVersions ( "welcome-email" );
POST /api/templates/:id/preview
Renders the template with the provided variables and returns the resulting HTML. Use this to preview how an email will look before sending.
Parameter Type Description idstring The template ID.
Field Type Required Description variablesobject No Key-value pairs to inject into the template.
{
"subject" : "Welcome, Alice!" ,
"html" : "<!doctype html><html>..."
}
curl -X POST https://api.kraiter.com/api/templates/welcome-email/preview \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "variables": { "firstName": "Alice" } }'
const preview = await kraiter.templates. preview ( "welcome-email" , {
variables: { firstName: "Alice" },
});
console. log (preview.html);