Create Subscription

Use this endpoint to create a Subscription. Subscriptions are created for existing callbacks. In the request body, you must specify the name of the new subscription, the name of the callback you are creating the subscription for, and the event types for the subscription.

A successful response returns information about the subscription.

Service URL:

/rest/api/v1.3/notifications/subscriptions

Request Method:

POST

Request Header:

Authorization=<AUTH_TOKEN>

Content-Type=application/json

Request Body - Required Properties:

name – The name of the subscription you want to create. This name must be unique.

callbackName – The name of the existing callback for which you want to associate with the subscription.

eventNames – Comma-separated list of fully qualified event names for which you want to receive event notifications for. You can retrieve a list of supported events using the Retrieve a List of Supported Events API.

filters - Optional. This is an array of filters that ensures a specific event is only triggered for certain campaigns. Contains an array of eventTypes and an array, values, of criteria to matched. As on 20D, the only supported criteria is a campaignNames array.

Sample Request Body

{
  "name": "<subscription_name>",
  "callBackName": "<callback_name>",
  "eventTypes": [
    "EMAIL_BOUNCED",
    "EMAIL_FAILED",
    "EMAIL_SKIPPED",
    "SMS_FAILED",
    "SMS_SKIPPED",
    "SMS_MO_FW_FAILED"
  ]
  "filters": [
    {
      "eventTypes": [
        "EMAIL_FAILED"
      ],
      "values": [
        {
          "campaignNames": [
            "vk_campaign_failed"
          ]
        }
      ]
    }
  ]
}

Sample Response Body - Success

{
  "subscriptionName": "<subscription_name>",
  "callBackUrl": "<callback_url>",
  "callBackName": "<callback_name>",
  "batchSize": <batchsize>,
  "eventTypes": [
    "EMAIL_BOUNCED",
    "EMAIL_FAILED",
    "EMAIL_SKIPPED",
    "SMS_FAILED",
    "SMS_SKIPPED",
    "SMS_MO_FW_FAILED"
  ],
  "status": "ACTIVE"
  "filters": [
    {
      "eventTypes": [
        "EMAIL_FAILED"
      ],
      "values": [
        {
          "campaignNames": [
            "vk_campaign_failed"
          ]
        }
      ]
    }
  ]
}

Sample Response Body - Failure

404 Not Found

Event type not supported: Requests fail if any events specified are not supported. The error resembles:

{
  "type": "",
  "title": "Object not found",
  "errorCode": "OBJECT_NOT_FOUND",
  "detail": "Event Type [ WEBPUSH_ ] not found or is not supported",
  "errorDetails": []
}

Invalid callback URL: Requests fail if the system cannot connect to the callback URL. Error resembles:

{
  "type": "",
  "title": "Invalid request parameters",
  "errorCode": "INVALID_PARAMETER",
  "detail": "Could not connect to callback url [<callback_url> ]",
  "errorDetails": []
}

Empty callback URL: Requests fail if a callback with the URL specified already exists. The error resembles:

{
  "type": "",
  "title": "Object not found",
  "errorCode": "OBJECT_NOT_FOUND",
  "detail": "Callback [<callback_name> ] not found ",
  "errorDetails": []
}

400 Bad Request

No events specified in the request: Requests fail if any events specified are not supported. The error resembles:

{
  "type": "",
  "title": "Invalid request parameters",
  "errorCode": "INVALID_PARAMETER",
  "detail": "Atleast one event type should be defined in the request",
  "errorDetails": []
}

Empty subscription name specified: Requests fail if any events specified are not supported. The error resembles:

{
  "type": "",
  "title": "Invalid request parameters",
  "errorCode": "INVALID_PARAMETER",
  "detail": "Subscription name is empty on null",
  "errorDetails": []
}

Subscription already active: Requests fail if any event types specified in the request are already active for the specified callback. If an active subscription already exists with any event types specified, update the current subscription instead. The error resembles:

{
  "type": "",
  "title": "Invalid request parameters",
  "errorCode": "INVALID_PARAMETER",
  "detail": "There's an active subscription for event [ EMAIL_FAILED ]",
  "errorDetails": []
}

Learn more

Retrieve a List of Supported Events

Event Responses