# Envoyer un email

> Mettre en file d'attente un e-mail transactionnel pour la livraison.

`POST /emails`

Accepts the email and returns HTTP 200 with its ID. Delivery happens asynchronously; follow it with [Retrieve email](https://sendtern.com/docs/api-get-email). Send an `Idempotency-Key` header to retry safely.

## Paramètres du corps

- `from` (string, required): Adresse de l'expéditeur. Utilisez `Name <address>` pour un nom convivial. Le domaine doit être vérifié.
- `to` (string | string[], required): Adresse du destinataire, ou un tableau de jusqu'à 50.
- `subject` (string, required): Objet de l'e-mail, jusqu'à 500 caractères.
- `html` (string): Corps HTML. Obligatoire à moins que `text` ne soit défini.
- `text` (string): Corps en texte brut. Fournissez du texte, du HTML ou un modèle publié.
- `cc` (string | string[]): Comptez pour atteindre la limite de 50 destinataires.
- `bcc` (string | string[]): Comptez pour atteindre la limite de 50 destinataires.
- `reply_to` (string | string[]): Où vont les réponses.
- `tags` (object[]): Jusqu'à dix objets contenant un nom et une valeur.
- `template` (object): Un ID ou alias de modèle publié et des variables facultatives.

## En-têtes

- `Idempotency-Key` (string): Jusqu’à 256 caractères. Voir [Touches d’identification](https://sendtern.com/docs/idempotency).

## Example

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.acme.io>",
  "to": [
    "ada@example.com"
  ],
  "subject": "Your sign-in code",
  "html": "<p>482 913</p>",
  "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.acme.io>",
    "to": [
      "ada@example.com"
    ],
    "subject": "Your sign-in code",
    "html": "<p>482 913</p>",
    "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.acme.io>",
      "to": [
        "ada@example.com"
      ],
      "subject": "Your sign-in code",
      "html": "<p>482 913</p>",
      "tags": [
        {
          "name": "category",
          "value": "auth"
        }
      ]
    },
)

print(res.json())
```

## Response

```json
{
  "id": "47be30ca-24b7-48fb-b35d-ff287b89e66d"
}
```
