# Campaigns mail preview create

`POST /mail/templates/preview` · Rivier · campaigns

Render a template (or inline content) with data exactly as a send would, and list the variables it asked for that the data did not carry. Sends and stores nothing.

- Scope: campaigns:read
- Mcp: rivier_campaign_mail_preview
- Graphql: Query.campaignsMailPreviewCreate
- Sdk: mail.preview
- Cli: mail preview

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "template": {
      "type": "string",
      "maxLength": 120,
      "description": "A saved template (name or id)"
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "subject": {
      "type": "string",
      "maxLength": 998
    },
    "html": {
      "type": "string",
      "maxLength": 1000000
    },
    "text": {
      "type": "string",
      "maxLength": 1000000
    },
    "data": {
      "type": "object",
      "additionalProperties": {},
      "description": "Defaults to the template's test data"
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: 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/preview' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "template": "string",
  "version": 0,
  "subject": "string",
  "html": "string",
  "text": "string",
  "data": {}
}'
```
