# 批准邮件

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

`POST https://api.won.dev/v1/email/messages/approve`

批准等待审批（`pending_approval`）的邮件：每封都按写好的内容，在它的邮箱可以发信、且收件人处于工作时间时尽快发出。没有在等待审批的邮件（例如已经批准过的）保持不变（`done: false`）。设置为需要审批的 key 不能批准（`forbidden`）：由人在控制台中批准。免费。

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

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

## 参数 [#parameters]

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

| 参数 | 类型 | 必填 | 说明（API 原文） |
| --- | --- | --- | --- |
| `message_ids` | string[] | 是 | Up to 100 email IDs, such as `msg_3e5r4k2m9x7p1q8w`, from `GET /email/messages?status=pending_approval`. |

## 响应 [#response]

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

| 字段 | 类型 | 说明（API 原文） |
| --- | --- | --- |
| `data` | object[] | One result per ID, in the order given. |
| `data[].id` | string |  |
| `data[].done` | boolean | Whether this call changed it. |
| `data[].status` | `pending_approval` \| `approved` \| `sending` \| `sent` \| `bounced` \| `failed` \| `skipped` \| null | Its status now. Null for an ID this account has no email with, or one of the other kind of key. |
| `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/messages/approve \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "message_ids": [
    "msg_3e5r4k2m9x7p1q8w"
  ]
}'
```

```json
{
  "data": [
    {
      "id": "msg_3e5r4k2m9x7p1q8w",
      "done": true,
      "status": "approved"
    }
  ],
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.08,
    "replayed": false
  }
}
```