Adds a contact for webhook alerts.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateWebhook

The operation that you want to perform. Set the value to CreateWebhook.

ContactName String Yes Webhook alert

The name of the contact.

Method String Yes Post

The HTTP request method.

  • Get
  • Post
Url String Yes https://oapi.dingtalk.com/robot/send?access_token=e1a049121ddbfce1ca963d115ef88cc7219583c4fb79fe6e398fbfb688******

The URL of the request method.

HttpParams String No [{"name":"mike"}]

The parameters in the HTTP request.

HttpHeaders String No [{"Content-Type":"application/json"}]

The HTTP request header.

RegionId String Yes cn-hangzhou

The region ID.

Body String Yes { "Alert name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notification policy":"{{ .dispatchRuleName }}", "Alert time":"{{ .startTime }}", "Alert content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

The notification template that is sent when an alert is triggered. This parameter is required if the Method parameter is set to Post. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length.

RecoverBody String No { "Alert name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notification policy":"{{ .dispatchRuleName }}", "Recovery time":"{{ .endTime }}", "Alert content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }

The notification template that is sent when an alert is resolved. This parameter is required if the Method parameter is set to Post. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length.

Response parameters

Parameter Type Example Description
ContactId String 48716

The ID of the contact for webhook alerts.

RequestId String 16AF921B-8187-489F-9913-43C808B4****

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateWebhook
&ContactName=Webhook alert
&Method=Post
&Url=https://oapi.dingtalk.com/robot/send?access_token=e1a049121ddbfce1ca963d115ef88cc7219583c4fb79fe6e398fbfb688******
&HttpParams=[{"name":"mike"}]
&HttpHeaders=[{"Content-Type":"application/json"}]
&RegionId=cn-hangzhou
&Body={ "Alert name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notificaiton policy":"{{ .dispatchRuleName }}", "Alert time:"{{ .startTime }}", "Notification content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
&RecoverBody={ "Alert name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notification policy":"{{ .dispatchRuleName }}", "Recovery time":"{{ .endTime }}", "Alert content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
&Common request parameters

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateWebhookResponse>
    <ContactId>48716</ContactId>
    <RequestId>16AF921B-8187-489F-9913-43C808B4****</RequestId>
</CreateWebhookResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ContactId" : 48716,
  "RequestId" : "16AF921B-8187-489F-9913-43C808B4****"
}