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

# Transactional templates

> Write the e-mail once, and let your applications call it by name.

**Transactional → Transactional templates → New template**.

## The name

The name is what your application sends: **lower-case letters, digits and dashes**, unique within the team. Keep it short and stable (`order-confirmation`, `password-reset`).

<Warning>
  Renaming or deleting a template makes the applications that ask for the old
  name fail (a 422 error).
</Warning>

## The editing page

| Section                     | Content                                                                                                                                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Subject**                 | Takes variables: `Order {{ order.number }} confirmed`.                                                                                                                                                                                       |
| **Template**, **Editor**    | An optional layout; the HTML, Markdown or MJML editor (no blocks).                                                                                                                                                                           |
| **Content**                 | The body, with variables, conditions and loops. See [Personalisation](/content/personalization).                                                                                                                                             |
| **Sample variables (JSON)** | An example of what your application will send; it feeds the preview and the tests.                                                                                                                                                           |
| **Preview**                 | The rendering with the sample variables.                                                                                                                                                                                                     |
| **Languages**               | One version per language; the application picks one with `locale`. See [Languages](/content/languages).                                                                                                                                      |
| **Sender**                  | Address, name, reply-to. Empty: those of **Settings → General**.                                                                                                                                                                             |
| **Default recipients**      | To, Cc, Bcc: used when the call carries no recipient. Handy for an internal alert ("new order") that always goes to the same people.                                                                                                         |
| **Tracking**                | Opens and clicks.                                                                                                                                                                                                                            |
| **Keep the content**        | The log keeps the e-mail as it was sent. Untick it for sensitive e-mails (sign-in links, codes): only the envelope is left (recipients, subject, status, figures). The variables are not kept either, and such e-mails cannot be sent again. |

**Sending it from your code** shows a `curl` call ready to copy, with the template's name and the sample variables.

### An example

The content:

```html theme={null}
<p>Hello {{ customer.name }},</p>
<p>Your order <strong>{{ order.number }}</strong> is confirmed.</p>
<ul>
    {% for line in order.lines %}
    <li>{{ line }}</li>
    {% endfor %}
</ul>
{% if order.pickup %}
<p>Ready to collect in the shop from {{ order.pickup }}.</p>
{% endif %}
```

The sample variables:

```json theme={null}
{
    "customer": { "name": "Ada" },
    "order": {
        "number": "A-1024",
        "lines": ["Sourdough bread", "Brioche"],
        "pickup": "Saturday 10:00"
    }
}
```

## Send a test

**Send a test**: e-mail addresses. The test goes out with the sample variables, through the transactional provider, and appears in the log.

## The template's figures

At the top of the page: **Sent**, **Failed**, **Opens**, **Clicks** for this template. A template with no content is marked **Unfinished** in the list.
