# Send a transactional email (one message per recipient)

`POST /mail/send` · Rivier · campaigns

Send a transactional email (one message per recipient). Use an Idempotency-Key (header or idempotencyKey) so a retry sends once; sandbox: true checks and renders without sending. Refuses suppressed addresses with a structured error. Mail goes out through the project's chosen transport once consent, quiet rules, test mode and the plan's limit allow it.

- Scope: campaigns:write
- Mcp: rivier_campaign_mail_send
- Graphql: Mutation.campaignsMailSendCreate
- Sdk: mail.send
- Cli: mail send
- Events: campaigns.mail.queued

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "to": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 3,
          "maxLength": 320
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 3,
            "maxLength": 320
          },
          "minItems": 1,
          "maxItems": 500
        }
      ],
      "description": "One address, or a list: each gets a message of its own (nobody sees the others)"
    },
    "from": {
      "type": "string",
      "minLength": 3,
      "maxLength": 320,
      "description": "Defaults to the project's sending address; must be on its sending domain"
    },
    "fromName": {
      "type": "string",
      "maxLength": 120
    },
    "replyTo": {
      "type": "string",
      "minLength": 3,
      "maxLength": 320
    },
    "subject": {
      "type": "string",
      "maxLength": 998,
      "description": "Required unless the template has one. May use {{variables}}"
    },
    "html": {
      "type": "string",
      "maxLength": 1000000
    },
    "text": {
      "type": "string",
      "maxLength": 1000000,
      "description": "Defaults to the html as plain text"
    },
    "template": {
      "type": "string",
      "maxLength": 120,
      "description": "A template name or id from the template library"
    },
    "data": {
      "type": "object",
      "additionalProperties": {},
      "description": "Values the template or the message reads: {{name}}, {{#if plan == \"pro\"}}, {{#each items}}"
    },
    "group": {
      "type": "string",
      "maxLength": 40,
      "description": "Unsubscribe group; adds the unsubscribe link and one-click header, and honours the person's choice"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 40
      },
      "maxItems": 10
    },
    "headers": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "maxLength": 998
      },
      "description": "Extra headers (X-...); headers the platform sets are refused"
    },
    "sendAt": {
      "type": "string",
      "maxLength": 40,
      "description": "ISO 8601 time, at most 30 days ahead; default now"
    },
    "trackOpens": {
      "type": "boolean"
    },
    "trackClicks": {
      "type": "boolean"
    },
    "sandbox": {
      "type": "boolean",
      "description": "Validate and render, report what would happen, send and store nothing"
    },
    "idempotencyKey": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Same as the Idempotency-Key header: the same key twice sends once"
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "The name the recipient sees, such as invite.ics"
          },
          "contentType": {
            "type": "string",
            "maxLength": 120,
            "description": "Defaults from the file name; text/calendar for an invitation"
          },
          "content": {
            "type": "string",
            "minLength": 1,
            "maxLength": 7000000,
            "description": "The file's bytes in base64"
          }
        },
        "required": [
          "filename",
          "content"
        ],
        "additionalProperties": false
      },
      "maxItems": 10,
      "description": "Up to 10 files, 5 MB together; programs and scripts are refused"
    }
  },
  "required": [
    "to"
  ],
  "additionalProperties": false
}
```

## Responses

- `202`: 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/send' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "to": "string"
}'
```
