# Create and edit templates

> Create a template, choose the Dragit, Rich Text or HTML editor, insert variables, and manage templates from the template list and template page.

This page shows how to create a template in the dashboard or with the API, how each of the three editors works, and how to manage templates from the template list. It's for anyone who designs emails, whether you work in code or not.

## Create a template

1. **Open Templates.** Go to **Email Marketing → Templates** and select **Add template**.

2. **Name it.** Enter a **Name**, such as `Welcome email`. Emailit fills in the **Alias** from the name, for example `welcome-email`.

3. **Check the alias.** The alias is how your code and automations refer to the template. It can use lowercase letters, digits, `_` and `-`, up to 191 characters. If the alias already exists, the dialog shows **Alias already exists**, and the new template becomes an unpublished [version](/docs/templates/versions/) of the existing one.

4. **Choose an editor.** Pick **Dragit Editor** (the default), **HTML Editor** or **Rich Text Editor**. You can't switch an existing template to another editor in the dashboard, so choose the one you want to keep.

5. **Set the defaults.** Optionally enter a **Subject**, which can contain [Temple](/docs/templates/temple/) placeholders, and a **From** address such as `Acme <hello@acme.com>`. Both are defaults that a send can override.

6. **Create and design.** Select **Create**. The template opens in its editor. Design the content, then save.

To set a Reply-To address or a separate plain-text body, use the API.

### Create a template with the API

Call [Create a template](/docs/api-reference/templates/create/) with a **Full Access** key. `editor` can be `dragit`, `tiptap` (Rich Text), `html` or `text`, and defaults to `html`.

```bash
curl https://api.emailit.com/v2/templates \
  -H "Authorization: Bearer $EMAILIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome email",
    "alias": "welcome-email",
    "editor": "html",
    "from": "Acme <hello@acme.com>",
    "reply_to": "support@acme.com",
    "subject": "Welcome to Acme, {{first_name|\"there\"}}",
    "html": "<p>Hi {{first_name|\"there\"}}, thanks for joining.</p>",
    "text": "Hi {{first_name|\"there\"}}, thanks for joining."
  }'
```

The response has status `201` and the template under `data`. If the alias is new, the template is published right away.

## Choose an editor

| Editor | Best for | What you get |
| --- | --- | --- |
| **Dragit** | Designed emails with columns, images and buttons, built without code | Drag-and-drop blocks, an image manager and a variables menu. Saves HTML and the Dragit design as JSON. |
| **Rich Text** | Simple, text-first emails that look like a personal message | A word-processor toolbar, a **Variables** menu and a **Preview text** field. Saves HTML. |
| **HTML** | Hand-coded or imported HTML, full control over markup | A code editor with line numbers and a live desktop and mobile preview. Saves your HTML as written. |

### Dragit editor

Dragit is a drag-and-drop email builder that opens full screen.

- Drag blocks such as text, images and buttons into the layout, and adjust their content and styles.
- Upload images with the built-in file manager. They're stored in your workspace and served from a hosted URL.
- Insert variables from the merge fields menu: **First name**, **Last name**, **Email**, and your contact [custom fields](/docs/contacts/custom-fields/) under **Custom fields**. The unsubscribe link is available as a special link type.
- Your work is saved automatically as you edit. Close the editor to go back to the template page.

Dragit templates keep their design as Dragit JSON as well as HTML, so you can export the JSON and import it into another workspace. See [Import and export](/docs/templates/import-export/).

### Rich text editor

The Rich Text editor opens full screen with a formatting toolbar: undo and redo, headings 1 to 3, bulleted and numbered lists, block quotes, bold, italic, underline, strikethrough, links and text alignment.

- Select the **Variables** button (the `@` icon) in the toolbar to insert a variable at the cursor.
- Enter **Preview text** at the top to set the line that inboxes show after the subject. Emailit adds it as hidden text at the start of the email.
- Select **Save** to keep your changes. On save, Emailit applies a sans-serif font to every element so the email looks consistent across mail clients.

### HTML editor

The HTML editor shows your code, with line numbers and syntax highlighting, together with a live preview. Switch the preview between **Desktop** and **Mobile**. Below the preview, **Available variables** lists the placeholders you can type into your HTML. Select **Save** to keep your changes.

The preview shows placeholders as written. It doesn't render Temple conditionals or fill in values.

## Variables in the editors

All three editors offer the same variables:

| Variable | Placeholder |
| --- | --- |
| First name | `{{first_name}}` |
| Last name | `{{last_name}}` |
| Email | `{{email}}` |
| Unsubscribe URL | `{{unsubscribe_url}}` |
| A contact custom field | `{{cf.<key>}}`, for example `{{cf.plan}}` |

Who fills them in depends on how the template is sent:

- **Campaigns** fill all of them from the recipient's contact record, and `{{unsubscribe_url}}` with their unsubscribe link. See [Campaign merge tags](/docs/campaigns/merge-tags/).
- **API sends** fill only what you pass in `variables`, using the same names. For `{{cf.plan}}`, pass `"variables": { "cf": { "plan": "Pro" } }`. Anything you don't pass is left empty.
- **Contact automations** fill `{{first_name}}`, `{{last_name}}` and `{{email}}` from the contact. Custom fields are available as `{{custom_fields.<key>}}`, and `{{unsubscribe_url}}` isn't filled.

See [Temple](/docs/templates/temple/) for the full rules.

## Manage templates

**Email Marketing → Templates** shows one card per alias, with a preview, the name, the alias, an editor badge and the number of versions. Only the published version of each alias appears in the grid. Find drafts in the **Versions** panel of the template page.

- **Search** by name or alias.
- **Sort** by **Newest first**, **Oldest first**, **Recently updated**, **Recently published**, **Name A-Z** or **Name Z-A**.
- **Filter** by editor.
- Select **Import** to add a template from a file. See [Import and export](/docs/templates/import-export/).

Each card's menu has these actions:

| Action | What it does |
| --- | --- |
| **View** | Opens the template page. |
| **Open Editor** | Opens the template in its editor. |
| **Duplicate Template** | Creates a copy with a new name and alias. See [Duplicate a template](/docs/templates/import-export/#duplicate-a-template). |
| **Export Dragit JSON** | Downloads the Dragit design. Shown only for Dragit templates. |
| **Export HTML** | Downloads the HTML. |
| **Export ZIP** | Downloads a package with the HTML, the Dragit JSON and the images. |
| **Delete** | Deletes this version permanently. |

### The template page

Select a card to open its template page. It shows the status (**Published** or **Draft**), alias, editor, creation date, name, subject, From, Reply-To and ID, a preview, and the **Versions** panel.

- **Publish** appears on draft versions and makes this version the live one for the alias.
- **Open Editor** opens the content in the template's editor.
- The menu has **Edit** (change the name, alias, subject and From), **Duplicate Template**, the export options and **Delete**.
- **New Version** in the **Versions** panel copies an existing version into a new draft. See [Template versions](/docs/templates/versions/).

## Related

- [Template versions](/docs/templates/versions/)
- [Temple template language](/docs/templates/temple/)
- [Templates API reference](/docs/api-reference/templates/)
- [Custom fields](/docs/contacts/custom-fields/)

---
Source: https://emailit.com/docs/templates/editors/
