# 发送测试邮件

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

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

立即把活动的某一步发给你团队里的人，让你像收件人一样读到它：从发件方的某个邮箱、以发件方的名义发出，带页脚和退订链接（点开只显示退订页，不会记录任何东西）。占位符填入某位收件人的信息：`recipient_id` 指定的那位，否则是活动里的第一位；活动还没有收件人时使用默认值。跟进邮件会带上 `Re:` 主题，并在下方引用上一封邮件。草稿也可以发。测试邮件计入发件方域名当天的发送量，每个账户每天最多发 20 封（`daily_limit_reached`），每分钟最多 5 封（`rate_limited`）。发件方还没有发信域名时返回 `no_domains`。测试 key 不会真的发出：`simulated` 为 true，`text` 是本应发出的内容。免费。

- **计费：** 调用免费，邮件本身也免费：它们从发件方的发信域名发出，域名按月付费，见[发信域名](/zh/docs/email#domains)。

用测试 key（`won_test_...`）发送这个请求，会在[沙箱](/zh/docs/email#sandbox)中运行：不发信，不收费。

## 参数 [#parameters]

`id` 放在路径中，其余参数放在 JSON 请求体里。`POST` 请求还支持 `Idempotency-Key` 请求头，见[重复请求](/zh/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]

错误说明见[错误码](/zh/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
  }
}
```