> For the complete documentation index, see [llms.txt](https://docs.mailofly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailofly.com/guides/campaigns-and-content/templates.md).

# 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.

{% hint style="info" %}
**Mailofly AI** (Basic plan+) can draft template content from a prompt inside the builder.
{% endhint %}

***

## 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
curl -sS -X POST "https://www.mailofly.com/api/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](/guides/campaigns-and-content/compose.md) — one-off sends with a template
* [Campaigns](/guides/campaigns-and-content/campaigns.md) — attach template to a blast
* [Contacts](/guides/campaigns-and-content/contacts.md) — fields that power merge tags


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mailofly.com/guides/campaigns-and-content/templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
