Mail API reference

Mail API · Templates

post/v1/workspaces/{workspace_id}/templates/previewAuth

Preview an unsaved draft. Renders subject + bodyHtml against the workspace brand tokens + supplied data, with all workspace layouts/partials registered. Used by the editor for live preview.

Path parameters

workspace_id*string · uuid

Id of the workspace.

Request body

subjectstring

Subject template (Handlebars).

body_html*string

HTML body to render (Handlebars).

dataobject

Sample data to render variables with. Keys are your variable names and are kept exactly as sent.

Response · 200

subject*string

The rendered subject line.

html*string

Fully-rendered HTML body.

text*string

Plain-text body (derived if not authored).

Example

Request

POST https://api.mail.productcraft.co/v1/workspaces/{workspace_id}/templates/preview
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "subject": "string",
  "body_html": "string",
  "data": {}
}

Response

{
  "subject": "string",
  "html": "string",
  "text": "string"
}