# 受信者を追加する

Source: https://won.dev/ja/docs/email/recipients-add

`POST https://api.won.dev/v1/email/campaigns/{id}/recipients`

キャンペーンが終了する前ならいつでも、最大1,000人を追加できます。各アドレスは呼び出しの中でチェックされ（形式、送信停止リスト、その人がすでにあなたの実行中のキャンペーンに入っていないか、地域のルール、プレースホルダーの値の不足）、除外したすべてのアドレスを理由つきで返します。受け入れたアドレスは、続けてメールボックスが実在するかを確認します。キャンペーンの最初の50件は数分以内に、残りはそれぞれ最初のメールの約1日前に確認するので、長いリストが何か月も前に確認されることはありません。確認できなかったものは `invalid` になります。同じリストを2回送っても何も変わりません。受信者には、どのエンドポイントがメールアドレスつきで返した人でも指定できます。アドレスの代わりに、その人の `per_` IDを `contact_id` として渡してください。無料です。

- **課金：** 呼び出しは無料で、メールも無料です。メールは送信者の送信ドメインから送られ、ドメインは月ごとに支払います。[送信ドメイン](/ja/docs/email#domains)を参照してください。

テストキー（`won_test_...`）では、これは[サンドボックス](/ja/docs/email#sandbox)で動きます。何も送信されず、課金もされません。

## パラメーター [#parameters]

`id` はパスに含めます。それ以外はJSONのリクエストボディで渡します。`POST` リクエストでは `Idempotency-Key` ヘッダーも使えます。[同じリクエストを2回送ったとき](/ja/docs/email#idempotency)を参照してください。

| パラメーター | 型 | 必須 | 説明（APIの原文） |
| --- | --- | --- | --- |
| `id` | string | はい | Campaign ID, such as `cmp_7p1q8w3e5r4k2m9x`. |
| `recipients` | object[] | はい | Up to 1000 people to add. Each needs `email` or `contact_id`. |
| `recipients[].email` | string | いいえ | The person's work email. |
| `recipients[].contact_id` | string | いいえ | A person ID this account was given in the last 90 days, such as `per_8f3k2m9x4p1q`, instead of `email`: from a contact search, a people search, or any endpoint that returns a person. Their email, name, company and country on file are used. A person found without an email needs one first: `POST /enrich/people/email/find` with `person_id`. |
| `recipients[].first_name` | string | いいえ | The person's first name, for `{{first_name}}`. |
| `recipients[].last_name` | string | いいえ | The person's last name, for `{{last_name}}`. |
| `recipients[].company` | string | いいえ | The company the person works at, for `{{company}}`. |
| `recipients[].country` | string | いいえ | Where the person is, as an ISO code such as `US`. It decides their office hours and which rules apply. Guessed from the address when left out. An address that shows a country itself, such as one ending in `.de`, stays under that country's rules whatever is given here. |
| `recipients[].timezone` | string | いいえ | The person's IANA time zone, when you know it better than the country says. |
| `recipients[].variables` | object | いいえ | Values for your own placeholders, such as `{ "product": "mesh chairs" }` for `{{product}}`. Names are lowercase letters, digits and underscores. |
| `recipients[].metadata` | object | いいえ | Your own keys and values, such as `{"customer_id": "c_812"}`: up to 20 keys of at most 40 characters, each value a string of at most 500. Returned with the recipient, and in the events about them over the campaign's keys of the same name. |
| `dry_run` | boolean | いいえ | Only check the list and say what would happen. Nothing is added. Default: `false`. |

## レスポンス [#response]

`dry_run: true` を指定すると、何も作成も変更もされません。レスポンスのフィールドは同じで、何が起きるかを示します。エラーについては[エラーコード](/ja/docs/errors)を参照してください。

| フィールド | 型 | 説明（APIの原文） |
| --- | --- | --- |
| `data` | object | What became of each address. |
| `data.accepted` | integer | Addresses taken into the campaign. |
| `data.duplicates` | integer | Addresses that were in the campaign already. Nothing changed for them. |
| `data.rejected` | integer | Addresses left out. `results` says why for each. |
| `data.results` | object[] | One entry for each address that was rejected, was a duplicate, or was accepted with a warning. Addresses accepted without remark are only counted. |
| `data.results[].email` | string \| null |  |
| `data.results[].status` | `accepted` \| `duplicate` \| `rejected` |  |
| `data.results[].recipient_id` | string \| null |  |
| `data.results[].reason` | string \| null | Why it was rejected: `invalid_address`, `blocked_mailbox`, `duplicate_in_request`, `suppressed`, `complained`, `undeliverable`, `active_in_other_campaign`, `region_blocked`, `region_not_declared`, `personal_mailbox_in_region`, `missing_variable`, `contact_not_found` or `campaign_full`. |
| `data.results[].message` | string \| null | The same in a sentence, with what to do about it. |
| `data.results[].warnings` | string[] | For an accepted address: `shared_mailbox` (such as info@, read by whoever is on duty) or `personal_mailbox` (a private mail service). |
| `data.dry_run` | boolean | True when nothing was added: the answer to `dry_run: true`. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

## 例 [#example]

```bash
curl https://api.won.dev/v1/email/campaigns/cmp_7p1q8w3e5r4k2m9x/recipients \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "recipients": [
    {
      "email": "sam.ortiz@brightdesk.example",
      "first_name": "Sam",
      "company": "Brightdesk"
    },
    {
      "email": "noreply@brightdesk.example",
      "company": "Brightdesk"
    }
  ]
}'
```

```json
{
  "data": {
    "dry_run": false,
    "accepted": 1,
    "duplicates": 0,
    "rejected": 1,
    "results": [
      {
        "email": "noreply@brightdesk.example",
        "status": "rejected",
        "recipient_id": null,
        "reason": "blocked_mailbox",
        "message": "This mailbox is not read by a person (such as noreply@ or postmaster@).",
        "warnings": []
      }
    ]
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}
```