Render a template

Render a template

POST/api/v1/email/templates/{id}/render

POST /email/templates/{id}/render
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/render' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 200
{
  "object": "template_render",
  "subject": "Welcome to Acme",
  "html": "string",
  "text": "string",
  "missing_variables": [
    "string"
  ]
}

The subject, HTML and text a send of this template would carry, with your footer and branding, without sending or storing anything. Pass variables as a send's template.variables, and contact_id to fill contact fields from that contact. missing_variables lists the variables left without a value: they render as a literal {{token}} here, and a real send refuses them. {{unsubscribe_url}} renders a preview link. A POST only because it takes a body; any other key is a 422. Requires the templates:read capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Request body3 fields
FieldTypeDescription
variablesobjectValues for the template's {{variables}}, as a send's `template.variables`. One with no value stays a literal {{token}} and is listed in `missing_variables`.
subjectstringRender this subject instead of the template's.
contact_idstringFill contact fields ({{first_name}}, custom fields) from this contact (`con_…`), as a send to them would.
Response · 200 fields5 fields
FieldTypeDescription
objectrequiredstring—
subjectrequiredstring—
htmlrequiredstringThe HTML a send would carry, footer and branding included. `{{unsubscribe_url}}` is a preview link.
textrequiredstring—
missing_variablesrequiredstring[]Variables with no value: they render as a literal {{token}}, and a real send would refuse them.
200400401403404422429

Search docs and guides

Search the docs and product guides.