# 修改邮件

Source: https://won.dev/zh/docs/email/messages-update

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

修改一封等待审批、或已批准但还没发出的邮件的主题或正文，只针对这一个人。它会像每封邮件一样经过检查，然后重新等待审批。请直接写出内容：占位符已经填好了。回复上一封邮件的跟进邮件沿用该线程的主题。之后修改活动的步骤时，这封邮件保持修改后的样子。免费。

- **计费：** 免费。

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

## 参数 [#parameters]

`id` 放在路径中，其余参数放在 JSON 请求体里。`PATCH` 请求还支持 `Idempotency-Key` 请求头，见[重复请求](/zh/docs/email#idempotency)。

| 参数 | 类型 | 必填 | 说明（API 原文） |
| --- | --- | --- | --- |
| `id` | string | 是 | Email ID, such as `msg_3e5r4k2m9x7p1q8w`. |
| `subject` | string | 否 | The new subject line. |
| `text` | string | 否 | The new text, as plain text. The footer and the unsubscribe link are added when it goes out. |

## 响应 [#response]

错误说明见[错误码](/zh/docs/errors)。

| 字段 | 类型 | 说明（API 原文） |
| --- | --- | --- |
| `data` | object |  |
| `data.id` | string | Message ID, such as `msg_3e5r4k2m9x7p1q8w`. |
| `data.conversation_id` | string | Its conversation with the person, such as `cnv_9x7p1q8w3e5r4k2m`. |
| `data.campaign_id` | string |  |
| `data.recipient_id` | string |  |
| `data.from` | string \| null | The address it went out from: a mailbox of the sender's domains. |
| `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` | `pending_approval` \| `approved` \| `sending` \| `sent` \| `bounced` \| `failed` \| `skipped` | `sent`, `bounced`, or `sending` for the seconds it takes. `failed` and `skipped` did not go out. On a campaign that asks for approval, `pending_approval` waits for a person to approve it, and `approved` waits for its mailbox and the recipient's office hours. |
| `data.subject` | string |  |
| `data.text` | string \| null | What it says, placeholders filled in, without the footer and the quoted email under a follow-up. On one that waits for approval, what will go out. |
| `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.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 |  |
| `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 -X PATCH https://api.won.dev/v1/email/messages/msg_3e5r4k2m9x7p1q8w \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Hi Dana,\n\nI saw that Harborline Imports imports office seating, and that you opened a warehouse in Savannah. We make mesh task chairs in Leeds and ship to the US in four weeks.\n\nWould a price list be useful?\n\nAlex"
}'
```

```json
{
  "data": {
    "id": "msg_3e5r4k2m9x7p1q8w",
    "conversation_id": "cnv_9x7p1q8w3e5r4k2m",
    "campaign_id": "cmp_7p1q8w3e5r4k2m9x",
    "recipient_id": "rcp_9x7p1q8w3e5r4k2m",
    "from": "alex@northwindseating.example",
    "to": "dana.whitfield@harborline-imports.example",
    "kind": "step",
    "step": 1,
    "version": 1,
    "status": "pending_approval",
    "subject": "Office chairs for Harborline Imports",
    "text": "Hi Dana,\n\nI saw that Harborline Imports imports office seating, and that you opened a warehouse in Savannah. We make mesh task chairs in Leeds and ship to the US in four weeks.\n\nWould a price list be useful?\n\nAlex",
    "opens": 0,
    "clicks": 0,
    "bounce_type": null,
    "attachments": [],
    "sent_at": null
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}
```