事件 API (Event)
事件 API 使用以下三个入口:
POST /event/createPOST /event/updatePOST /event/close
- 请求体必须是 JSON。
- 请求模型为严格解析,未声明字段会直接报错(400)。
Authorization: Bearer <token>仅在网关开启鉴权时必填。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
channel_id | string | 是 | 目标频道 ID。 |
password | string | 是 | 频道密码,长度 8-128。 |
op_id | string | 否 | 幂等键;不传则网关自动生成并在响应回传。 |
thing_id | string | 否 | 可选对象上下文,仅作用于本次事件分发。 |
路由级必填矩阵
Section titled “路由级必填矩阵”| 路由 | 业务硬必填字段 |
|---|---|
/event/create | title、status、message、severity、event_time |
/event/update | event_id、status、message、severity、event_time |
/event/close | event_id、status、message、severity、event_time |
| 字段 | 类型 | 必填 | 规则 |
|---|---|---|---|
event_id | string | 更新/关闭必填 | 创建时不能传;由网关生成。 |
title | string | 仅创建必填 | 更新/关闭可选。 |
description | string | 否 | 空字符串会按缺省处理。 |
status | string | 创建/更新/关闭必填 | 非空,最大 24 字符。 |
message | string | 创建/更新/关闭必填 | 非空,最大 512 字符。 |
severity | string | 创建/更新/关闭必填 | 仅允许 critical/high/normal/low。 |
event_time | number | 是 | Unix 秒时间戳,作为本次事件分发的发生时间。 |
started_at | number | 否 | 仅 create 允许。 |
ended_at | number | 否 | 仅 close 允许。 |
tags | string[] | 否 | 最多 32 项,每项最多 64 字符,trim 后去重。 |
images | string[] | 否 | 最多 32 项,每项最多 2048 字符,trim 后去重。 |
attrs | object | 否 | 对象补丁;value 为 null 表示删键;不允许数组。 |
metadata | object | 否 | 仅支持标量值(string/number/bool),key <= 64,value <= 512。 |
curl -X POST https://gateway.pushgo.cn/event/create \ -H "Content-Type: application/json" \ -d '{ "channel_id": "06J0FZG1Y8XGG14VTQ4Y3G10MR", "password": "pass-1234", "title": "数据库延迟", "status": "ongoing", "message": "从库延迟超过 30 秒", "severity": "high", "event_time": 1713750000, "started_at": 1713750000 }'{ "success": true, "data": { "channel_id": "06J0FZG1Y8XGG14VTQ4Y3G10MR", "op_id": "op-20260422-001", "event_id": "8a1fc4b3d9f04fd2857f92f66f7cc5d1", "thing_id": null, "accepted": true }, "error": null, "error_code": null}