# إرسال البريد الإلكتروني

> وضع بريد إلكتروني معاملاتي في طابور التسليم.

`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.

## بارامترات الجسم

- `from` (string, required): عنوان المرسل. استخدم `Name <address>` ليكون اسماً سهلاً. يجب التحقق من النطاق.
- `to` (string | string[], required): عنوان المتلقي، أو صفيفة تصل إلى 50.
- `subject` (string, required): موضوع البريد الإلكتروني، بحد أقصى 500 حرف.
- `html` (string): جسد HTML. مطلوب ما لم يكن `text` محدد.
- `text` (string): يقدم النص، أو HTML، أو نموذج منشور.
- `cc` (string | string[]): المتلقون بصورة نسخة، يحسبون في حدود 50 متلقيا.
- `bcc` (string | string[]): المتلقون بصورة سرية، احسب نحو الحد الأقصى للمتلقين البالغ 50.
- `reply_to` (string | string[]): حيث تذهب الردود
- `tags` (object[]): ما يصل إلى عشرة أشياء تحتوي على اسم وقيمة.
- `template` (object): هوية النموذج المنشور أو اسمه المستعار ومتغيرات اختيارية.

## عناوين الصفحات

- `Idempotency-Key` (string): 256 حرفاً على الأكثر. انظر [أزرار التوافق](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"
}
```
