# Email content

Write emails as HTML, markdown or a template, and personalize them with merge tags.

Every email (a campaign step, a broadcast, a template, a transactional or test email) has a subject, an optional preview text and a body.

## Three ways to send the body

Send exactly one of these, and set the others to `null`:

- **html**: a full HTML document or a fragment. A fragment is wrapped in a simple, readable layout.
- **markdown**: turned into HTML when you save it.
- **template_id**: copies a template’s subject, preview text and body. Set `subject`, `preview_text`, `html` and `markdown` to `null`. Later edits to the template do not change emails made from it.

Sendocado stores HTML. Every response gives the `html`, a plain-text version in `text`, and the merge tags it found in `merge_tags`.

## Merge tags

Write `{{ key }}`, or `{{ key | fallback }}` to use a fallback when the value is empty.

| Tag | Value |
| --- | --- |
| `{{ first_name }}`, `{{ last_name }}`, `{{ email }}` | From the contact |
| `{{ attributes.<key> }}` | A contact attribute, like `{{ attributes.plan }}` |
| `{{ variables.<key> }}` | A variable you pass with a transactional email |

Values are escaped in HTML, so a contact’s name can never change your markup. A missing value with no fallback becomes empty.

## What Sendocado adds

You never write these; content cannot remove them:

- Link tracking: links are sent through Sendocado so clicks count, then go straight to your link.
- An open pixel on marketing and transactional email.
- On campaigns and broadcasts: an unsubscribe link, the one-click unsubscribe header, and your project’s postal address.
- On the Free plan: a small “Sent with Sendocado” link.

Test emails are never tracked.

## Limits

- Subject: up to 998 characters.
- Preview text: up to 300 characters.
- Body: up to 512 KB of HTML.

## Images

Upload images to Sendocado and use the returned `url` in your HTML. See the [Images reference](https://sendocado.com/docs/api/images).
