Use the following APIs to create, update, get, and delete notification definitions.
Create a Notification Definition
- Required Permissions
-
You must have the Create Notification Definition permission to perform this operation.
- API
- /api/notification-definitions
- Method
- POST
- Required Parameters
-
Name Description name string
Name of the notification definition. (Mandatory) description string
Description of the notification definition. (Optional) httpParameters json
It is mandatory to include one of the following options, but not both:http_parameters
email_parameters
If the notification definition's protocol is HTTP, then httpParameters is mandatory.
It includes the following fields:relativePath
string : The relative API endpoint where the notifications are to be delivered.
headers
json : The list of headers that is expected by the API endpoint.
key
string: Header key.
value
string: Header value.
payloadTemplate
string: The custom REST template for receiving notifications.
retrySchedule
retryInterval
: The retry interval in milliseconds.maxRetryCount
: The maximum number of times to retry.requestTimeout
: The response wait time in milliseconds.
sslTlsVersionNO_CERT
: Use this option if the REST server is non-TLS.TLS1_2
: Use this option if the REST server is TLS.
host
Hostname or IP address of the REST server. (Mandatory)
port
Port number of the REST server. (Mandatory)
certificate
Certificate of the REST server.
Mandatory if sslTlsVersion is other than
NO_CERT
.authenticationTypeNO_AUTH
: Use this option if the REST server does not require any authentication.BASIC
: Use this option if the REST server requires basic authentication.
username
User name is mandatory if authenticationType is
BASIC
.password
Password is mandatory if authenticationType is
BASIC
.emailParameters json
It is mandatory to include one of the following options, but not both:http_parameters
email_parameters
emailParameters is mandatory for sending email notifications. It consists of the following fields:emailRecipients
: Consists of a list of email recipients. It is mandatory to enter at least one recipient.emailSubjectTemplate
: Consists of the email subject. You can derive the keys from the Create Default Template API.emailBodyTemplate
: Consists of the email body.senderEmailAddress
: Consists of the sender's email address.senderName
: Consists of the sender's name.
schedulerepeatInterval
: The repeat interval in milliseconds.maxRepetition
: The maximum number of repetitions.
onFailure string
The definition id for which the instance gets triggered if the notification for the current definition has a FAILED status. onSuccess string
The definition id for which the instance gets triggered if the notification for the current definition has a SENT status. onCompletion string
The definition id for which the instance gets triggered irrespective of the status of the instance for the current definition. protocol HTTP
Use the
HTTP
protocol to notify to an HTTP REST server.-
SMTP
Use the
SMTP
protocol to notify using Emails
- Input Example for HTTP Notification Definition
- Input Example for SMTP or Email Notification Definition
-
{ "name": "Email", "description": "Email Definition", "protocol": "SMTP", "emailParameters": { "senderEmailAddress": "[email protected]", "senderName": "svc.pulse-notify", "emailSubjectTemplate": "Notification for Alert ${alertState}", "emailRecipients": [ "[email protected]" ], "schedule": { "repeatInterval": 120000, "maxRepetition": 5 } } }
- Response
-
{ "id": "5bf29d8178d80c88c89df352" }
Get Notification Definition
- Required Permissions
-
You must have the View Notification Definition permission to perform this operation.
- API
- /api/notification-definitions/{id}
- Method
- GET
- Required Parameters
- None
- Sample Response
-
{ "id": "5bf29d8178d80c88c89df352", "name": "SampleHttpNotificationDefinition", "description": "This is a sample notification definition", "httpParameters": { "relativePath": "/callback", "headers": [ { "key": "Content-Type", "value": "application/json" } ] }, "retryCount": 2, "tenantId": "5beaa559a40a82f457340c4d", "createdTime": "1542470980533", "lastUpdatedTime": "1542470980533", "createdBy": "[email protected]", "lastUpdatedBy": "[email protected]", "updateVersion": 1 "payloadTemplate": "{\"description\" : \"${description} \",\"deviceTemplateId\" : \"${deviceTemplateId}\",\"deviceId\" : \"$ {deviceId}\",\"triggerCount\": \"${triggerCount}\"}" } }
Update Notification Definition
- Required Permissions
-
You must have the Edit Notification Definition permission to perform this operation.
- API
- /api/notification-definitions/{id}
- Method
- PUT
- Required Parameters
-
Name Description id string
Notification definition ID. (Mandatory) name string
Name of the notification definition. (Optional) description string
Description of the notification definition. (Optional) httpParameters json
If the notification definition's protocol is HTTP, then httpParameters is mandatory.
You cannot edit the protocol type.
It includes the following fields:retrySchedulerelativePath
string : The relative API endpoint where the notifications are to be delivered.
headers
json : The list of headers that is expected by the API endpoint.
key
string: Header key.
value
string: Header value.
payloadTemplate
string: The custom REST template for receiving notifications.
retryInterval
: The retry interval in milliseconds.maxRetryCount
: The maximum number of times to retry.requestTimeout
: The response wait time in milliseconds.
sslTlsVersionNO_CERT
: Use this option if the REST server is non-TLS.TLS1_2
: Use this option if the REST server is TLS.
host
Hostname or IP address of the REST server. (Mandatory)
port
Port number of the REST server. (Mandatory)
certificate
Certificate of the REST server.
authenticationTypeNO_AUTH
: Use this option if the REST server does not require any authentication.BASIC
: Use this option if the REST server requires basic authentication.
username
User name is mandatory if authenticationType is
BASIC
.password
Password is mandatory if authenticationType is
BASIC
.emailParameters json
You cannot edit the protocol type.
emailParameters is mandatory for sending email notifications.It consists of the following fields:scheduleemailRecipients
: Consists of a list of email recipients. It is mandatory to enter at least one recipient.emailSubjectTemplate
: Consists of the email subject. You can derive the keys from the Create Default Template API.emailBodyTemplate
: Consists of the email body.senderEmailAddress
: Consists of the sender's email address.senderName
: Consists of the sender's name.
repeatInterval
: The repeat interval in milliseconds.maxRepetition
: The maximum number of repetitions.
onFailure string
The definition id for which the instance gets triggered if the notification for the current definition has a FAILED status. onSuccess string
The definition id for which the instance gets triggered if the notification for the current definition has a SENT status. onCompletion string
The definition id for which the instance gets triggered irrespective of the status of the instance for the current definition. - Input Example for HTTP Update Notification Definition
-
{ "name": "SampleHttpNotificationDefinition", "description": "This is a sample HTTP Notification Definition", "httpParameters": { "headers": [{ "key": "content-type", "value": "application/json" }], "relativePath": "/basicauth/notification", "retrySchedule": { "retryInterval": 5000, "maxRetryCount": 1, "requestTimeout": 5000 } }, "onFailure": "b6ece001-88d6-4300-aca8-9d515fd906c8", "onSuccess": "7024eb44-b5ec-47c0-9264-51015a2917a6", "onCompletion": "7024eb44-b5ec-47c0-9264-51015a2917a6" }
- Input Example for SMTP Update Notification Definition
-
{ "name": "SampleSmtpNotificationDefinition", "description": "This is a sample Smtp Notification Definition", "emailParameters": { "senderEmailAddress": "[email protected]", "senderName": "Sample name", "emailRecipients": [ "[email protected]" ], "schedule": { "repeatInterval": 0, //Time in milliseconds "maxRepetition": 0 //Time in milliseconds } } }
- Response
-
{ "id": "5bf29d8178d80c88c89df352" }
Delete Notification Definition
List All Notification Definitions
- Required Permissions
-
You must have the View Notification Definition permission to perform this operation.
- API
- /api/notification-definitions
- Method
- GET
- Required Parameters
- None
- Response
-
{ "notificationDefinitions": [ { "id": "5bf29d8243d80c88c25an910", "name": "SampleSmtpNotificationDefinition", "description": "This is a sample notification definition", "emailParameters": { "emailRecipients": [ "[email protected]", "[email protected]" ], "senderEmailAddress": "[email protected]", "senderName": "User 3", "emailSubjectTemplate": "Notification for Alert ${alertState}", "emailBodyTemplate": "<html lang=\"en\"> Notification for alert ${alertDefinitionId} </html>" }, "tenantId": "5beaa559a40a82f457340c4d", "createdTime": "1542626689123", "lastUpdatedTime": "1542626689123", "createdBy": "[email protected]", "lastUpdatedBy": "[email protected]", "updateVersion": 1 }, { "id": "5bf29d8178d80c88c89df352", "name": "SampleHttpNotificationDefinition", "description": "This is a sample notification definition", "httpParameters": { "relativePath": "/callback", "headers": [ { "key": "Content-Type", "value": "application/json" } ], "payloadTemplate": "{\"description\" : \"${description} \",\"deviceTemplateId\" : \"${deviceTemplateId}\",\"deviceId\" : \"$ {deviceId}\",\"triggerCount\": \"${triggerCount}\"}" }, "retryCount": 1, "tenantId": "5beaa559a40a82f457340c4d", "createdTime": "1542622551030", "lastUpdatedTime": "1542622551030", "createdBy": "[email protected]", "lastUpdatedBy": "[email protected]", "updateVersion": 1 } ], "pageInfo": { "page": 1, "pageSize": 10, "totalElements": "2", "totalPages": "1" } }
Get Template
- API
- /api/notification-templates
- Method
- GET
- Required Parameters
-
type
. For example,/api/notification-templates?type=default
- Response
-
{ "templateKeys": [ { "key": "entityType", "description": "Entity type like Alert, campaign for which notification is generated" }, { "key": "alertSeverity", "description": "Alert severity defined in the alert definition." }, { "key": "triggersMetricName", "description": "Metric name for which alert was triggered" }, { "key": "description", "description": "Description of alert" }, { "key": "recommendation", "description": "Defined in alert definition who takes remediation steps for user" }, { "key": "entityId", "description": "Id of the generated alert" }, { "key": "alertTemplate", "description": "Alert template selected by user" }, { "key": "notificationInstanceId", "description": "Id of notification instance created for this alert" }, { "key": "deviceId", "description": "Device Id for which alert is generated" }, { "key": "triggersTimeMs", "description": "Time for which alert was triggered" }, { "key": "triggerCount", "description": "No of times metric exceeded the threshold which results in triggering alert" }, { "key": "duration", "description": "Duration (in sec) of absence of metrics from offline alert triggering device" }, { "key": "lambda", "description": "Threshold value for triggering alert" }, { "key": "cancelCount", "description": "Count of consecutive ingestion on which the alert cancellation will take place" }, { "key": "entityState", "description": "Present state of the entity like active, user_acknowledged etc" }, { "key": "entityName", "description": "Entity name for which notification is generated" }, { "key": "deviceTemplateId", "description": "ID of device template" }, { "key": "createdTime", "description": "Time at which alert was created" }, { "key": "lastUpdatedTime", "description": "Last time when alert was updated" }, { "key": "metrics", "description": "List of metrics on a threshold alert symptom" }, { "key": "alertDefinitionId", "description": "alert definition id" }, { "key": "triggersValue", "description": "The value which caused the triggering of alert" }, { "key": "userAcknowledged", "description": "User who acknowledged the alert" } ], "subject": "${entityType} ${entityState} Notification for ${entityType} ${entityName}(${entityId})", "default.alert.body.template": "<html lang=\"en\"> <head> <meta charset=\"UTF-8\"> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> <meta http-equiv=\"Content-Type\" content=\"text/html\"> <link rel=\" stylesheet\" href=\"https://unpkg.com/[email protected]/clarity-ui.min.css\"> </head> <body style=\"word-wrap:break-word;-webkit-nbsp-mode:space;color:rgb(0,0,0)\"> <div xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\"> <style type=\"text/css\" media=\"all\"> @font-face { font-family: 'subjectFont'; src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Light.otf') format('opentype'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Light.ttf') format('truetype'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Light.woff') format('woff'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Light.woff2') format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'bodyFont'; src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Regular.otf') format('opentype'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Regular.ttf') format('truetype'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Regular.woff') format('woff'); src: url('https://console.cloud.vmware.com/csp/gateway/portal/assets/fonts/Metropolis/Metropolis-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; } .wrapper-container { overflow-wrap: normal; background-color: #fafafa; /*gray color*/ } .container { max-width: 600px; margin: 0 auto; background-color: #ffffff; /*white color*/ } .csp-header { font-family: 'subjectFont', Helvetica, Arial, sans-serif; font-size: 23px; padding: 24px