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

# Create Email Template

> Create an email template with your API key: describe the email, Minimo writes it and saves it with a subject

```
POST https://api.minimo.it/public/v1/ai/transactional-templates
```

**Permission:** `Transactional`. Keep the key on your server.

You describe the email in plain words. Minimo writes it and saves it as a template of your workspace, with a subject.
The answer gives you its `uid`: use it to send, as a master in `masterTemplateIds`, and in your rules.

The call can take several seconds, because Minimo writes the email.

### Body

| Field | Type | Required | Description |
| - | - | - | - |
| `description` | string | yes | What the email is about, in plain words. 3 to 50,000 characters. |
| `name` | string | no | Name of the template, up to 200 characters. Without it, Minimo picks one. |
| `subject` | string | no | The subject the guest sees, up to 200 characters. Saved as you write it (spaces at the ends are removed). Merge fields such as `{GUEST_NAME}` work here too. Without it, Minimo writes one. If it cannot, the template name becomes the subject. |
| `category` | string | no | `utility` for service emails (confirmation, reminder, cancellation): sent even without marketing consent. `marketing` for offers and review requests: sent only to contacts who agreed. Without it, Minimo decides from the description, and a service email is `utility`. |
| `customFields` | string\[] | no | Merge fields to use in the text, for example `["GUEST_NAME", "BOOKING_TIME"]`. They appear as `{GUEST_NAME}`. Up to 50, each up to 100 characters. You pass the same keys as `customFields` when you send. |
| `brandingKit` | object | no | Colors and font: `text`, `background`, `accent` (hex or rgba) and `fontFamily`, all four required; `background2` optional. Without it, your workspace's defaults are used. |

```bash theme={null}
curl -X POST https://api.minimo.it/public/v1/ai/transactional-templates \
  -H "Authorization: Bearer YOUR_MINIMO_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Booking confirmation for a restaurant guest: date, time and party size, with a friendly tone",
    "name": "Booking confirmation (en)",
    "subject": "Your table is booked",
    "category": "utility",
    "customFields": ["GUEST_NAME", "BOOKING_TIME", "PARTY_SIZE"]
  }'
```

### Response

HTTP `201`:

```json theme={null}
{
  "data": {
    "id": 1234,
    "uid": "TRF4MS9",
    "name": "Booking confirmation (en)",
    "subject": "Your table is booked",
    "category": "utility",
    "customFields": ["GUEST_NAME", "BOOKING_TIME", "PARTY_SIZE"],
    "editorUrl": "https://app.minimo.it/templates/email/TRF4MS9/edit"
  }
}
```

| Field | Description |
| - | - |
| `uid` | The template's 7-character code (the UID column in **Templates**). Send it as `transactional`. |
| `id` | The numeric id. `masterTemplateIds` and rules accept it too. To send, use `uid`. |
| `subject` | The subject it was saved with. Never empty. |
| `editorUrl` | Opens the template in the Minimo editor, to change the text, the design or the subject. |

### Use it

* **Send it:** `POST /public/v1/transactionals` with `"transactional": "<uid>"`. See [Send Email Template](https://docs.minimo.it/api-reference/messaging-channels/email/send-template.md).
* **As a master for your restaurants:** put the `uid` in `masterTemplateIds` of `PUT /public/v1/widgets/settings`, then in your [rules](https://docs.minimo.it/guides/embedded-automations.md). A review request must be `marketing`: a `utility` template that reads like a promotion is refused as a master (`422 MASTER_LOOKS_PROMOTIONAL`).

### Dashboard or API

| | Dashboard | API |
| - | - | - |
| Who writes the email | You, in the editor | Minimo, from your `description` |
| Subject | You type it | Yours, or written by Minimo |
| Extra API key | The first save creates a key `Template — send from code` | None |
| Change it later | In the editor | In the editor (`editorUrl`) |

### Errors

| Answer | Cause |
| - | - |
| `400 INVALID_PARAMETERS` | A field is missing or too long; read `userMessage`. |
| `401 INVALID_TOKEN` | Wrong key, or the key does not have the **Transactional** permission. |
| `503` | Writing the email failed. Nothing is saved. Try again. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.