Skip to main content
Render an unsaved draft — the template fields travel in the request body, so nothing is stored. This is the endpoint behind the dashboard’s live template editor. POST /v1/templates/preview To render a template you’ve already saved, use POST /v1/templates//render instead, which references it by id.

Body parameters

All fields are optional — send the draft fields you want to render.
subject
string
Draft subject line with merge variables.
html
string
Draft HTML body.
text
string
Draft plain-text body.
data
object
Merge variables to substitute. HTML values are escaped before insertion into the html field.

Request

curl https://api.drin.run/v1/templates/preview \
  -H "Authorization: Bearer $DRIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Hi {{name}}",
    "html": "<b>Welcome, {{name}}!</b>",
    "data": { "name": "Sam" }
  }'

Response

subject
string
The rendered subject.
html
string | null
The rendered HTML, or null when not supplied or on a syntax error.
text
string | null
The rendered text, or null.
missing
string[]
Referenced variables absent from data.
error
string
Present only when a draft field has a template syntax error. The request still returns 200 OK so the editor can show the message inline.
200 OK
{
  "subject": "Hi Sam",
  "html": "<b>Welcome, Sam!</b>",
  "text": null,
  "missing": []
}

Syntax error

A malformed block (e.g. an unclosed {{#if}}) returns 200 with an error string rather than a 4xx, so a live editor can surface it without treating it as a failed request.
200 OK · with error
{
  "subject": "Hi Sam",
  "html": null,
  "text": null,
  "missing": [],
  "error": "unexpected end of input in {{#if"
}
HTML escaping. Values in data are HTML-escaped before substitution into html. Use the triple-brace {{{raw}}} form only for values you trust to be safe markup.