CreateNotifyPolicy

Updated at:

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:CreateNotifyPolicy

create

*Workspace

acs:cms:{#regionId}:{#accountId}:workspace/{#WorkspaceName}

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.