POST/api/v1/projects/{project_id}/templates/{template_id}/preview
Needs scope: readIdempotency-KeyMCP tool: preview_template
operationId preview_template
Preview a message template
Renders the template’s latest version, with the latest versions of the
partials it includes, as a subscriber would get it: the subscriber
subscriber_id’s email, attributes and list name, or
sample_attributes, or, with neither, sample values. The unsubscribe
and confirmation links are samples (https://postwind.invalid/...);
campaign.name is Sample campaign. The text is the text body, or
the HTML made into text; when the project’s auto_footer is true, the
footer with the unsubscribe link is added to each that does not show
{{ unsubscribe_url }}. Nothing is written. Needs scope read.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
project_idrequired |
path | string · uuid | The project’s id |
template_idrequired |
path | string · uuid | The message template’s id |
Idempotency-Key |
header | string
1–128 characters · pattern |
A key of the client’s choosing, one per request it means to send once (a UUID will do). A repeat with the same key and the same body within 24 h creates nothing again and gets the first answer, marked Idempotent-Replayed: true. The key belongs to the API key that sent it. Only a 2xx answer is kept: after any other answer the key is free again. |
Request body
application/json · required
- PreviewTemplateRequest object
-
sample_attributesobject | nullAttributes to render with, as a subscriber’s: string, number or boolean values, up to 64 keys, up to 4 KB of JSON; any other attribute the template names is undefined. Not with
subscriber_id;nullor left out: none. -
subscriber_idstring · uuid | nullA subscriber of the project: its email, attributes and list name. Not with
sample_attributes;nullor left out: none.
Responses
200
The rendered message
| Header | Type | Description |
|---|---|---|
Idempotent-Replayed | string · enum | true when the answer is a replay of an earlier request with the same Idempotency-Key; absent otherwise. |
- TemplatePreview object · all fields required
-
htmlstringThe HTML part, with the automatic footer when it was added.
-
subjectstring -
textstringThe text part: the text body, or the HTML made into text; with the automatic footer when it was added.
-
warningsarray of PreviewWarning3 fields
- PreviewWarning object · all fields required
-
codestringsubscriber_not_active,subscriber_list_deleted,empty_subject,html_too_large,auto_footer_added,text_from_html.example
auto_footer_added -
messagestring -
partPreviewPart | nullThe part it is about;
null: the message as a whole.- subject
- html
- text
404
No such project, template or subscriber in it, or another project’s (not_found)
409
A request with the same Idempotency-Key has not answered yet (idempotency_key_in_progress)
422
Invalid fields, every one in errors (validation_failed): both subscriber_id and sample_attributes, invalid attributes, a partial (template_id), or the template does not render with this data, with the codes of saving; or the Idempotency-Key was used in the last 24 h for another request (idempotency_key_reused), or is not 1 to 128 visible ASCII characters (validation_failed, field Idempotency-Key)
429
The key is over its rate limit, api.rate_limit_per_minute requests a minute on this node (rate_limited)
| Header | Type | Description |
|---|---|---|
Retry-After | integer | Seconds until the key’s next request passes; rounded up. |
504
Postwind’s storage did not answer within its time limit (storage_timeout). A change the request makes may still take effect: check before repeating it. A repeat with the same Idempotency-Key never runs it twice: it is 409 idempotency_key_in_progress until the key’s 24 h end