email-templates

Get an email template preview

Renders a template with the sample values you supply and returns the resulting subject, HTML, and plain-text bodies. Bird does not issue a recipient-specific unsubscribe URL in a preview. If you supply bird.unsubscribe_url in parameters, the preview renders your value; an empty link is not live. Bird adds unsubscribe content to marketing email at send time; transactional email gets no automatic unsubscribe footer. By default it renders the current draft, so you can check your changes before you submit it. Pass version to preview a specific published version instead; built-in system templates have no versions, so version on a bird_ template returns a validation error. Pass contact to see the email the way one of your contacts would receive it. Works for your workspace templates and built-in system templates. Sample parameters are capped at 16 KB once serialized, and personalization that is not valid or not supported returns a validation error naming what to fix. The response also reports what the HTML uses that mail clients remove, ignore, or render inconsistently. Each finding in compatibility names the pattern, the line and column it sits on, and what to use instead, and compatibility_severity reduces them to one word for the whole body. It is advisory: the preview renders either way.

post/v1/email/templates/{template_ref}/preview

Request

  • Base URL: https://us1.platform.bird.com
  • URL: https://us1.platform.bird.com/v1/email/templates/{template_ref}/preview
  • Auth: one of:
    • HTTP bearer
    • API key in cookie bird_session

Headers

Idempotency-Keystring

Client-supplied key. On operations supporting request deduplication, a retained response is replayed for duplicate requests with the same key within the idempotency window (3 hours by default). This protection requires a workspace, organization, or staff-account scope. User-only and unscoped unauthenticated operations, streams, and operations with a separate replay contract do not use this response replay.

On a supported operation, if idempotency protection is unavailable before execution, the API returns 503 IdempotencyUnavailable (E01033) without executing this attempt. Retry with backoff using the same key and request. An operation that takes effect before its response is retained can still execute again on retry.

Two distinct 409 errors signal misuse:

  • request_in_progress (E01004): The same key is currently being processed by a concurrent request. Wait briefly and retry. The lock expires within 30 seconds.
  • idempotency_key_reuse (E01005): The same key has already completed against a different request body or method. Generate a new key.

Recommended key format is <event-type>/<entity-id> (for example welcome-user/usr_abc123).

X-Workspace-Idstring

Workspace context for the request. Required for dashboard authentication and master keys. Workspace keys and access tokens already identify their workspace; send that workspace or omit the header. A different one is rejected.

X-Organization-Idstring

Organization context for the request. Required for dashboard authentication. An API key or access token carries its own organization, so send either that organization or no header at all; a different one is rejected.

Request body

parametersobject

Sample values for the variables the template uses, for this one preview only. A variable takes its value under its own name. A bird. value nests to match the token, so {"bird": {"contact": {"first_name": "Ada"}}} fills {{ bird.contact.first_name }}.

A preview is more forgiving than a send: a parameter you leave out renders as empty here rather than being rejected. parameters is capped at 16 KB once serialized.

contactstring
languagestring

A language tag in BCP-47 form, for example en or pt-BR.

versionstring

Example request

{
  "content": {
    "subject": "Welcome to Acme, {{ bird.contact.first_name }}!",
    "preview_text": "{{ bird.contact.first_name }}, your order is on its way",
    "html": "<h1>Hi {{ bird.contact.first_name }}</h1>"
  },
  "parameters": {
    "bird": {
      "contact": {
        "first_name": "Ada"
      }
    },
    "animal": "otter"
  },
  "contact": "con_01krdgeqcxet5s7t44vh8rt9mg",
  "language": "pt-BR",
  "version": "emv_01krdgeqcxet5s7t44vh8rt9mg"
}

Response

The rendered preview.

editor_urlstring uri

Optional link to open the saved draft in the browser editor, in the language this preview rendered. Absent for built-in templates, published-version previews, and previews of unsaved content.

subjectstring nullable required

The rendered subject line. Null when the template has no subject.

htmlstring nullable required

The rendered HTML body. Null when the template has no HTML body.

textstring nullable required

The rendered plain-text body. Derived from the HTML when the template has no separate plain-text body, and null when it has neither.

languagestring required

A language tag in BCP-47 form, for example en or pt-BR.

compatibility_severity'problem' | 'warning' | 'none' required

The worst severity across every finding the response was computed from, which is the authoritative reading: a response that caps how many findings it lists still accounts here for the ones it left out. Each response's compatibility says which content it covered.

  • problem: at least one finding is a problem.
  • warning: every finding is a warning.
  • none: there are no findings.

Example response

{
  "language": "pt-BR",
  "compatibility_severity": "warning",
  "compatibility": [
    {
      "rule_id": "css_display_flex_grid",
      "severity": "warning",
      "language": "pt-BR",
      "field": "html",
      "message": "`display: flex` and `grid` don't work in Outlook (Windows/Windows Mail).",
      "fix": "Use tables for layout.",
      "partial": "Partial support for `display: flex` and `grid` in Gmail (iOS/Android).",
      "line": 14,
      "column": 6,
      "match": "display: flex",
      "unsupported_clients": [
        {
          "family": "outlook",
          "platforms": [
            "windows",
            "windows_mail"
          ]
        }
      ],
      "partial_clients": [
        {
          "family": "outlook",
          "platforms": [
            "windows",
            "windows_mail"
          ]
        }
      ]
    }
  ]
}

Changes

No recorded changes to this operation across all 2 revisions of this API.