Compile template

Compiles an MJML template with provided data, returning the rendered HTML. 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')

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",
  "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

Changes