冷邮件 API
添加收件人
向发送活动添加最多 1,000 位收件人。每个地址都会经过检查,响应中会说明哪些被排除以及原因。免费。
POST https://api.won.dev/v1/email/campaigns/{id}/recipients
向发送活动添加最多 1,000 位收件人,活动结束前随时可以添加。每个地址会在调用过程中完成检查(格式、禁发名单、此人是否已在你其他运行中的活动里、地区规则、占位符是否缺值),响应会列出每个被排除的地址及原因。通过的地址随后还会检查邮箱是否存在,需要几分钟;未通过的会标为 invalid,不收费。同一份名单重复提交不会产生任何变化。收件人可以是任意接口返回给你的、带邮箱的人:把他的 per_ ID 作为 contact_id 传入,代替邮箱地址。免费;邮件在发出时计费。
- 计费: 调用本身免费。发送活动每发出一封邮件收取 $0.03(
email_sent),见计费。
参数
id 放在路径中,其余参数放在 JSON 请求体里。POST 请求还支持 Idempotency-Key 请求头,见重复请求。
| 参数 | 类型 | 必填 | 说明(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. |
响应
传入 dry_run: true 时不会创建或修改任何东西:响应字段不变,内容为将会发生的结果。错误说明见错误码。
| 字段 | 类型 | 说明(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. |
示例
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"
}
]
}'{
"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
}
}用测试 key(won_test_...)发送这个请求,会在沙箱中运行:不发信,不收费。