# Email templates (/docs/guides/email-templates)



An email template is a subject and an HTML body with placeholders, stored once in the project and
named by the SendGrid **Send Email** node of a [connector](/docs/guides/connectors#email-templates-and-attachments).
The node supplies the data; the template supplies the design. Changing the wording of a statement
or a notice then means editing a template, not every decision that sends it.

## Create a template [#create-a-template]

Open **Email templates** in the sidebar and choose **New template**.

| Field       | What it does                                                                                             |
| ----------- | -------------------------------------------------------------------------------------------------------- |
| Name        | Up to 120 characters.                                                                                    |
| Key         | What the node names. Lowercase letters, digits and dashes, e.g. `account-statement`. Fixed once created. |
| Description | Optional note for your team.                                                                             |
| Subject     | Up to 500 characters; placeholders work here too.                                                        |
| HTML        | The body, up to 500,000 characters.                                                                      |
| Plain text  | Optional. Left empty, it is derived from the HTML.                                                       |
| Sample data | A JSON object the preview and test emails are rendered with.                                             |

The editor offers a **Format** button, suggests placeholders found in the sample data, and flags
sections that are never closed and placeholders missing from the sample data. A template whose
sections do not balance is refused on save.

## Placeholders [#placeholders]

The syntax is a small subset of Mustache. There is no code in a template: it can only reach the
data it is given.

| Syntax                  | Result                                                                                               |
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
| `{{name}}`              | Inserts a value, HTML-escaped. Dotted paths such as `{{user.name}}` work.                            |
| `{{{html}}}`            | Inserts the value as markup, as it is.                                                               |
| `{{#items}}…{{/items}}` | Repeats for each item of a list, or shows once when the value is truthy. `{{.}}` is the item itself. |
| `{{^items}}…{{/items}}` | Shows when the value is missing, false or an empty list.                                             |

## Preview and test send [#preview-and-test-send]

**Preview** renders the template with its sample data, including your unsaved edits. **Send test**
renders the **saved** template and sends it through SendGrid to an address you choose: it needs a
`from` address verified in your SendGrid account and a SendGrid credential from **Settings →
Access**. Save before sending.

## Pinned when you publish [#pinned-when-you-publish]

A decision keeps the template it was published with, like a constant. Editing or deleting a
template does not change what already published versions send; **republish** to send the change.
Publishing a decision that names a template that no longer exists fails.

## Attachments [#attachments]

Attachments are set on the node, not on the template. They can come from a URL the platform
downloads at send time, or from base64 the flow already holds; nothing is stored, and a retry
downloads the document again. Up to 10 attachments, 10 MB each and 20 MB in all. The URL goes
through the outbound guard, so a host on a private network must be listed in
`OUTBOUND_ALLOWED_HOSTS`. See [Connectors](/docs/guides/connectors#email-templates-and-attachments).

## SendGrid as the platform's email provider [#sendgrid-as-the-platforms-email-provider]

This is separate from the connector. The platform's own transactional email (verification,
password reset, invitations) is sent by Resend or SendGrid, chosen with `EMAIL_PROVIDER` or by
whichever key is set (`SENDGRID_API_KEY`), with `EMAIL_FROM` as sender. See
[Configuration](/docs/self-host/configuration).

## API [#api]

`/api/v1/email-templates`: list, create, `GET`/`PATCH`/`DELETE /:key`, `POST /:key/preview` and
`POST /:key/test-send`. See the API reference for the schemas.
