冷邮件 API
发送单封邮件
在序列之外单独发一封邮件,可带附件。发出时收取 $0.03。
POST https://api.won.dev/v1/email/messages
在序列之外单独发送一封邮件。可以再次发给活动已联系过的人(recipient_id),比如一周后把对方要的报价发过去;也可以发给回复中推荐给你的同事(reply_id 加 to):与回复者同一家公司的人,或者回复中提到的地址。邮件从这段对话一直使用的邮箱发出,署名不变。不传 subject 时,邮件会接在上一封邮件的会话里;传入则开启新会话。附件放在 attachments 中。发出时收取 $0.03;未能投递则不收费。它与发送活动一起计入账户当天的发信量。不能给已退订、已退信或在禁发名单上的人发信;回复中没有提到的新联系人,请加入发送活动:POST /email/campaigns/{id}/recipients。24 小时内的相同请求会被视为重复:你会拿到第一次的结果,不会重复发信。
- 计费:
email_sent$0.03:成功投递给对方邮件服务器的一封邮件。
参数
参数放在 JSON 请求体里。POST 请求还支持 Idempotency-Key 请求头,见重复请求。
| 参数 | 类型 | 必填 | 说明(API 原文) |
|---|---|---|---|
recipient_id | string | 否 | Write again to this recipient, such as rcp_9x7p1q8w3e5r4k2m. They must have had an email of the campaign. |
reply_id | string | 否 | Instead of recipient_id: write to someone this reply pointed to, such as rpl_1q8w3e5r4k2m9x7p. Needs to. |
to | string | 否 | With reply_id: the colleague's email address. |
first_name | string | 否 | With reply_id: the colleague's first name, for {{first_name}}. |
last_name | string | 否 | With reply_id: the colleague's last name. |
subject | string | 否 | The subject line of a new thread. Leave it out to write in the thread of the last email. |
text | string | 是 | The email, as plain text. Placeholders such as {{first_name|there}} work as in a campaign. No signature block or unsubscribe line: every email ends with them. |
attachments | object[] | 否 | Up to 3 files, 10 MB together: PDFs, pictures, office documents, CSV and text. Each needs content or url. |
attachments[].filename | string | 是 | The name the recipient sees, with its extension: .pdf, .png, .jpg, .jpeg, .gif, .webp, .docx, .xlsx, .pptx, .doc, .xls, .ppt, .csv, .txt. |
attachments[].content | string | 否 | The file, base64-encoded. Up to about 3 MB this way; pass url for a larger file. |
attachments[].url | string | 否 | Instead of content: a public https:// address we fetch the file from while the email is sent. |
max_cost | number | 否 | Spending cap for this call in US dollars. If the call could cost more, it fails with budget_exceeded before anything is charged. |
dry_run | boolean | 否 | If true, only return the maximum cost of this call. Nothing runs, nothing is charged. Default: false. |
响应
传入 dry_run: true 时不会发信,data 中只返回本次调用的最高费用,见预估费用。错误说明见错误码。
| 字段 | 类型 | 说明(API 原文) |
|---|---|---|
data | object | The email, with who it went to. |
data.id | string | Message ID, such as msg_3e5r4k2m9x7p1q8w. |
data.campaign_id | string | |
data.recipient_id | string | |
data.to | string | |
data.kind | step | reply | single | step of the sequence, reply (your answer to a reply), or single (an email you sent on its own with POST /email/messages). |
data.step | integer | null | The step, counted from 1. Null for a reply or a single email. |
data.version | integer | Which version of the step went out, counted from 1. |
data.status | sending | sent | bounced | failed | skipped | sent, bounced, or sending for the seconds it takes. failed and skipped did not go out and cost nothing. |
data.subject | string | |
data.opens | integer | Opens that look like a person's. Machines that fetch mail to scan it are left out. |
data.clicks | integer | |
data.bounce_type | hard | soft | null | |
data.cost | number | What it cost, in US dollars. 0 after a refund. |
data.attachments | object[] | The files that went with it. |
data.attachments[].filename | string | |
data.attachments[].content_type | string | |
data.attachments[].size | integer | In bytes. |
data.sent_at | string | null | |
data.recipient | object | Who it went to. A colleague a reply pointed to is added to the campaign, outside its sequence. |
data.recipient.id | string | Recipient ID, such as rcp_9x7p1q8w3e5r4k2m. |
data.recipient.campaign_id | string | |
data.recipient.email | string | |
data.recipient.first_name | string | null | |
data.recipient.last_name | string | null | |
data.recipient.company | string | null | |
data.recipient.country | string | null | ISO 3166-1 alpha-2, as given or as read off the address. |
data.recipient.contact_id | string | null | The person ID it was added by. |
data.recipient.status | verifying | scheduled | active | replied | completed | bounced | unsubscribed | suppressed | invalid | stopped | verifying while the address is checked, scheduled before the first email, active between emails. Final: replied, completed (every email sent, no answer), bounced, unsubscribed, suppressed, invalid, stopped. |
data.recipient.reason | string | null | Why, for invalid, stopped, bounced and suppressed. |
data.recipient.risky | boolean | The address could not be confirmed: its domain accepts mail for any name. |
data.recipient.emails_sent | integer | |
data.recipient.next_send_at | string | null | When the next email is due at the earliest. |
data.recipient.last_sent_at | string | null | |
data.recipient.metadata | object | Your own keys and values, as you gave them. Empty when none were. |
data.recipient.created_at | string | When it was added, as an ISO 8601 time in UTC. |
notice | string | null | A plain sentence when there is something to know about this answer. Null otherwise. |
usage | object | What this call was charged, and the balance left. |
usage.unit | email_sent | email_sent_dedicated | email_capacity | email_dedicated_domain | What is counted. |
usage.records | integer | How many were returned and charged. |
usage.already_paid | integer | How many more were returned for free, because this organization paid for them in the last 30 days. |
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/messages \
-H "Authorization: Bearer $WON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipient_id": "rcp_9x7p1q8w3e5r4k2m",
"text": "Hi Dana,\n\nAs promised, here is the quote for 40 chairs. It holds until the end of the month.\n\nAlex",
"attachments": [
{
"filename": "quote-harborline.pdf",
"url": "https://northwind-seating.example/q/2611.pdf"
}
]
}'{
"data": {
"id": "msg_2k9x7p1q8w3e5r4m",
"campaign_id": "cmp_7p1q8w3e5r4k2m9x",
"recipient_id": "rcp_9x7p1q8w3e5r4k2m",
"to": "dana.whitfield@harborline-imports.example",
"kind": "single",
"step": null,
"version": 1,
"status": "sent",
"subject": "Re: Office chairs for Harborline Imports",
"opens": 0,
"clicks": 0,
"bounce_type": null,
"cost": 0.03,
"attachments": [
{
"filename": "quote-harborline.pdf",
"content_type": "application/pdf",
"size": 96540
}
],
"sent_at": "2026-11-27T15:12:40.000Z",
"recipient": {
"id": "rcp_9x7p1q8w3e5r4k2m",
"campaign_id": "cmp_7p1q8w3e5r4k2m9x",
"email": "dana.whitfield@harborline-imports.example",
"first_name": "Dana",
"last_name": "Whitfield",
"company": "Harborline Imports",
"country": "US",
"contact_id": null,
"status": "active",
"reason": null,
"risky": false,
"emails_sent": 1,
"next_send_at": "2026-11-24T15:20:00.000Z",
"last_sent_at": "2026-11-27T15:12:40.000Z",
"metadata": {
"crm_id": "lead_4471"
},
"created_at": "2026-11-18T14:03:10.000Z"
}
},
"notice": null,
"usage": {
"unit": "email_sent",
"records": 1,
"already_paid": 0,
"cost": 0.03,
"balance": 48.05,
"replayed": false
}
}用测试 key(won_test_...)发送这个请求,会在沙箱中运行:不发信,不收费。