Preview a rendered template

POST/api/v1/email-templates/preview
Requires anorganization API keywith the scopetemplates:read

Renders a template with the variables you supply and returns the result without sending anything. Worth calling in your own test suite: it is the cheapest way to catch a variable you renamed on one side and not the other.

Request body

  • subjectstring

    The subject line to preview.

  • htmlstring

    The HTML to preview, with {{ tags }}.

  • skeleton_htmlstring

    Optional, advanced. Your own HTML with data-my-edit on the parts people may change in the dashboard. We build html from it and content.

  • source_template_keystring

    Optional. Make the template from one of our ready-made designs, by the design's key. We build html from the design, your brand kit and content.

  • contentobject

    For a template made from a design (source_template_key) or from skeleton_html: the text and images for each editable part, keyed by the part's name. Not used with plain html.

  • layoutstring

    For a template made from a design: which version of the design, for example branded or plain. A name the design does not have falls back to its default.

  • show_company_nameboolean

    For a template made from a design: show your company name at the top. Leave it out, or send null, to follow your brand kit.

  • plain_textstring

    Plain text to preview. With plain: true, it is laid out exactly as a plain email is sent.

  • plainboolean

    Send true to preview plain_text as a plain email, exactly as it would be sent.

  • variablesobject

    Sample values for the {{ tags }}, like {"name": "Ada"}. email and organization_name are filled for you.

  • brandobject

    Optional. Brand kit values to try before saving them (logo, colours, company name).

Request

POST/api/v1/email-templates/preview
curl -X POST 'https://app.mailyte.com/api/v1/email-templates/preview' \
  -H 'Authorization: Bearer mk_live_YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "html": "<p>Hi {{name}}</p>",
    "variables": {
      "name": "Ada"
    }
  }'
The key names its own organization, so no X-Organization-ID header is needed.

Response

Success.

  • dataobject
    • objectstringtemplate_preview
    • subjectstring

      The subject with {{ }} variables filled in, as a real send would show it. Null when you sent no subject. "" usually means a placeholder you gave no value for.

    • htmlstring

      The HTML with {{ }} variables filled in; values are HTML-escaped here. Null when you sent no html. This endpoint previews only what you post: it does not load a saved template.

    • textstring

      The rendered plain-text body. The REQUEST field for it is plain_text, not text: this endpoint validates plain_text and drops a text key, so posting text renders nothing and returns null here.

    • variablesarray<string>

      The {{ }} placeholder names found in what you sent, whether or not you gave them values.

Returned inside the standard envelope.

Errors

StatusWhen
401The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist.
403The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys.
404No such resource in this organization.
422The request was understood but the values were not acceptable.
429Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait.

Every status, with what causes it and what to do, is on the error reference.