跳到正文
Won.dev
冷邮件 API

修改发送活动

修改尚未结束的发送活动:文案、发送时段和上限,从下一封邮件起生效。免费。

PATCH https://api.won.dev/v1/email/campaigns/{id}

修改尚未结束的发送活动(draft、active 或 paused):只修改传入的字段,其余保持不变。每发一封邮件前都会重新读取活动,所以修改从下一封邮件起生效。steps 会替换整个序列:已经发给过收件人的步骤会保留在序列中,已发出的每个版本也会保留,但文案可以修改,只影响之后待发的邮件;还没有人收到的步骤可以修改、删除或新增。已收完所有步骤的人视为已完成,之后新增的步骤不会再发给他们。已经开始计时的等待间隔保持原长度。新文案会像创建时一样经过检查;如果占位符没有备用值,而待发收件人中有人缺少这个值,修改会被拒绝。把 max_cost 调到低于已花费金额时,活动会在下一封邮件前暂停;调高 max_cost 不会自动恢复已暂停的活动,需要调用 POST /email/campaigns/{id}/resume。此接口不支持预演:未通过检查的修改不会生效。免费。

  • 计费: 免费。

参数

id 放在路径中,其余参数放在 JSON 请求体里。PATCH 请求还支持 Idempotency-Key 请求头,见重复请求。

参数类型必填说明(API 原文)
idstring是Campaign ID, such as cmp_7p1q8w3e5r4k2m9x.
namestring否A name for your own reference. Recipients never see it.
stepsobject[]否The whole sequence as it is to be, in order. It replaces the one there is.
steps[].delay_daysinteger否Sending days to wait after the step before. Default 3. Ignored on the first step.
steps[].subjectstring否The subject line. Required on the first step. Leave it out on a follow-up to send it as a reply in the thread of the first email, which is what gets answers.
steps[].bodystring是The text, as plain text. Placeholders: {{first_name}}, {{last_name}}, {{company}}, your own from variables, and {{sender_first_name}} and {{sender_name}} for the name of the mailbox that writes. {{first_name|there}} falls back to "there". Do not add a signature block with your company and address or an unsubscribe line: every email ends with them.
steps[].weightinteger否With variants: this version's share of the recipients, relative to the others. Default: 1.
steps[].variantsobject[]否Other versions of this step, to test against it. Each recipient gets one version, always the same one. GET /email/campaigns/{id} shows how each did.
steps[].variants[].subjectstring否The subject line. Required on the first step. Leave it out on a follow-up to send it as a reply in the thread of the first email, which is what gets answers.
steps[].variants[].bodystring是The text, as plain text. Placeholders: {{first_name}}, {{last_name}}, {{company}}, your own from variables, and {{sender_first_name}} and {{sender_name}} for the name of the mailbox that writes. {{first_name|there}} falls back to "there". Do not add a signature block with your company and address or an unsubscribe line: every email ends with them.
steps[].variants[].weightinteger否With variants: this version's share of the recipients, relative to the others. Default: 1.
scheduleobject否The days and hours to send in. It replaces the whole schedule.
schedule.timezonestring否IANA time zone the hours are read in for a recipient whose own is not known. Default America/New_York.
schedule.days(sun | mon | tue | wed | thu | fri | sat)[]否Days emails go out on. Default Monday to Friday.
schedule.start_hourinteger否First hour emails go out in. Default 9.
schedule.end_hourinteger否Emails go out before this hour. Default 17.
daily_limitinteger否The most emails the campaign sends on one day. A new account also has a daily limit across its campaigns, which rises as it sends without bounces and complaints.
stop_on_company_replyboolean否When one person at a company answers, stop writing to the others at that company.
track_opensboolean否Count opens with an invisible image. Off by default: it lowers inbox placement, and mail programs that fetch images themselves make the numbers unreliable.
track_clicksboolean否Count clicks by sending links through our redirect. Off by default, for the same reason.
max_costnumber | null否The most the campaign may spend in its whole life, in US dollars. null takes the limit away.
metadataobject否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. It replaces the metadata there is; {} removes it. Events that already happened keep what they carried.

响应

错误说明见错误码。

字段类型说明(API 原文)
dataobjectThe campaign as it is now, and what the checks found in its texts.
data.campaignobject
data.campaign.idstringCampaign ID, such as cmp_7p1q8w3e5r4k2m9x.
data.campaign.namestring
data.campaign.sender_idstring
data.campaign.tenant_idstring | nullIts sender's tenant_id. Null: the account itself.
data.campaign.statusdraft | in_review | active | paused | completed | canceled | suspendeddraft until started. active sends. paused waits for resume. completed, canceled and suspended are final. in_review is no longer given: a campaign left waiting for a review from before starts by itself within minutes.
data.campaign.pause_reasonmanual | insufficient_balance | max_cost | list_quality | sending_suspended | nullWhy it is paused: manual, insufficient_balance (top up, then resume), max_cost (the campaign's own cap is reached), list_quality (too many invalid addresses; resuming accepts the list as it is), sending_suspended.
data.campaign.stepsobject[]The sequence, in order.
data.campaign.steps[].delay_daysintegerSending days to wait after the email before. 0 on the first step.
data.campaign.steps[].versionsobject[]The text of the step. More than one when versions are tested against each other.
data.campaign.steps[].versions[].subjectstring | nullNull on a follow-up that goes out as a reply in the thread of the first email.
data.campaign.steps[].versions[].bodystring
data.campaign.steps[].versions[].weightintegerIts share of the recipients, relative to the other versions.
data.campaign.steps[].versions[].statsobjectHow this version did.
data.campaign.steps[].versions[].stats.sentinteger
data.campaign.steps[].versions[].stats.openedintegerEmails opened at least once. Counted only when track_opens is on.
data.campaign.steps[].versions[].stats.clickedinteger
data.campaign.steps[].versions[].stats.repliedintegerReplies that came after this email and before the next one.
data.campaign.scheduleobjectWhen emails go out: on these days, between these hours, in the recipient's time.
data.campaign.schedule.timezonestringIANA time zone the hours are read in when a recipient's own is not known.
data.campaign.schedule.days(sun | mon | tue | wed | thu | fri | sat)[]
data.campaign.schedule.start_hourinteger
data.campaign.schedule.end_hourinteger
data.campaign.daily_limitintegerThe most emails the campaign sends on one day.
data.campaign.stop_on_company_replybooleanOne person at a company answers: nobody else at that company gets another email.
data.campaign.track_opensboolean
data.campaign.track_clicksboolean
data.campaign.max_costnumber | nullThe most the campaign may spend in its life, in US dollars. Null when not set.
data.campaign.metadataobjectYour own keys and values, as you gave them. Empty when none were.
data.campaign.statsobjectWhere the campaign stands.
data.campaign.stats.recipientsintegerPeople in the campaign.
data.campaign.stats.waitingintegerStill being checked, or waiting for their first email.
data.campaign.stats.in_sequenceintegerGot at least one email and have more to come.
data.campaign.stats.finishedintegerGot every email and did not answer.
data.campaign.stats.repliedinteger
data.campaign.stats.bouncedinteger
data.campaign.stats.unsubscribedinteger
data.campaign.stats.excludedintegerLeft out or stopped: invalid address, suppressed, or stopped by you.
data.campaign.stats.emails_sentinteger
data.campaign.stats.emails_openedinteger
data.campaign.stats.emails_clickedinteger
data.campaign.stats.spentnumberWhat the campaign has cost so far, in US dollars.
data.campaign.stats.reservednumberSet aside from the balance for the emails of the next days, in US dollars.
data.campaign.testbooleanMade with a test key: sending and replies are simulated.
data.campaign.created_atstringWhen it was created, as an ISO 8601 time in UTC.
data.campaign.started_atstring | null
data.campaign.completed_atstring | null
data.campaign.next_check_afterinteger | nullSeconds until something is likely to have changed. Asking sooner tells you nothing new. Null when the campaign is not running.
data.contentobjectWhat the checks found in the sequence as it is now.
data.content.adviceobject[]What would make the emails more likely to reach an inbox and be answered.
data.content.advice[].stepintegerThe step, counted from 1.
data.content.advice[].versionintegerThe version of the step, counted from 1.
data.content.advice[].fieldsubject | body
data.content.advice[].codestring
data.content.advice[].messagestring
data.content.variablesobject[]The placeholders your texts use beyond the sender's own. required ones have no fallback: a recipient without a value is left out.
data.content.variables[].namestring
data.content.variables[].requiredboolean
noticestring | nullA plain sentence when there is something to know about this answer. Null otherwise.
usageobjectNothing is charged here. The balance, for reference.
usage.costnumberWhat this call cost, in US dollars.
usage.balancenumberThe balance left after this call, in US dollars.
usage.replayedbooleanTrue when this is a repeat of a request from the last 24 hours. Repeats are free.

示例

curl -X PATCH https://api.won.dev/v1/email/campaigns/cmp_7p1q8w3e5r4k2m9x \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "daily_limit": 80,
  "steps": [
    {
      "subject": "Office chairs for {{company}}",
      "body": "Hi {{first_name|there}},\n\nI saw that {{company}} 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\n{{sender_first_name}}"
    },
    {
      "delay_days": 4,
      "body": "Hi {{first_name|there}},\n\nWe can ship samples within a week now. Shall I send one?\n\n{{sender_first_name}}"
    }
  ]
}'
{
  "data": {
    "campaign": {
      "id": "cmp_7p1q8w3e5r4k2m9x",
      "name": "US chair importers, November",
      "sender_id": "snd_4k2m9x7p1q8w3e5r",
      "tenant_id": null,
      "status": "active",
      "pause_reason": null,
      "steps": [
        {
          "delay_days": 0,
          "versions": [
            {
              "subject": "Office chairs for {{company}}",
              "body": "Hi {{first_name|there}},\n\nI saw that {{company}} 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\n{{sender_first_name}}",
              "weight": 1,
              "stats": {
                "sent": 42,
                "opened": 0,
                "clicked": 0,
                "replied": 3
              }
            }
          ]
        },
        {
          "delay_days": 3,
          "versions": [
            {
              "subject": null,
              "body": "Hi {{first_name|there}},\n\nJust checking that my note reached the right person. Who looks after seating suppliers at {{company}}?\n\n{{sender_first_name}}",
              "weight": 1,
              "stats": {
                "sent": 17,
                "opened": 0,
                "clicked": 0,
                "replied": 1
              }
            }
          ]
        }
      ],
      "schedule": {
        "timezone": "America/New_York",
        "days": [
          "mon",
          "tue",
          "wed",
          "thu",
          "fri"
        ],
        "start_hour": 9,
        "end_hour": 17
      },
      "daily_limit": 80,
      "stop_on_company_reply": true,
      "track_opens": false,
      "track_clicks": false,
      "max_cost": 25,
      "metadata": {
        "customer_id": "c_812"
      },
      "stats": {
        "recipients": 120,
        "waiting": 74,
        "in_sequence": 38,
        "finished": 0,
        "replied": 4,
        "bounced": 1,
        "unsubscribed": 1,
        "excluded": 2,
        "emails_sent": 59,
        "emails_opened": 0,
        "emails_clicked": 0,
        "spent": 1.74,
        "reserved": 5.46
      },
      "test": false,
      "created_at": "2026-11-18T14:03:10.000Z",
      "started_at": "2026-11-18T14:03:11.000Z",
      "completed_at": null,
      "next_check_after": 1740
    },
    "content": {
      "advice": [],
      "variables": [
        {
          "name": "company",
          "required": true
        },
        {
          "name": "first_name",
          "required": false
        }
      ]
    }
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}

用测试 key(won_test_...)发送这个请求,会在沙箱中运行:不发信,不收费。

本页内容