Creating HTML Email Templates

Creating HTML Email Templates

This guide walks you through creating and managing HTML email templates using the Bird API. By the end, you'll have a fully functional email template ready to send.

Overview

Creating an HTML email template involves the following steps:

  1. Create a project – Set up an HTML email project to hold your templates

  2. Create a template – Initialize a new template with basic settings

  3. Add content – Upload your HTML and define variables

  4. Activate the template – Make it available for sending

Let's walk through each step.


Step 1: Create a project

Before you can create templates, you need an HTML email project to store them. Projects act as containers that organize your templates and define their type.

Request

POST /workspaces/{workspaceId}/projects

To create a basic HTML email project:

Response

Save the id from the response – this is your projectId for the next steps.

Adding optional fields

You can include additional fields when creating the project:

Field
Required
Description

name

No

Project name (max 100 characters)

description

No

Project description (max 300 characters)

type

Yes

Must be htmlEmail for email templates

suites

No

Categorization: marketing, service, payments, automations, developer

Alternative: Create project with initial template

You can also create a project and its first template in a single request:

This approach saves an API call when you know you'll need a template immediately.


Step 2: Create a template

Once you have a project, you can create templates within it. Each project can contain multiple templates.

Request

For a simple HTML template, you only need to specify the editor type and default locale:

Response

The template is created in draft status. Save the id from the response – you'll need it for the next steps.

Adding optional fields

You can include additional fields when creating the template:

Field
Required
Description

editor

Yes

Set to html for raw HTML templates

defaultLocale

Yes

Default language code (e.g., en, de, fr)

description

No

A description to help identify the template

useCase

No

Classification: transactional, marketing, marketingCustomUnsubscribe, or other

The useCase field affects compliance requirements. Marketing emails require an unsubscribe link, while transactional emails do not.


Step 3: Add content

Now that you have a template, you need to add the actual email content. Content is stored per locale, so you can have different versions for different languages.

Request

Replace {templateId} with the ID from Step 2, and {locale} with the language code (e.g., en).

Here's a basic example with a subject line and HTML body:

Using variables

To personalize your emails, use variables with the {{variableName}} syntax. Define each variable with a description and example value:

The description helps team members understand each variable's purpose. The example value is used when previewing the template.

Adding attachments

To include file attachments with your email, use the attachments field:

Each attachment requires:

  • url – The URL where the file is hosted

  • filename – The name shown to recipients

Mapping image assets

If your HTML references images, use assetRefs to map local references to CDN URLs:

Complete content example

Here's a full example combining all content options:


Step 4: Activate the template

Once your content is ready, activate the template to make it available for sending emails.

Request

No request body is required.

Response

The template status changes from draft to active. You can now use this template to send emails.


Adding multiple languages

Templates support multiple locales. After creating content for your default language, you can add additional languages by calling the content endpoint with different locale codes.

Add German content

Common locale codes: en, en-US, en-GB, de, de-DE, fr, fr-FR, es, es-ES, it, nl, pt, pt-BR, ja, zh, ko.


Verifying your template

After activation, you can verify your template was created correctly.

Get template details

This returns the template metadata and content summaries for all locales.

Get template content (with HTML)

To retrieve the full content for a specific locale, including the actual HTML, use the content endpoint:

The plainHtml field contains the complete HTML content of the template. This is useful for migrating templates between workspaces, backing up template content, and programmatically editing templates.

Preview the template

To see how the template renders with example values:

This returns the rendered HTML with variables replaced by their example values.


Migrating templates between workspaces

To move a template from one workspace to another (e.g., sandbox to production), follow these steps:

  1. Retrieve the source template content – Call the GET content endpoint and save the response, particularly the plainHtml, subject, variables, and attachments fields.

  2. Create a project in the target workspace – Use the POST projects endpoint.

  3. Create a template in the new project – Use the POST html-emails endpoint.

  4. Add the content to the new template – Use the PATCH content endpoint with the data from step 1.

  5. Activate the template – Use the POST activate endpoint.


Managing templates

List all templates

Returns all templates in the project.

Update template metadata

To change the description or use case without modifying content:

Deactivate a template

To temporarily disable a template:

The status changes to inactive. You can reactivate it later using the activate endpoint.

Clone a template

To copy a template to the same or different project:

Omit toProjectId to clone within the same project.

Delete content for a locale

To remove a specific language version:


Template status reference

Status
Description

draft

Template is being edited and cannot be used for sending

active

Template is live and available for sending emails

inactive

Template has been deactivated

pending

Template is being processed

pendingReview

Template is awaiting review


Next steps

For a complete list of endpoints and parameters, see the API Reference.

Last updated

Was this helpful?