# テストメールを送る

Source: https://won.dev/ja/docs/email/campaigns-test

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

キャンペーンのステップを今すぐ自分のチームの人に送り、受信者と同じように読めるようにします。送信者のメールボックスから送信者の名前で、フッターと配信停止リンクつきで届きます（リンクを開くとページが表示されますが、何も記録されません）。プレースホルダーには受信者の情報が入ります。`recipient_id`で指定した人、指定がなければキャンペーンの最初の人、まだ誰もいなければフォールバックの値です。フォローアップには`Re:`の件名がつき、前のメールが下に引用されます。下書きでも使えます。送信者のドメインがその日に送れる数に含まれ、1つのアカウントが送れるテストメールは1日20通（`daily_limit_reached`）、1分に5通（`rate_limited`）までです。送信者に送信ドメインがない間は`no_domains`で失敗します。テストキーでは何も送られません。`simulated`がtrueになり、`text`が送られるはずだった内容です。無料です。

- **課金：** 呼び出しは無料で、メールも無料です。メールは送信者の送信ドメインから送られ、ドメインは月ごとに支払います。[送信ドメイン](/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`. |
| `to` | string | いいえ | Who gets it: the address someone of your account signs in with. Leave it out to send it to the account's owner. |
| `step` | integer | いいえ | The step, counted from 1. Default: `1`. |
| `version` | integer | いいえ | The version of the step, counted from 1. Default: `1`. |
| `recipient_id` | string | いいえ | The recipient whose details fill in the placeholders, such as `rcp_9x7p1q8w3e5r4k2m`. They get nothing. |

## レスポンス [#response]

エラーについては[エラーコード](/ja/docs/errors)を参照してください。

| フィールド | 型 | 説明（APIの原文） |
| --- | --- | --- |
| `data` | object |  |
| `data.id` | string | Test email ID, such as `tst_8w3e5r4k2m9x`. |
| `data.campaign_id` | string |  |
| `data.from` | string | The mailbox it went out from, under the name recipients see. |
| `data.to` | string |  |
| `data.step` | integer | The step, counted from 1. |
| `data.version` | integer | The version of the step, counted from 1. |
| `data.recipient_id` | string \| null | The recipient whose details filled in the placeholders. Null when the campaign has none yet: then only the fallbacks did. |
| `data.subject` | string |  |
| `data.text` | string | The email as it went out, footer and unsubscribe link included. A follow-up quotes the email before it. |
| `data.simulated` | boolean | Made with a test key: nothing was sent, and this is what would have gone out. |
| `data.sent_at` | string |  |
| `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/test \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "jamie@northwind-seating.example",
  "step": 1,
  "version": 1
}'
```

```json
{
  "data": {
    "id": "tst_3e5r4k2m9x7p",
    "campaign_id": "cmp_7p1q8w3e5r4k2m9x",
    "from": "alex@northwindseating.example",
    "to": "jamie@northwind-seating.example",
    "step": 1,
    "version": 1,
    "recipient_id": "rcp_9x7p1q8w3e5r4k2m",
    "subject": "Office chairs for Harborline Imports",
    "text": "Hi Dana,\n\nI saw that Harborline Imports imports office seating. We make mesh task chairs in Leeds and ship to the US in four weeks.\n\nWould a price list be useful?\n\nAlex\n\nNorthwind Seating Ltd, 18 Harbour Road, Leeds LS1 4AP, United Kingdom\nNot relevant? Unsubscribe: https://won.dev/e/u/9k2m4x",
    "simulated": false,
    "sent_at": "2026-11-18T13:40:02.000Z"
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}
```