Notifications
#
Available NotificationsCurrently Truphone Connect supports notifications via a webhook registration. This process is not global for all SIMs and therefore each SIM object will need to be registered in order to receive its notifications.
Currently Connect provides support for two types of notifications: SUBSCRITPION_END
and USAGE_THRESHOLD
.
#
Usage Threshold Payload ExampleThese type of notifications are triggered upon 80% of usage is reached.
{ "id": "1234-56789", "type": "USAGE_THRESHOLD", "iccid": "893000000002391231", "subscription_id": "ZHNhc2Rhc2Q=", "threshold": 80}
#
Subscription End Payload ExampleThese type of notifications are triggered upon full depletion of a plan or when it passes its expiration date.
{ "id": "1234-56789", "type": "SUBSCRIPTION_END", "iccid": "893000000002391231", "subscription_id": "ZHNhc2Rhc2Q="}
#
1. Registering WebhookIn order to receive notifications the first step is to register a webhook onto a SIM resource passing the intended notification type. Currently, only one request per type is supported.
Note: Currently notification work per SIM resource so each SIM needs to be registered to have a webhook, the webhook URL can be the same across all the SIMs
#
Example Requestcurl -X POST \ https://services.truphone.com/connect-api/v1/sim/8944474600000109251/preferences/notifications/SUBSCRIPTION_END \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -H 'X-Correlation-ID: unique-id-from-requester-123' -d '{ "webhook_url": "http://acme-flights.com/notifications/handler" }'
#
2. Receiving NotificationWhen the events happen a payload will be sent to the registered webhook.
#
Example Payload{ "id": "1234-56789", "type": "SUBSCRIPTION_END", "iccid": "893000000002391231", "subscription_id": "ZHNhc2Rhc2Q="}
#
3. Unregistering WebhookAt any time, it's possible to stop receiving notifications for any specific SIM using the delete SIM preferences API
#
Example Requestcurl -X DELETE \ https://services.truphone.com/connect-api/v1/sim/8944474600000109251/preferences/notifications/SUBSCRIPTION_END \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -H 'X-Correlation-ID: unique-id-from-requester-123'