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

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'
The key names its own organization, so no X-Organization-ID header is needed.

Response

Success.

  • dataobject
    • objectstringtemplate_preview
    • subjectstring

      The subject with `{{ }}` substituted, as a real send would render it -- the preview runs the same renderer. NULL MEANS NONE: you supplied no `subject` to render, so there was nothing to give back. A subject you DID supply that renders away to nothing comes back as `""`, not null, so the two cases stay distinguishable -- which matters, because `""` usually means a `{{ }}` name you did not pass a value for.

    • htmlstring

      Substituted values are HTML-escaped here and left raw in `subject` and `text`. NULL MEANS NONE -- no `html` was supplied to render -- and, as with `subject`, an empty render is `""` rather than null. This endpoint renders ONLY what you post: it does not load a stored template, so a request carrying just a `template_id` previews nothing and every content field here is null.

    • 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 the supplied content -- what an editor builds its sample-value form from. This field was called `tags` before, which in this same module means the caller's labels on a message; they are unrelated. Names, not values: a placeholder appears here whether or not you supplied a value for it.

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.