创建通知策略
接口说明
在指定工作空间下创建通知策略。请求体 NotifyPolicyConfig 中 notifyStrategy 为必填,subscription 与 responsePlan 可选。创建成功后返回生成的策略 uuid 及完整策略详情。同一工作空间下策略名称重复将返回 ConflictName。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
POST /api/eventbase/notify-policy/create HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| workspace |
string |
是 |
工作空间 ID,用于隔离不同业务空间的通知策略资源。 |
default-cms-xxxx-cn-hangzhou |
| body | NotifyPolicyConfig |
否 |
请求 Body,通知策略完整配置对象 NotifyPolicyConfig。 |
body(NotifyPolicyConfig)为策略完整配置:notifyStrategy 定义分组合并与通知路由渠道,subscription 定义事件过滤与订阅范围,responsePlan 定义升级与行动集成。channelType 取值须为大写枚举(DING/WEIXIN/FEISHU/WEBHOOK/CONTACT 等);dayInWeek 取值 0-6(0=周日)。
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| requestId |
string |
本次请求的唯一 ID,用于问题排查与工单定位。 |
0B9377D9-C56B-5C2E-A8A4-A01D6CC3F4B8 |
| notifyPolicy | NotifyPolicy |
通知策略对象详情,包含策略 uuid、名称、描述、启用状态,及通知策略(分组合并、通知路由、渠道)、订阅(事件过滤、跨 workspace 路由、老产品事件订阅)、响应计划(升级、重复通知、自动恢复、行动集成)等子实体。 |
示例
正常返回示例
JSON格式
{
"requestId": "0B9377D9-C56B-5C2E-A8A4-A01D6CC3F4B8",
"notifyPolicy": {
"uuid": "04779a183add4f2ca06ab440f16cc580",
"name": "生产环境告警通知策略",
"description": "生产环境告警通知策略",
"enabled": true,
"version": 1,
"workspace": "default-cms-xxxx-cn-hangzhou",
"userId": "1234567890123456",
"createTime": "1710000000000",
"updateTime": "1710000000000",
"notifyStrategy": {
"description": "生产环境告警通知策略",
"ignoreRestoredNotification": true,
"groupingSetting": {
"groupingKeys": [
"alertname"
],
"periodMin": 0,
"silenceSec": 0,
"times": 0
},
"routes": [
{
"channels": [
{
"channelType": "WEBHOOK",
"enabledSubChannels": [
"EMAIL"
],
"receivers": [
"webhook-uuid-xxx"
]
}
],
"effectTimeRange": {
"dayInWeek": [
0
],
"startTimeInMinute": 0,
"endTimeInMinute": 1439,
"timeZone": "Asia/Shanghai"
},
"filterSetting": {
"expression": "1 and 2 or 3",
"conditions": [
{
"op": "EQ",
"field": "severity",
"value": "CRITICAL"
}
],
"relation": "AND"
},
"digitalEmployeeName": "数字员工名",
"enableRca": false
}
],
"customTemplateEntries": [
{
"templateUuid": "template-uuid-xxx"
}
]
},
"subscription": {
"filterSetting": {
"expression": "1 and 2 or 3",
"conditions": [
{
"op": "EQ",
"field": "severity",
"value": "CRITICAL"
}
],
"relation": "AND"
},
"workspaceFilterSetting": {
"tagSelector": {
"expression": "1 and 2 or 3",
"conditions": [
{
"op": "EQ",
"field": "severity",
"value": "CRITICAL"
}
],
"relation": "AND"
},
"workspaceUuids": [
"\"ws-abc123\""
]
},
"subscribeLegacyEvent": false
},
"responsePlan": {
"escalationId": [
"esc-uuid-xxx"
],
"repeatNotifySetting": {
"endIncidentState": "RECOVERED",
"repeatInterval": 300
},
"autoRecoverSeconds": 300,
"pushingSetting": {
"alertActionIds": [
"action-uuid-xxx"
],
"restoreActionIds": [
"action-uuid-yyy"
]
}
}
}
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | InvalidParameterValue | Illegal parameters. | 参数错误。 |
| 500 | InternalUnknownError | The request processing has failed due to some unknown error. | 服务运行错误。 |
| 403 | Forbidden | You are not authorized to operate the specified resource. | 没有权限,请使用RAM进行授权 |
| 404 | ResourceNotFound | The specified resource is not found. | 未找到指定资源。 |
| 409 | ConflictName | The specified name conflicts with an existing resource. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。