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
| Field | Type | Description |
|---|---|---|
idrequired | string · path | — |
Request body3 fields
| Field | Type | Description |
|---|---|---|
variables | object | Values 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`. |
subject | string | Render this subject instead of the template's. |
contact_id | string | Fill contact fields ({{first_name}}, custom fields) from this contact (`con_…`), as a send to them would. |
Response · 200 fields5 fields
| Field | Type | Description |
|---|---|---|
objectrequired | string | — |
subjectrequired | string | — |
htmlrequired | string | The HTML a send would carry, footer and branding included. `{{unsubscribe_url}}` is a preview link. |
textrequired | string | — |
missing_variablesrequired | string[] | Variables with no value: they render as a literal {{token}}, and a real send would refuse them. |
200400401403404422429