CreateNotifyPolicy
Creates a notification policy.
Operation description
Creates a notification policy in a specified workspace. In the NotifyPolicyConfig request body, notifyStrategy is required, while subscription and responsePlan are optional. Upon successful creation, the generated policy UUID and complete policy details are returned. If a duplicate Policy Name exists in the same workspace, ConflictName is returned.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:CreateNotifyPolicy |
create |
*Workspace
|
None | None |
Request syntax
POST /api/eventbase/notify-policy/create HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| workspace |
string |
Yes |
The workspace ID, which is used to isolate notification policy resources for different business workspaces. |
default-cms-xxxx-cn-hangzhou |
| body | NotifyPolicyConfig |
No |
The request body, which is the complete configuration object NotifyPolicyConfig for the notification policy. |
The body (NotifyPolicyConfig) contains the complete configuration for the policy. notifyStrategy defines grouping, merging, and notification routing channels. subscription defines event filtering and subscription scopes. responsePlan defines escalation and action integration. The value of channelType must be an uppercase enumeration value, such as DING, WEIXIN, FEISHU, WEBHOOK, or CONTACT. The value of dayInWeek ranges from 0 to 6, where 0 indicates Sunday.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| requestId |
string |
The unique ID of the request, which is used for troubleshooting and ticket tracking. |
0B9377D9-C56B-5C2E-A8A4-A01D6CC3F4B8 |
| notifyPolicy | NotifyPolicy |
The details of the notification policy object, including the policy UUID, name, description, and enabled status, as well as sub-entities such as the notification policy (grouping and merging, notification routing, and channels), subscription (event filtering, cross-workspace routing, and legacy product event subscription), and response plan (escalation, repeated notifications, automatic recovery, and action integration). |
Examples
Success response
JSON format
{
"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": "Production environment alert notification policy",
"ignoreRestoredNotification": true,
"groupingSetting": {
"groupingKeys": [
"alertname"
],
"periodMin": 0,
"silenceSec": 0,
"times": 0
},
"routes": [
{
"channels": [
{
"channelType": "DING",
"enabledSubChannels": [
"EMAIL"
],
"receivers": [
"webhook-uuid-xxx"
]
}
],
"effectTimeRange": {
"dayInWeek": [
0
],
"startTimeInMinute": 0,
"endTimeInMinute": 1439,
"timeZone": "Asia/Shanghai"
},
"filterSetting": {
"conditions": [
{
"field": "labels.alertname\t",
"op": "EQ",
"value": "CRITICAL"
}
],
"expression": "1 and 2 or 3",
"relation": "AND"
},
"digitalEmployeeName": "Digital employee name",
"enableRca": false
}
],
"customTemplateEntries": [
{
"templateUuid": "template-uuid-xxx"
}
]
},
"subscription": {
"filterSetting": {
"conditions": [
{
"field": "labels.alertname\t",
"op": "EQ",
"value": "CRITICAL"
}
],
"expression": "1 and 2 or 3",
"relation": "AND"
},
"workspaceFilterSetting": {
"tagSelector": {
"conditions": [
{
"field": "labels.alertname\t",
"op": "EQ",
"value": "CRITICAL"
}
],
"expression": "1 and 2 or 3",
"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"
]
}
}
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameterValue | Illegal parameters. | Illegal parameters. |
| 500 | InternalUnknownError | The request processing has failed due to some unknown error. | A service runtime error occurred. |
| 403 | Forbidden | You are not authorized to operate the specified resource. | No permission, please use RAM to authorize |
| 404 | ResourceNotFound | The specified resource is not found. | The specified resource is not found. |
| 409 | ConflictName | The specified name conflicts with an existing resource. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.