跳转到内容

事件 API (Event)

事件 API 使用以下三个入口:

  • POST /event/create
  • POST /event/update
  • POST /event/close
  • 请求体必须是 JSON。
  • 请求模型为严格解析,未声明字段会直接报错(400)。
  • Authorization: Bearer <token> 仅在网关开启鉴权时必填。
字段类型必填说明
channel_idstring目标频道 ID。
passwordstring频道密码,长度 8-128。
op_idstring幂等键;不传则网关自动生成并在响应回传。
thing_idstring可选对象上下文,仅作用于本次事件分发。
路由业务硬必填字段
/event/createtitlestatusmessageseverityevent_time
/event/updateevent_idstatusmessageseverityevent_time
/event/closeevent_idstatusmessageseverityevent_time
字段类型必填规则
event_idstring更新/关闭必填创建时不能传;由网关生成。
titlestring仅创建必填更新/关闭可选。
descriptionstring空字符串会按缺省处理。
statusstring创建/更新/关闭必填非空,最大 24 字符。
messagestring创建/更新/关闭必填非空,最大 512 字符。
severitystring创建/更新/关闭必填仅允许 critical/high/normal/low
event_timenumberUnix 秒时间戳,作为本次事件分发的发生时间。
started_atnumbercreate 允许。
ended_atnumberclose 允许。
tagsstring[]最多 32 项,每项最多 64 字符,trim 后去重。
imagesstring[]最多 32 项,每项最多 2048 字符,trim 后去重。
attrsobject对象补丁;value 为 null 表示删键;不允许数组。
metadataobject仅支持标量值(string/number/bool),key <= 64,value <= 512。
Terminal window
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
}