Preview Email
Render an email without sending it. The body matches Send Email: pass text and/or html, or a template_id with data.
When template_id is set, the compiled template is rendered with data, including substitute and markdown. Any text or html on the request is ignored. subject is rendered with the template language as plain text, using the template default when the request omits it. from and to are optional and are not returned.
A raw html or text body is returned as given. substitute and markdown run only when a template is rendered. To preview a message field on its own, use Preview Fields.
Nothing is stored or queued. Open and click tracking are not applied.
/emails/preview
/emails/preview
Body Parameters
Subject line. When template_id is set, placeholders such as {{name}} are filled from data.
Plain-text body. Ignored when template_id is set. Required unless html or template_id is provided.
HTML body. Ignored when template_id is set. Required unless text or template_id is provided.
A template TypeID or user_id. When set, the template body is used. Test keys (test_…) render the test template if one exists for that user_id.
Values substituted into the template. Interpolated values are HTML-escaped and newlines become <br>.
Data keys to render as templates before the outer template runs. Same behavior as Send Email.
Data keys to render as CommonMark after substitute. Same behavior as Send Email.
Example
curl -X POST https://api.mailcast.io/v1/emails/preview \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d $'{
"template_id": "template_01k3tgwp77e9ns7r3g7c2fg1hw",
"subject": "Welcome {{name}}",
"data": {
"name": "John"
}
}'
{
"subject": "Welcome John",
"html": "Hello John",
"text": null
}