> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

# Email templates

Templates store reusable **subject** and **HTML body** content. Campaigns and Compose both reference templates so you design once and send many times.

**In the app:** [Templates](https://www.mailofly.com/user/templates)

***

## Visual builder

Mailofly includes a drag-and-drop email builder:

| Action           | Path                              |
| ---------------- | --------------------------------- |
| Browse templates | `/{org}/templates`                |
| Create new       | **New template** → visual builder |
| Edit existing    | Click card → **Edit**             |

The builder saves both rendered **HTML** (`body`) and the builder document (`body_json`) so you can re-open and edit visually.

<Info>
  **Mailofly AI** (Basic plan+) can draft template content from a prompt inside the builder.
</Info>

***

## Merge tags

Insert placeholders that resolve per recipient at send time:

```
Hi {{ first_name }},

Your order ships on {{ iso_date }}.

Use code {{ promo_code }} for 20% off.

<a href="{{ unsubscribe_url }}">Unsubscribe</a>
```

### Built-in contact fields

| Tag                    | Source             |
| ---------------------- | ------------------ |
| `{{ email }}`          | Contact email      |
| `{{ first_name }}`     | Contact first name |
| `{{ last_name }}`      | Contact last name  |
| `{{ name }}`           | Full name          |
| `{{ phone }}`          | Phone number       |
| `{{ custom.company }}` | Custom field       |

### Date & time (computed at send)

| Tag              | Example output |
| ---------------- | -------------- |
| `{{ date }}`     | March 4, 2026  |
| `{{ iso_date }}` | 2026-03-04     |
| `{{ weekday }}`  | Tuesday        |
| `{{ year }}`     | 2026           |

### Custom placeholders

Any tag not in the built-in list (e.g. `{{ promo_code }}`) is a **custom variable**. Provide values at send time:

* **Compose dialog** — prompted before send
* **API** — pass in the `variables` object

***

## Template readiness

A template needs both **subject** and **body** before campaigns treat it as ready. Draft templates (missing subject) appear filtered separately in the gallery.

***

## Use in campaigns vs compose

|                 | Campaign                    | Compose                          |
| --------------- | --------------------------- | -------------------------------- |
| Template picker | Attach at campaign creation | Load in compose dialog           |
| Recipients      | Whole segment               | Manual emails or picked contacts |
| Repeatable      | ✓ with scheduling           | One-off                          |

***

## API

```bash theme={null}
curl -sS -X POST "https://api.mailofly.com/v1/templates" \
  -H "Authorization: Bearer mf_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome email",
    "subject": "Welcome, {{ first_name }}!",
    "body": "<h1>Hello {{ first_name }}</h1><p>Glad you joined.</p>"
  }'
```

Full reference: [API: Templates](https://docs.mailofly.com/api/templates)

***

## Related

* [Compose](compose.md) — one-off sends with a template
* [Campaigns](campaigns.md) — attach template to a blast
* [Contacts](contacts.md) — fields that power merge tags


## Related topics

- [Index](/changelog/index.md)
- [Email types](/getting-started/email-types.md)
- [Create Template](/templates/create-template.md)
- [Delete Template](/api/templates/delete-template.md)
- [Retrieve Template](/api/templates/get-template.md)
