# Create an email template

`POST /mail/templates` · Rivier · campaigns

Create an email template. Variables {{name}} and {{name|fallback}}, conditionals {{#if}} {{else}}, loops {{#each}} and partials {{> name}}; values are escaped for HTML.

- Scope: campaigns:write
- Graphql: Mutation.campaignsMailTemplateCreate
- Sdk: mail.templates.create
- Cli: mail template-create

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "kind": {
      "type": "string",
      "enum": [
        "transactional",
        "marketing",
        "partial"
      ]
    },
    "language": {
      "type": "string",
      "maxLength": 20,
      "description": "en, dv, ar, ...; sets the direction and footer words of group mail"
    },
    "subject": {
      "type": "string",
      "maxLength": 998
    },
    "html": {
      "type": "string",
      "maxLength": 1000000
    },
    "text": {
      "type": "string",
      "maxLength": 1000000
    },
    "testData": {
      "type": "object",
      "additionalProperties": {},
      "description": "Sample values used by the preview"
    },
    "note": {
      "type": "string",
      "maxLength": 200
    },
    "share": {
      "type": "string",
      "enum": [
        "project",
        "organization"
      ],
      "description": "organization: every project of the organization can use it"
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/mail/templates' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string"
}'
```
