Sign inGet Started

Email templates

A template is a subject line and an email body that you save once and send many times. You write the parts that change as {{ variable }} placeholders, publish the template, and then send it by slug instead of pasting the same HTML into every API call. A template belongs to your workspace.

Author and manage templates in Email > Templates, through /v1/email/templates, with the bird CLI, or through the MCP server. Typed methods ship in the TypeScript, Python, PHP, and Go SDKs under email.templates. Full request and response schemas are in the API reference. Send a published template through the regular send endpoint.

Template structure

Every template has two identifiers with different roles:

  • slug is the identifier you reference when sending, such as welcome-email. You choose it at creation and cannot change it later. A slug can contain lowercase letters, numbers, hyphens, and underscores, must start and end with a letter or number, and can be up to 63 characters long. Two prefixes are reserved: bird_ for built-in templates and emt_ for template IDs. The dashboard calls this field Alias.
  • name is a free-text display label. It defaults to the slug. You can change it at any time. Sending does not resolve templates by display name. Renaming a template does not affect API calls.

A template also has a permanent emt_ ID that never changes, a category (marketing or transactional), and an authoring source (html, meaning markup you provide, optionally personalized with Liquid). Both category and source are fixed when you create the template.

We provide a catalog of built-in templates whose slugs start with bird_. A built-in template does not belong to any workspace, cannot be edited, and is ready to send as provided. Copying a built-in template into your workspace creates an ordinary editable template. The copy starts as an unpublished draft that inherits the original's category, source, and language settings. Publish the copy before sending it.

Drafts and published versions

Every template has one draft, which is the working copy you edit. It can also have any number of immutable published versions, numbered sequentially (1, 2, 3, and so on). Editing updates the draft in place. Publishing snapshots the current draft into the next numbered version and sets it as the active version for sending. The draft remains editable for future changes.

New message requests use the template's active published version. Drafts cannot be sent directly. You can edit the draft while your published version continues sending, then publish when the update is ready. Publishing a new version or rolling back to an earlier version changes what new requests render once active. Messages already accepted before a publish or rollback (including scheduled messages) keep the version from when they were accepted. Cancel and replace a scheduled message before dispatch if it needs the updated version.

The template Versions tab with a Draft row and published v3, v2, and v1 rows showing their creation and publication dates

You can also discard the draft's changes to reset the draft to the currently published version or roll back to restore an earlier published version as the active version for sending. You can only roll back to a published version. Rolling back replaces the draft with that version's content. Any unsaved edits in the draft are lost. Further edits start from the restored version. A rollback does not create a new version.

To choose an existing image, you need read access to the workspace media library. To upload, paste, or drop a new image, you need write access. If Insert image is disabled or you cannot browse or upload, ask a workspace administrator for the matching media-library permission. Template editing permission alone does not grant media-library access.

In the dashboard, choose Visual > Insert image to search your media library or upload a PNG, JPEG, GIF, or static WebP image within the media-library upload limits. Static WebP uploads convert to PNG or JPEG. Select the image to set its Image description, display width, alignment, and link. Mark an image as Decorative image only when it does not add information. A linked image needs a description that explains its destination. Each language keeps separate image descriptions and layout.

Use Replace image to change a selected image while keeping its description, link, width, and alignment. You can also paste or drop one image file into the visual editor. Wait for the upload to finish, or cancel it, before saving or sending a test. Select Preview to check the rendered email, then select Send test email to send the current content to yourself. Code remains available for editing HTML.

Removing an image from the media library does not remove it from already-sent email. Replacing an image uses a new URL. Earlier messages continue showing the original image.

Saving uses optimistic concurrency via a revision number. Send the revision you last read for the language you are saving. If someone else modified that language in the meantime, the API rejects the save with a conflict instead of overwriting their work. Omit revision to save unconditionally. Publishing and rolling back use the draft's revision the same way.

Content in more than one language

A template supports up to 25 languages, tagged with BCP-47 codes such as en or pt-BR. Each language has a separate subject and body. One language is the template's default. Publishing a template publishes every language in it at the same time. You cannot publish a single language independently. Every language you have added must be complete first. Each language needs a subject and a body. The template's default language must also have content. If anything is missing, publishing fails and the error lists every missing field by language so you can fix everything in one pass. You do not need to finish every planned language up front. Publish the languages that are ready and add more later.

In the dashboard, you choose the default language when you create a template. To change it later, switch the editor to another language and choose Set as default… in the language menu. Send test email in Preview can send any language defined on the template. It requires a subject and content in the language currently open. Fill those in or switch to a finished language first. The open language sends its current editor state. Any other language sends its last saved draft.

Every language requires an HTML body. If you omit text, publishing automatically generates a plain-text alternative from the HTML so messages include both parts without you writing plain text manually.

Each language can also include optional preview text (sometimes called a preheader), which is the snippet an inbox shows after the subject in its message list. Preview text can be up to 255 characters and supports the same {{ variable }} placeholders as the subject. If you omit it, the inbox falls back to the opening text of the email body. Publishing rejects preview text on a language without an HTML body because mail clients read preview text from hidden HTML markup. Publishing also rejects {{ bird.unsubscribe_url }} in preview text and subjects because neither field supports links.

These two settings control what happens when a request omits a language or asks for a language the template does not contain:

SettingWhat it controls
on_missing_languageControls what happens when a request specifies a language the template does not have. fallback (the default) serves the closest match. It tries a broader form of the same language first (for example, a stored pt serves a request for pt-BR). Otherwise, it falls back to the template's default language. fail rejects the request instead, useful when sending the wrong language is worse than not sending.
language_source_requiredControls whether every request must specify a language. This setting is off by default. A request that omits a language uses the template's default language. When enabled, a request without a language is rejected. Because a broadcast uses a single language for its entire audience, a template with this setting enabled requires you to pick that language before sending the broadcast.

You can configure these settings independently. By itself, on_missing_language: "fail" only applies when a request specifies an unavailable language. A request that omits a language still succeeds using the default. Enable both settings together to require every request to specify a language explicitly.

Personalizing with variables

Individual, batch, and scheduled template sends can use contact values. Each To address must match a contact when the template reads bird.contact.*.

Write {{ variable }} placeholders in the subject, preview text, and body. We detect placeholders automatically across every language. You do not need to declare them separately. The placeholder prefix distinguishes the two kinds. A path starting with bird. reads from our data, either a contact record or the unsubscribe link. Everything else is a parameter you supply when sending.

Parameter names must be a single word, such as {{ animal }}. Dotted parameter names are rejected at publish time because parameters are flat values. Pass the value as a flat key inside template.parameters or read contact data with bird.contact.<attribute> instead.

In a single or batch request, parameter values come from the template.parameters object, keyed by parameter name. One set of values applies to every recipient of that message. The key bird is reserved. Passing bird in template.parameters returns 422.

Use bird.contact.<attribute> to read the recipient's contact properties, including the built-in first_name, last_name, and email fields. Individual and batch sends match each To address to a contact in the same workspace. Cc and Bcc recipients receive a copy of each To recipient's personalized email. They do not need matching contacts. A broadcast reads its audience contacts and also accepts caller values in its template parameters.

Code example
Hi {{ bird.contact.first_name }},

Supply the required caller parameters used by the resolved language. A missing or null required parameter returns 422. An intentional empty string remains valid. The version's variables list aggregates parameters across every language. A parameter used only by another language does not need a value for the current request.

Publishing records the contact attributes used by each language. Sending fetches only the attributes used by the selected language and send fields. A message without contact references skips contact lookup.

A template that reads bird.contact.* requires a matching workspace contact for each To recipient. If a To recipient has no contact, the API returns 422 with E04099 before accepting any message, including in a batch or a scheduled email. Create or update the contact first. Otherwise, use caller parameters. A Liquid default filter or conditional does not remove this requirement. Templates that use caller parameters or bird.unsubscribe_url without contact attributes do not require a matching contact.

For example, send Hello {{ bird.contact.first_name }} to Alice and Bob, with Charlie in Cc:

DeliveryGreetingVisible To
AliceHello AliceAlice
Charlie, copied on Alice's emailHello AliceAlice
BobHello BobBob
Charlie, copied on Bob's emailHello BobBob

Charlie receives two copies. The request produces four deliveries in total. Bcc works the same way, with the Bcc address hidden. Separate personalized emails are generated only when the template uses contact attributes. Ordinary emails keep standard addressing behavior. The same rule applies to each message in the batch API.

An existing contact can have an empty first or last name. Missing names render as empty strings. You control the fallback greeting in the template. For a first-name greeting, use Hello {{ bird.contact.first_name | default: "there" }}!. For a full name, combine both parts, trim whitespace, and apply a default:

Code example
{% assign full_name = bird.contact.first_name | append: " " | append: bird.contact.last_name | strip %}
Hello {{ full_name | default: "there" }}!

This renders Hello Jane Doe!, Hello Jane!, or Hello Doe! when the corresponding names are present, and Hello there! when both are missing. No workspace-wide replacement names are needed.

Custom contact properties keep their configured fallback values. A stored null counts as absent. An explicit empty string, false, or zero remains a value. An absent property without a fallback renders as empty. Unknown properties and invalid stored values reject acceptance. A failed lookup is retryable and does not substitute fallbacks.

A bird.contact.* placeholder must reference a built-in attribute or a registered custom property. Caller parameter names remain separate from those platform paths. Individual and batch template sends (including scheduled sends) save recipient values at acceptance and reuse them for delivery retries and message reads. Broadcasts keep separate preparation timing. Individual and batch sends reject sensitive inputs before acceptance.

Archiving a property removes it from the editor's property picker. New template versions that reference the archived property cannot be published. The error identifies the archived property. Already-published templates continue sending. Unarchive the property to use it in new versions again.

Placeholders use Liquid. Filters and control flow work alongside plain substitution. Both {% if %} conditionals and {% for %} loops over arrays work. Publishing rejects these unsupported constructs and specifies what to change:

  • Partial includes, using {% include %} or {% render %}. To share a section such as a footer across templates, link a reusable block instead.
  • The increment, decrement, and ifchanged tags.
  • The money, format_date, format_time, json, inspect, and type filters.
  • Comparing against empty or blank. Use .size == 0 instead.
  • Blocks nested far deeper than real email markup needs.

Broadcast template parameters accept scalar values. Arrays and objects are unsupported. Without caller parameters, both {% for %} and {% tablerow %} support literal ranges such as (1..3) and lists created inside Liquid with split. A broadcast that uses caller parameters supports {% for %} over a split list but rejects ranges and {% tablerow %}. In either case, a loop tag that reads a caller parameter or contact property directly is rejected, including a range whose endpoint reads either type of value.

Every template uses Liquid, including templates that contain only {{ variable }} placeholders. Before publishing, we validate the subject, preview text, HTML, and plain-text content as Liquid. We also add the escape filter to each HTML output that does not already end with escape or escape_once so values containing & or < cannot alter surrounding markup. The reserved unsubscribe output stays unchanged so sending can replace it. The subject line and plain-text body stay as written. Because publishing adds these filters, the HTML you read from a published version may not be byte-identical to what you submitted.

Put a complete URL directly in an href, such as <a href="{{ sign_in_url }}">Sign in</a>. Do not add url_encode to the whole value. It percent-encodes https://, /, ?, and &, which stops the result from working as an absolute link. We add HTML escaping while preserving the URL structure. When a parameter supplies one URL component, encode that component explicitly: <a href="https://example.com/search?q={{ query | url_encode }}">Search</a>.

Previewing before you publish

You can render a template with sample values to inspect the exact subject line, HTML body, and plain-text body a message would deliver. Preview uses our local Liquid renderer and renders the draft by default so you can verify changes before publishing. You can also preview a published version. Preview works for workspace templates and built-in templates without sending any email.

You can also pass unsaved subject and body content directly to the preview endpoint instead of reading the saved draft. The endpoint renders that content the same way as a draft, which lets an editor show live changes as you type without saving first.

Preview resolves personalization placeholders so the output reads as finished copy instead of {{ }} tags. If you specify a contact, every bird.contact.<attribute> resolves against that contact's properties. This lets you check your wording against a real record before sending. Preview uses the same contact projection as broadcasts and produces the same rendered values as a real message.

If you omit contact, preview substitutes stand-in values: Bird for first_name, Test for last_name, bird.test@example.com for email, and each custom property's registered fallback. A referenced property without a fallback renders as its key in brackets, such as [loyalty_tier]. That format shows the value is a placeholder and identifies which property needs a fallback.

Preview reads each contact's current values. Use preview to check content you are about to send. To inspect what an earlier message actually delivered, open that message in the email log, which renders it from the values stored when the message was sent.

Pass language to render a specific language or omit it to render the template's default. The response includes the language that was rendered, which is useful when the requested language does not exist and on_missing_language fell back to a close match.

If the draft contains personalization that would fail publishing, preview returns that same error. Use preview to catch Liquid issues early.

In the dashboard's template builder, select Preview above the email to see the rendered subject line, preview text, and body. Save a new template once before you preview it. Until then, Preview stays unavailable. This works from both the visual and the code editor. The preview panel then shows Preview as, which chooses whose data fills the placeholders, Send test email, which mails the email personalized for that contact, and a field for each parameter's sample value. Sample data uses the stand-in values listed above. Turn on View as plain text to read the plain-text version the email sends with, at the Desktop or Mobile width. Select Edit to return to the editor. While you edit, hovering a variable shows the value it renders with.

Sending with a template

Set the request's template object to identify the template by either id (emt_...) or slug, but not both. Put caller variable values in template.parameters. Include language to pick a specific language or omit it to use the template's default language (unless the template requires every request to specify a language). Omit subject, html, and text because the template provides them.

Code example
{
  "from": "hello@yourdomain.com",
  "to": ["delivered@messagebird.dev"],
  "category": "transactional",
  "template": {
    "slug": "welcome-email",
    "parameters": { "first_name": "Jane" }
  }
}

A template's category acts as a default that the request's category overrides. If you omit category from the request, the email inherits the template's category. For example, a transactional template sends as transactional without repeating the field on every call. If you set category on the request, that value takes precedence. See sending with a template for the rest of the send-side contract.

Authoring outside the dashboard

The full template lifecycle is available through the API, the SDKs under email.templates, the bird CLI, and the email_templates_* MCP tools. In the SDKs, version and language operations live under email.templates.versions and email.templates.versions.languages. Publishing is called submit in those interfaces. It converts the draft into the next published version.

You can store templates in your repository and sync them from a build step. A draft and a published version return different HTML. Choose the endpoint that matches what your tooling needs:

  • A draft returns the exact HTML you saved. The HTML you save to a draft language comes back byte-for-byte from GET /v1/email/templates/{id}/versions/{draft_version_id}/languages/{language} and from the version endpoint, including the doctype, <style> blocks, comments, whitespace, line endings, and non-ASCII text. Saving does not return the body content. Fetch the language back when you need to confirm what was stored.
  • A published version returns send-ready HTML. Publishing transforms the HTML in three ways. First, each {{ }} output that does not already end with escape or escape_once gets the escape filter, except {{ bird.unsubscribe_url }}, which stays as written. Second, preview text is inserted as a hidden block right after the opening <body> tag (or at the start if there is no <body> tag). Third, an empty text field is populated with a plain-text alternative generated from the HTML. Reading a published version returns this rewritten content, which differs from your source file.

To export the source you authored, read the draft. Reading a template or listing templates returns metadata and per-language state without HTML.

A language that links reusable blocks is an exception. By default, reading that language expands each link into the block's current published content. Because that expanded HTML differs from what you saved, saving it back is rejected. Copying it into another template copies the rendered content without preserving the block links. To export or edit the source, read the language with authoring=true (--authoring in the CLI). That response returns the HTML with its block markers and the shared_blocks map. Include both when saving to keep the links intact.

The examples below use {{ first_name }}, a caller parameter supplied in template.parameters, as in "parameters": {"first_name": "Jane"}. Use {{ bird.contact.first_name }} when the template should read the recipient's workspace contact instead. Address recipients by email in both individual and batch sends. Styling saved in the published template stays part of that version. There is no runtime bird.brandkit.* namespace.

Create the template with its first language. The response includes the template id and draft_version_id, which subsequent version and language endpoints require. The example also sets preview_text, the preview text an inbox shows after the subject in its message list. Publishing inserts it into the HTML as a hidden block, which is one reason a published version returns different HTML than the draft:

const template = await bird.email.templates.create({
  slug: "welcome-email",
  category: "transactional",
  source: "html",
  languages: {
    en: {
      subject: "Welcome, {{ first_name }}",
      preview_text: "Your account is ready",
      html: "<!DOCTYPE html>\n<html>\n<body>\n<p>Hi {{ first_name }}, thanks for signing up.</p>\n</body>\n</html>\n",
    },
  },
});
console.log(template.id, template.draft_version_id);

To update a language later, save it again with bird email templates versions languages set or a PUT request to the same language path. The body is flat and accepts subject (required), preview_text, html, and text. Any omitted field is cleared. Pass the revision you last read so the API rejects the update if someone else changed that language in the meantime.

The dashboard's visual editor layout is also cleared because the API, SDKs, and CLI cannot send layout data. Saving a language built in the visual editor keeps its HTML and removes the layout. The dashboard then reopens that language in the code editor.

A language can also link reusable blocks, which are shared sections like a legal footer that insert their latest published content into every linked template. Languages with linked blocks require shared_blocks and marker comments in html. Updating the body without them is rejected. Read the language with authoring=true before saving changes.

The next steps use TEMPLATE_ID and DRAFT_VERSION_ID for the id and draft_version_id returned by the create call. Read the draft language back to get the HTML exactly as it is stored:

const language = await bird.email.templates.versions.languages.get(
  "TEMPLATE_ID",
  "DRAFT_VERSION_ID",
  "en",
);
console.log(language.content?.html);

jq -j writes the string without adding a trailing newline so the file holds the exact bytes the API stored.

Submit the draft with validate_only first. That call runs all publish checks across every language and reports any problems in one response without publishing. Next, submit without validate_only to publish the next version as the active version for sending:

const templateId = "TEMPLATE_ID";
const draftVersionId = "DRAFT_VERSION_ID";
const check = await bird.email.templates.versions.submit(templateId, draftVersionId, {
  validate_only: true,
});
for (const problem of check.errors) {
  console.log(problem.language, problem.field, problem.message);
}
if (check.valid) {
  const result = await bird.email.templates.versions.submit(templateId, draftVersionId);
  console.log(result.version?.version_number);
}

The submit body accepts validate_only and expected_revision. Pass the template's revision as expected_revision so publishing is rejected if the draft changed since you last read it.

List your workspace's templates to find the slug to use when sending:

for await (const tpl of bird.email.templates.list({ scope: "workspace" })) {
  console.log(tpl.slug, tpl.name);
}

Send the published template by slug and pass a value in template.parameters for each parameter it uses (here, first_name):

const msg = await bird.email.send({
  from: { email: "onboarding@messagebird.dev", name: "Bird" },
  to: ["delivered@messagebird.dev"],
  category: "transactional",
  template: {
    slug: "welcome-email",
    parameters: { first_name: "Jane" },
  },
});
console.log(msg.id, msg.status);

Next steps

  • Sending email: the full send payload and how templated sends fit into it
  • Categories: choosing marketing vs transactional on each message
  • Reusable email blocks: sharing one section, such as a legal footer, across templates
  • bird email templates: managing templates from the terminal
  • API reference: full request and response schemas for all eighteen template operations
  • SDKs: the typed email.templates methods in TypeScript, Python, PHP, and Go
  • MCP server: letting an agent author and publish templates
  • How to build an email template: a video walkthrough of building a template in the dashboard and having an agent build another

Continue with the documentation, guides and examples for this topic.