POST/api/v1/projects/{project_id}/templates/{template_id}/preview
preview_template
Renders a message template as a subscriber would get it, before anything is sent: the subject, the HTML and the text, with warnings.
- Call it
- to check the layout and the variables of a template, for one subscriber (
subscriber_id: its email, attributes and list name) or withsample_attributes(not both; with neither, every attribute is the textsample). The latest version of the template and of each partial it includes is rendered; the unsubscribe links are samples (https://postwind.invalid/...) andcampaign.nameisSample campaign. A template without a text body gets its text made from the HTML; when the project’sauto_footeris true, a part that does not show{{ unsubscribe_url }}gets the footer with the unsubscribe link. - Needs
- an admin key with
project_id, or a project key with scoperead(its own project; the argument is ignored), and a message template: a partial isvalidation_failedontemplate_id; a subscriber of another project isnot_found; a template that does not render with this data isvalidation_failedwith the errors of saving. Nothing is written. - Returns
subject,html,textandwarnings(code,part,message), the same asPOST /api/v1/projects/{project_id}/templates/{template_id}/preview.
Arguments
- object
-
template_idstring · uuidrequiredThe message template’s id.
-
project_idstring · uuid | nullThe template’s project. An admin key must pass it; a project key’s own project is used and this is ignored.
-
sample_attributesmap of string → string | number | boolean | nullAttributes to render with, as a subscriber’s (string, number or boolean values). Not with
subscriber_id; with neither, every attribute is the textsample. -
subscriber_idstring · uuid | nullA subscriber of the project to render for: its email, attributes and list name. Not with
sample_attributes.
No other arguments are accepted.
Result
The result comes back as structuredContent, with the same JSON as a text block.
- 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 PreviewWarningOutput3 fields
- PreviewWarningOutput object · all fields required
-
codestringsubscriber_not_active,subscriber_list_deleted,empty_subject,html_too_large,auto_footer_added,text_from_html. -
messagestring -
partPreviewPartOutput | nullThe part it is about;
null: the message as a whole.- subject
- html
- text
Definitions
PreviewPartOutput
The part of a message a warning is about.
string · enum
- subject
- html
- text
PreviewWarningOutput
Something about the preview to look at.
- object · all fields required
-
codestringsubscriber_not_active,subscriber_list_deleted,empty_subject,html_too_large,auto_footer_added,text_from_html. -
messagestring -
partPreviewPartOutput | nullThe part it is about;
null: the message as a whole.- subject
- html
- text
Errors
A failed call answers isError: true with a code from the same table as the HTTP API, and detail. How tools report errors
HTTP API
The same operation over HTTP: POST /api/v1/projects/{project_id}/templates/{template_id}/preview