# Sending emails

> Everything a send request can carry, and what happens after.

Every email starts as one `POST /emails` request. Sendtern validates it, returns `200 OK` with its ID, and delivers in the background.

## Anatomy of a request

cURL:

```
curl -X POST 'https://sendtern.com/emails' \
  -H 'Authorization: Bearer st_your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{
  "from": "Acme <hello@mail.example.com>",
  "to": [
    "ada@example.com"
  ],
  "reply_to": "support@example.com",
  "subject": "Your sign-in code",
  "html": "<p>Your code is <strong>482 913</strong></p>",
  "text": "Your code is 482 913",
  "tags": [
    {
      "name": "category",
      "value": "auth"
    }
  ]
}'
```

Node.js:

```
const res = await fetch("https://sendtern.com/emails", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SENDTERN_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "from": "Acme <hello@mail.example.com>",
    "to": [
      "ada@example.com"
    ],
    "reply_to": "support@example.com",
    "subject": "Your sign-in code",
    "html": "<p>Your code is <strong>482 913</strong></p>",
    "text": "Your code is 482 913",
    "tags": [
      {
        "name": "category",
        "value": "auth"
      }
    ]
  }),
});

const data = await res.json();
```

Python:

```
import os
import requests

res = requests.post(
    "https://sendtern.com/emails",
    headers={"Authorization": f"Bearer {os.environ['SENDTERN_API_KEY']}"},
    json={
      "from": "Acme <hello@mail.example.com>",
      "to": [
        "ada@example.com"
      ],
      "reply_to": "support@example.com",
      "subject": "Your sign-in code",
      "html": "<p>Your code is <strong>482 913</strong></p>",
      "text": "Your code is 482 913",
      "tags": [
        {
          "name": "category",
          "value": "auth"
        }
      ]
    },
)

print(res.json())
```

## Sender

`from` accepts a bare address or `Name <address>`. [Verify the exact sender domain](https://sendtern.com/docs/domains) before sending.

## Recipients

- `to` takes a string or an array, up to 50 addresses per email.
- `cc` and `bcc` work the same way and count toward the 50.
- `reply_to` sets where replies go, for example your support inbox.

## Content

Send `html`, `text`, or both. HTML can have up to 200,000 characters and plain text up to 100,000 characters.

## Tags

Send up to 10 `tags`. Each tag has a `name` and a `value`, each up to 128 letters, digits, hyphens or underscores.

## After the request

The email starts as **queued** and moves through the [statuses](https://sendtern.com/docs/statuses) as the recipient's server responds. Use the returned `id` to [retrieve it](https://sendtern.com/docs/api-get-email) at any time.
