v24

latestOpenAPI 3.0.3raw.githubusercontent.com2026-08-014382230.2 KB

Compile template

Compiles an MJML template with provided data, returning the rendered HTML. When subject and/or subject_preview are provided, they are rendered through the same Liquid engine used at send time and returned alongside the HTML so callers do not need to run a separate Liquid pass to preview the subject line. Useful for previewing templates before saving.

post/api/templates.compile

Request body

workspace_idstring required

The ID of the workspace

message_idstring required

Unique message ID for tracking

visual_editor_treeobject required

MJML visual editor tree structure (must have type 'mjml')

subjectstring

Optional email subject. When provided, it is rendered through the same Liquid engine the send path uses (with test_data) and the rendered result is returned as subject in the response. Liquid processing is skipped when preserve_liquid is true, channel is web, or test_data is empty.

subject_previewstring

Optional inbox preview text (the snippet shown after the subject in most clients). Rendered through Liquid like subject and returned as subject_preview in the response.

test_dataobject

Data to use for Liquid templating

channel'email' | 'web'

Channel filter for block visibility

Example request

{
  "workspace_id": "ws_1234567890",
  "message_id": "msg_abc123",
  "subject": "Hi {{ contact.first_name }}",
  "subject_preview": "Welcome {{ contact.first_name }}",
  "test_data": {
    "user_name": "John Doe",
    "action_url": "https://example.com/action"
  }
}

Response

Template compiled successfully

successboolean

Whether compilation was successful

mjmlstring

Generated MJML markup

htmlstring

Compiled HTML output

subjectstring

Rendered email subject. Present only when the request included a non-empty subject. Returned on both success and error paths so the caller can display the rendered subject alongside any compilation error.

subject_previewstring

Rendered inbox preview text. Present only when the request included a non-empty subject_preview. Returned on both success and error paths.

Example response

{
  "subject": "Hi Pierre",
  "subject_preview": "Welcome Pierre"
}