Test a subscription with the Notification API

This is for:

System Administrator
In this article

The Notification API allows you to test a subscription, meaning that it can send a mock notification to its specified service URL, or to its recipient email address. Testing a subscription can be useful if you need to know what its actual notifications may look like.

Use the Test a subscription for organization to test an administration level subscription, or use the Test a subscription for current user to test a user level subscription.

Request template

POST https://platform.cloud.coveo.com/rest/organizations/<MyOrganizationId>/subscriptions/<MySubscriptionId>/test HTTP/1.1

or

POST https://platform.cloud.coveo.com/rest/organizations/<MyOrganizationId>/subscriptions/me/<MySubscriptionId>/test HTTP/1.1
 
Content-Type: application/json
Accept: application/json
Authorization: Bearer <MyOAuth2Token>

Use the https://platform.cloud.coveo.com/rest/organizations/<MyOrganizationId>/subscriptions request path to test an administrator subscription.

Use the https://platform.cloud.coveo.com/rest/organizations/<MyOrganizationId>/subscriptions/me request path to test a user subscription.

In the selected request path:

  • Replace <MyOrganizationId> with the actual ID of the Coveo organization hosting the subscription (see Retrieve the organization ID).

  • Replace <MySubscriptionId> with the actual ID of the subscription to test.

In the Authorization HTTP header:

  • If you’re testing an administrator subscription:
    • Replace <MyOAuth2Token> with a Coveo access token that grants you the Subscriptions - Edit privilege in the target Coveo organization, if not already done.
  • If you’re testing a user subscription:

    • Replace <MyOAuth2Token> with a Coveo access token that grants you the Activities - View privilege in the target Coveo organization, if not already done.

See:

It’s impossible to authenticate either of these calls using an API key, since the service needs to be able to retrieve an email address from the access token in order to test the subscription.

A successful response (204 No Content) has no content, but indicates that the service has successfully received the request.

  • A successful response doesn’t imply that the mock notification was actually sent to, or received by the subscription recipient.

  • Subscription statistics data is logged as usual for mock notifications.

  • Each test you perform on an "EMAIL" or "EMAIL_JSON" subscription counts against the daily email notifications limit of the Coveo organization hosting the subscription.

Assuming that the service successfully processes and sends the mock notification:

  • If you’re testing an "EMAIL" subscription, the subscription recipient should receive a user-friendly email notification such as:

  • If you’re testing an "EMAIL_JSON" subscription, the subscription recipient should receive an un-formatted email notification with mock JSON data such as:

      {
        "id" : "vr5h2iu3xp3sifbptrxovc2mkq",
        "operation" : "REBUILD",
        "state" : "EXECUTED",
        "result" : "ERROR",
        "content" : { },
        "createDate" : 1511371291987,
        "startDate" : 1511371291987,
        "triggeredBy" : {
          "displayName" : "asmith@example.com-google"
        },
        "organizationId" : "mycoveocloudv2organizationg8tp8wu3",
        "resourceName" : "Generated test activity",
        "resourceType" : "SOURCE"
      }
    
  • If you’re testing a "WEB_HOOK" subscription, the same mock JSON data will be used as the body of an HTTP POST request against the serviceUrl specified in the tested subscription configuration.

Sample request

Testing an administrator subscription

POST https://platform.cloud.coveo.com/rest/organizations/mycoveocloudv2organizationg8tp8wu3/subscriptions/vr5h2iu3xp3sifbptrxovc2mkq/test HTTP/1.1
 
Content-Type: application/json
Accept: application/json
Authorization: Bearer **********-****-****-****-************

Successful response - 204 No Content

{}