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

# POST Create a template

> Create a text or media template. Variables are recalculated automatically.

## Endpoint

```txt theme={null}
POST /api/v1/templates
```

## Body

| Field      | Type   | Required              | Description                                   |
| ---------- | ------ | --------------------- | --------------------------------------------- |
| `name`     | string | yes                   | Name of the template                          |
| `type`     | enum   | yes                   | `text`, `image`, `video`, `audio`, `document` |
| `body`     | string | yes if `type=text`    | Contenu avec placeholders                     |
| `mediaUrl` | string | yes si template media | Public media URL                              |

## Success response `201`

```json theme={null}
{
  "data": {
    "id": "tmpl_uuid",
    "name": "Relance panier",
    "type": "text",
    "body": "Hello {{contact.firstName}}",
    "mediaUrl": null,
    "variables": ["contact.firstName"]
  }
}
```

## Common errors

| HTTP  | Code               | When                |
| ----- | ------------------ | ------------------- |
| `400` | `VALIDATION_ERROR` | Invalid body        |
| `400` | `TEMPLATE_INVALID` | Placeholder invalid |
