# Email templates and variables

> Email templates and variables: design a transactional email template once, publish it, and send it from your app by alias, with fallbacks and versions.

Canonical: https://www.cresca.xyz/docs/templates
Last updated: 2026-11-05

Email templates and variables let you design an email once, publish it, and send it from your app by alias with values such as a name, a link or a code.

Instead of building HTML in your code, design the email in Cresca, mark the parts your app fills in, and publish it. Your app then sends only the template alias and the values.

## How email templates and variables work

Mark a value with triple braces: `{{{RESET_LINK}}}`. Variables can appear in the HTML, the plain-text version and the subject.

- Names use letters, numbers and underscores, up to 50 characters. Upper case is the convention.
- Each variable is a `string` (up to 2,000 characters) or a `number`, and can have a fallback value used when a send leaves it out.
- A template can have up to 50 variables.
- `FIRST_NAME`, `LAST_NAME`, `EMAIL` and `UNSUBSCRIBE_URL` are reserved.

Values are HTML-escaped in the HTML body, so a name like `<b>Ana</b>` is shown as text and can never change your email's markup. In the text version values are inserted as-is, and line breaks are removed from the subject.

## Draft and published versions

Editing a template changes its draft only. Sends always use the **published** version, so you can work on a change without affecting live email. Sending a template that has never been published fails with `422 validation_error`: "This template has not been published yet. Publish it before sending." Publishing creates the next version number (1, 2, 3...). Placeholders in the draft that you have not declared are added as string variables without a fallback when you publish. Variables also work in the preview text.

## Build it in the editor

1. Open [Transactional → Templates](https://app.cresca.xyz/transactional/templates) and click **Create template**. Start blank, or choose **Import HTML** to paste or drop an existing email.
2. Choose the sender, write the subject and, if you like, a Reply-To address and preview text. The alias is how your app picks the template.
3. Write the email. Type `/` for blocks (headings, buttons, images, columns, dividers and more) and `{{` to add a variable. A button link or an image can be a variable too.
4. In the **Variables** panel, give optional values a fallback. A warning marks variables every send must include. **Styles** sets the background, link and button colours and the content width.
5. Changes save automatically (or press `Cmd/Ctrl + S`). Click **Test email** to send the draft to up to 5 addresses. Fill in the variables one by one or paste them as JSON, the same object your app sends in `template.variables`. Test emails count toward your monthly allowance.
6. Click **Publish**. Cresca checks the template (sender, subject, empty body, variables), then you slide to publish.

Every publish is kept in **Version history** (the `⋯` menu), with who published it and when. Restoring a version replaces the draft; publish it to make it live again.

You can also create and publish templates with the [Templates API](https://www.cresca.xyz/docs/api-reference/create-template).

## Send with a template

Pass the template id or alias and the variables instead of `html` and `text`:

Request

```bash
curl -X POST 'https://api.cresca.xyz/api/v1/emails' \
  -H 'Authorization: Bearer cr_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "to": "user@example.com",
  "template": {
    "id": "password-reset",
    "variables": {
      "NAME": "Ana",
      "RESET_LINK": "https://acme.com/reset?token=abc"
    }
  }
}'
```

| Field | Comes from |
| --- | --- |
| `html` | The published template, with variables filled in. |
| `text` | The template’s text version, or generated from the HTML. |
| `subject` | Your request if given, otherwise the template’s default subject. |
| `from` | Your request if given, otherwise the template’s default sender. |
| `reply_to` | Your request, else the template, else the sender’s Reply-To. |

If a variable has no value and no fallback, the email is not sent and the API returns `422 validation_error` naming the missing variables.

For a longer walkthrough with cURL, Node.js and Python examples, read the [email templates API guide](https://www.cresca.xyz/blog/email-templates-api).

[Previous Authentication](https://www.cresca.xyz/docs/authentication) [Next Idempotency](https://www.cresca.xyz/docs/idempotency)

Last updated November 5, 2026. Questions? [lalit@cresca.xyz](mailto:lalit@cresca.xyz)
