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)
notificationDestinationId

string

Notification destination ID. Mandatory for HTTP endpoints.
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.

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.
Input Example for HTTP Notification Definition
{
    "name": "SampleSmtpNotificationDefinition",
    "description": "This is a sample Smtp Notification Definition",
    "emailParameters": {
        "emailRecipients": [
            "user1@gmail.com",
            "user2@gmail.com"
        ],
        "senderEmailAddress": "user3@gmail.com",
        "senderName": "User 3",
        "emailSubjectTemplate": "Notification for Alert ${alertState}",
        "emailBodyTemplate": "<html lang=\"en\"> Notification for alert ${alertDefinitionId} </html>"
    }
}
Input Example for SMTP Notification Definition
{
  "name": "SampleSmtpNotificationDefinition",
  "description": "This is a sample Smtp Notification Definition",
  "emailParameters": {
    "emailRecipients": [
      "user1@gmail.com",
      "user2@gmail.com"
    ]
  }
}
}
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",
  "notificationDestinationId": "5bf29d8178d80c88c25ed713",
  "httpParameters": {
    "relativePath": "/callback",
    "headers": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ]
  },
  "retryCount": 2,
  "tenantId": "5beaa559a40a82f457340c4d",
  "createdTime": "1542470980533",
  "lastUpdatedTime": "1542470980533",
  "createdBy": "sysadmin@vmware.com",
  "lastUpdatedBy": "sysadmin@vmware.com",
  "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)
notificationDestinationId

string

Notification destination ID. (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:
  • 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.

emailParameters

json

You cannot edit the protocol type.

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.
Input Example for HTTP Update Notification Definition
{
  "id": "5bf29d8178d80c88c89df352",
  "description": "This is an updated sample HTTP Notification Definition",
  "notificationDestinationId": "5bf29d8178d80c88c25ed713",
  "retryCount": 2
}
Input Example for SMTP Update Notification Definition
{
  "id": "5bf29d8243d80c88c25an910",
  "description": "This is an updated sample Smtp Notification Definition",
  "notificationDestinationId": "9as29d8178d91c88c25sx670",
}

Response
{
  "id": "5bf29d8178d80c88c89df352"
}

Delete Notification Definition

Required Permissions

You must have the Delete Notification Definition permission to perform this operation.

API
/api/notification-definitions/{id}
Method
DELETE
Required Parameters
Name Description
id

string

Notification definition ID.
Response
{}

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",
      "notificationDestinationId": "9as29d8178d91c88c25sx670",
      "emailParameters": {
        "emailRecipients": [
          "user1@gmail.com",
          "user2@gmail.com"
        ],
      "senderEmailAddress": "user3@gmail.com",
        "senderName": "User 3",
        "emailSubjectTemplate": "Notification for Alert ${alertState}",
        "emailBodyTemplate": "<html lang=\"en\"> Notification for alert ${alertDefinitionId} </html>"
      },
      "tenantId": "5beaa559a40a82f457340c4d",
      "createdTime": "1542626689123",
      "lastUpdatedTime": "1542626689123",
      "createdBy": "sysadmin@vmware.com",
      "lastUpdatedBy": "sysadmin@vmware.com",
      "updateVersion": 1
    },
    {
      "id": "5bf29d8178d80c88c89df352",
      "name": "SampleHttpNotificationDefinition",
      "description": "This is a sample notification definition",
      "notificationDestinationId": "5bf29d8178d80c88c25ed713",
      "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": "sysadmin@vmware.com",
      "lastUpdatedBy": "sysadmin@vmware.com",
      "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/clarity-ui@0.9.8/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