# أرسل رسالتك الأولى

> أنشئ مفتاح إرسال واستدعِ POST /emails. تعيد الواجهة معرّفًا عند إدراج الرسالة في قائمة الانتظار.

كل بريد إلكتروني يبدأ كطلب واحد `POST /emails`. Sendtern يصدق عليه، ويعيد `200 OK` مع هويته، ويسلم في الخلفية.

## ألف - تشريح الطلب

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())
```

## المرسل

`from` يقبل عنوانا خاليا أو `Name <address>`. [تحقق من نطاق المرسل بالضبط](https://sendtern.com/docs/domains) قبل الإرسال.

## المستفيدون

- `to` يأخذ سلسلة أو صفيفة، حتى 50 عنوانا لكل بريد إلكتروني.
- `cc` و `bcc` يعملان بنفس الطريقة ويعدان نحو 50.
- `reply_to` يحدد أين تذهب الردود، على سبيل المثال صندوق الدعم الوارد.

## المحتويات

إرسال `html`، `text`، أو كلاهما. يمكن أن يكون HTML حتى 200000 شخصية والنص البسيط حتى 100000 شخصية.

## العلامات

إرسال ما يصل إلى 10 `tags`. كل علامة تحتوي على `name` و `value`، كل واحد منها حتى 128 حرفا، رقما، شريط أو خط تحت.

## بعد الطلب

يبدأ البريد الإلكتروني ك** في الطابور** ويتحرك عبر [حالات](https://sendtern.com/docs/statuses) كما يستجيب خادم المرسل إليه. استخدم `id` المرجعة ل [استعادته](https://sendtern.com/docs/api-get-email) في أي وقت.
