Consume ntm-subscribe-service

Subscribe service can be used to:

  1. Create a user or subscription to a channel with a keyword.
  2. Get a list of all subscriptions present for a channel.
  3. Get a list of application subscriptions created by an application.
  4. Get a list of user subscriptions created by a user.
  5. Delete a subscription by subscription id.
  6. Update Subscription Status.
  7. Get details of a subscription by subscription id.

userId: Identity of the user.

channelName: Name of the channel user/application wants to subscribe to. For the list of channels use Channel Service.

channelId: Unique identifier of the channel, user/application wants to subscribe to. For the list of channels use Channel Service.

keyword: Keyword works as a filter. Application/user will get messages with a title containing the keyword.

For example, if a user subscribes with the keyword "Contract", the user will get all the messages with a message title containing the keyword "Contract".

endpointUrl: Messages will be posted to this endpoint URL given by the subscriber. Please refer to Interpret a push notification for a template of the JSON data that will be pushed to this endpoint. For securing this endpoint, please refer to Secure Subscription Endpoint URL

context: Context in which a user is present.

Note:

  • The client identity used to create a subscription in NTM should add NTM Master client identity("* ntm-master-svc-ntm.slbservice.com*") under its approved-callers-list in Developer Portal.
  • This whitelisting will enable NTM to push notifications to the subscriber's endpoint URL seamlessly.
  • It takes around 20 mins for a new subscription to reflect in the system. Please ensure that you allow this time to the system before you can listen to a notification via your subscription.



Sample Requests:

POST: /subscription - for User

A Subscription ID will be generated after making a POST request, where this Subscription ID can be used to delete the subscription.

Mandatory fields for user subscription: [ userId, channelId, context, keyword ]

Sample cUrlSample Output
curl -X POST \
   'https://api.delfi.slb.com/ntm/v2/subscription' \
   -H 'Authorization: Bearer <your-user-exchanged-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache' \
   -H 'Content-Type: application/json' \
   -d '{
     "userId":"abc@slb.com",
     "channelId": "hg08cfa9-a0a4-4c7b-9882-1b3b93b4895b",
     "keyword": "Contract",
     "context": {
       "account": "Account A,
       "contract": "Contract C",
       "department": "Department D",
     }
   }'
{
   "Message": "fc08cfa9-a0a4-4c7b-9882-1b3b93b4895b"
}

POST: /subscription - for Application

A Subscription ID will be generated after making a POST request, where this Subscription ID can be used to delete the subscription.

Mandatory fields for application subscription: [ channelId, endpointUrl, context/account, keyword ]

Sample cUrlSample Output
curl -X POST \
   'https://api.delfi.slb.com/ntm/v2/subscription' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache' \
   -H 'Content-Type: application/json' \
   -d '{
     "channelId": "hg08cfa9-a0a4-4c7b-9882-1b3b93b4895b",
     "keyword": "Contract",
     "endpointUrl": "exampleendpointurl@example.com",
     "context": {
       "account": "Account A,
       "contract": "Contract C",
       "department": "Department D",
     }
   }'
{
   "Message": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9"
}

GET: /subscription

Gets the list of all subscriptions for a specific channel.

Sample cUrlSample Output
curl -X GET \
   'https://api.delfi.slb.com/ntm/v1/subscription?channelId=50fab0ce-5b25-400d-8408-af620e43a932' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache'
[
   {
     "channelID": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9",
     "channelName": "ntm",
     "contextAccount": "Account A",
     "contextContract": "Contract C",
     "endpointUrl": "exampleendpointurl@example.com",
     "keyword": "Contract",
     "sourceAppId": "ntm-master-svc-ntm.slbservice.com",
     "status": "approved",
     "subscriber": "ntm-master-svc-ntm.slbservice.com",
     "subscriptionId": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9"
   },
   {
     "channelID": "e3b0a2eb-8489-9351-d622-daf4fe94cd78",
     "channelName": "ntm",
     "contextAccount": "Account A",
     "contextContract": "Contract C",
     "endpointUrl": "exampleendpointurl@example.com",
     "keyword": "Contract",
     "sourceAppId": "ntm-master-svc-ntm.slbservice.com",
     "status": "approved",
     "subscriber": "abc@slb.com",
     "subscriptionId": "fc08cfa9-a0a4-4c7b-9882-1b3b93b4895b"
   }
]

GET: /subscription/application

Gets the list of all subscriptions made by an application.

Sample cUrlSample Output
curl -X GET \
   'https://api.delfi.slb.com/ntm/v1/subscription/application' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache'
[
   {
     "channelID": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9",
     "channelName": "ntm",
     "contextAccount": "Account A",
     "contextContract": "Contract C",
     "endpointUrl": "exampleendpointurl@example.com",
     "keyword": "Contract",
     "sourceAppId": "ntm-master-svc-ntm.slbservice.com",
     "status": "approved",
     "subscriber": "ntm-master-svc-ntm.slbservice.com",
     "subscriptionId": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9"
   }
]

GET: /subscription/user/{userId}

Gets the list of all subscriptions made by a user.

Sample cUrlSample Output
curl -X GET \
   'https://api.delfi.slb.com/ntm/v1/subscription/abc@slb.com' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache'
[
   {
     "channelID": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9",
     "channelName": "ntm",
     "contextAccount": "Account A",
     "contextContract": "Contract C",
     "endpointUrl": "exampleendpointurl@example.com",
     "keyword": "Contract",
     "sourceAppId": "ntm-master-svc-ntm.slbservice.com",
     "status": "approved",
     "subscriber": "abc@slb.com",
     "subscriptionId": "fc08cfa9-a0a4-4c7b-9882-1b3b93b4895b"
   }
]

DELETE: /subscription/{subscriptionId}

Deletes a subscription using Subscription ID.

Sample cUrlSample Output
curl -X DELETE \
   'https://api.delfi.slb.com/ntm/v1/subscription/4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache'
{
   "Message": "Subscription with ID fc08cfa9-a0a4-4c7b-9882-1b3b93b4895b is deleted."
}

PUT: /subscription/{subscriptionId}/status

Updates an existing subscription status based on subscriptionId. You can only Update this details of a subscription by using a private clientID.

status values can be: [ approved, denied, revoked ]

Sample cUrlSample Output
curl -X PUT \
   'https://api.delfi.slb.com/ntm/v1/subscription/4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9/status' \
   -H 'Authorization: Bearer <your-user-exchanged-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache' \
   -H 'Content-Type: application/json' \
   -d '{
     "status": "approved"
     }
   }'
{
   "Message": "User subscription status updated"
}

GET: /subscription/{subscriptionId}

Get details of a subscription based on subscriptionId. You can access subscription details only for subscriptions, created for your application, or created by your application as a subscriber.

Sample cUrlSample Output
curl -X GET \
   'https://api.delfi.slb.com/ntm/subscribe/v1/subscription/4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9' \
   -H 'Authorization: Bearer <your-ccg-token>' \
   -H 'AppKey: <your-appkey>' \
   -H 'Cache-Control: no-cache' \
   -H 'Content-Type: application/json' \
   }'
{
     "channelID": "806ad674-db3d-44ab-8d73-d02fd632b385",
     "channelName": "ntm",
     "contextAccount": "Account A",
     "contextDepartment": "Department A",
     "contextContract": "Contract C",
     "endpointUrl": "exampleendpointurl@example.com",
     "keyword": "Contract",
     "sourceAppId": "ntm-master-svc-ntm.slbservice.com",
     "status": "approved",
     "subscriber": "ntm-master-svc-ntm.slbservice.com",
     "subscriptionId": "4bd2a2eb-4045-4ee2-b31f-4cd78daf4fe9"
   }