Render a template without saving or sending

Search Documentation

Search across all developer documentation

entities

Render a template without saving or sending

POST /v1/templates/render
Auth required api.templates.view

Renders a stored template (template, by slug) or content you have not saved (body) against the merge values in variables. Supply exactly one of template and body. Nothing is written and no mail is sent, which is why this needs only api.templates.view.

Read variables_unresolved before you send anything. A merge field the template prints and your data does not carry renders as nothing in a real inbox — and for a STORED template SES refuses the render outright, which is a bounce rather than a blank. variables_used is the complement: the fields the data did resolve.

With no variables at all, a template renders against an auto-generated stub built from its own merge fields, so the shape of the email is still visible.

Request body

Content type: application/json

template string optional

Slug of a stored template to render.

body string optional

Unsaved content to render instead.

subject string optional

Rendered alongside body. Ignored with template, which uses the stored row's own subject.

variables object optional

Merge values. With none, a template renders against an auto-generated stub built from its own merge fields.

Responses

Errors follow the RFC 7807 problem format — see the error reference.

200 The rendered template application/json
slug string | null required

The stored template rendered; null when body was rendered.

subject string required
html string required
text string required
warnings array<object> required

Each entry in warnings:

type string enum required

One of: missing_variable, extra_variable, type_mismatch

variable string required
expected string optional
got string optional
message string required
direct boolean required

Whether the template PRINTS this variable. Only a direct missing_variable fails an SES render; one used solely as a block-helper argument renders happily.

variables_used array<string> required

Merge fields the template references that the supplied data resolved.

variables_unresolved array<string> required

Merge fields the template references that the supplied data did NOT resolve. Read this before sending: an unresolved printed field renders blank in a real inbox, and SES refuses the render of a stored template outright.

401 Missing, malformed, or unknown API key application/problem+json
403 Key lacks the required scope or plan limit violated application/problem+json
404 Resource not found application/problem+json
422 A query parameter, path value or body field failed validation. The body is a validation_failed Problem. When the refusal is about a reference — a segment key, template slug, topic or attribute name the organization does not have — it additionally carries validation_code, field, line/column, missing, candidates and next_step, so a client can correct the call without a second round of guessing. See ValidationProblem. application/problem+json
429 Per-org rate limit exceeded application/problem+json
500 Unexpected server-side failure. The code is internal_error. The request_id field can be quoted to SendOps support to investigate. application/problem+json