# 첫 이메일 보내기

> 발송 키를 만든 후 POST /emails를 호출하세요. 메시지가 대기열에 들어가면 API가 ID를 반환합니다.

모든 이메일은 하나의 `POST /emails` 요청으로 시작됩니다. Sendtern는 이 요청을 검증하고, ID를 포함한 `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은 최대 200,000자, 일반 텍스트는 최대 100,000자까지 사용할 수 있습니다.

## 태그

최대 10개의 `tags`를 보낼 수 있습니다. 각 태그에는 `name`와 `value`가 있으며, 각각 최대 128개의 문자, 숫자, 하이픈 또는 밑줄이 있습니다.

## 요청 후

이메일은 **queued**로 시작되고 수신자 서버가 응답할 때 [statuses](https://sendtern.com/docs/statuses)를 통해 이동합니다. 반환된 `id`를 사용하여 언제든지 [retrieve it](https://sendtern.com/docs/api-get-email)를 검색할 수 있습니다.
