> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 批量处理事件

> 一次请求确认、解决、暂缓、转派多个事件，或修改它们的严重度。

```http theme={null}
POST /api/v1/alerts/incidents/bulk
```

对 `ids` 里的每个事件做同一件事，逐个处理：一个事件处理不了，不影响其余的。`action` 指明做什么，它要的字段写在旁边：

| `action` | 字段 | 做什么 |
| - | - | - |
| `acknowledge` | 无 | 同[确认事件](https://docs.molesignal.com/zh-Hans/api/alerting/ack-incident.md)。 |
| `resolve` | 无 | 同[解决事件](https://docs.molesignal.com/zh-Hans/api/alerting/resolve-incident.md)。 |
| `snooze` | `duration_secs` | 同[暂缓事件](https://docs.molesignal.com/zh-Hans/api/alerting/snooze-incident.md)。 |
| `reassign` | `to`，即[转派事件](https://docs.molesignal.com/zh-Hans/api/alerting/reassign-incident.md)的请求体 | 同这个调用。 |
| `set_severity` | `severity` | 同[设置事件严重度](https://docs.molesignal.com/zh-Hans/api/alerting/set-incident-severity.md)。 |

该调用需要 `alerts.incidents.acknowledge`，每个事件按单个调用的规则检查。合并不是批量操作，请用[合并事件](https://docs.molesignal.com/zh-Hans/api/alerting/merge-incidents.md)。

**请求体**

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `ids` | array | 是 | 1 到 100 个事件 ID，重复的只算一次。 |
| `action` | string | 是 | `acknowledge`、`resolve`、`snooze`、`reassign` 或 `set_severity`。 |

```bash cURL theme={null}
curl -X POST http://localhost:5080/api/v1/alerts/incidents/bulk \
  -H "authorization: Bearer $MS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"ids": ["<incident-id>", "<another-incident-id>"], "action": "snooze", "duration_secs": 3600}'
```

响应里每个事件一条结果：`id`，没处理成时还有 `error`，例如事件已恢复，或 `duration_secs` 超出范围。

```json 200 theme={null}
{
  "results": [
    {
      "id": "3KEDNEyqouYJeBDTLTMTBui7XHW"
    },
    {
      "id": "3KEDQ4mJ8sLp2Xv6Nc1Rt9bYwHe",
      "error": "this incident is no longer active"
    }
  ]
}
```

**错误**

| 状态码 | 原因 |
| - | - |
| `400` | `ids` 为空或超过 100 个。 |
| `403` | Token 缺少 `alerts.incidents.acknowledge`。 |
| `422` | 缺少 `action` 或不认识，或缺少它要的字段。 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.