10DLC Callbacks
Registering your number with 10DLC requires you to interact with different Plivo APIs.
For every Brand, Campaign, Number Linking, and Number Unlinking request you send, Plivo sends a status update to a URL you configure as a callback. You can store this information on your server for delivery status analysis.
The webhooks you integrate with Plivo are triggered by changes in the status of Brand, Campaign, or Number requests (e.g. successful registration of your brand with TCR). Upon one of these events, Plivo makes an HTTP request (POST or GET) to the endpoint URL you’ve configured for the webhook. To handle a webhook, you must create a listener (web app) that can accept these HTTP requests from Plivo.
Create Brand
Create Campaign
Link Number
Unlink Number
Handle callbacks in your web app
To handle callbacks in your application, your endpoint should capture HTTP requests and respond to them. When Plivo sends the HTTP request callbacks to the webhook during an event, you should capture the request (POST or GET based on the method you’ve defined for the URL) and respond with a 200 OK response. You can store the callback data in your database.
Note: Plivo automatically retries webhooks three times if an HTTP 200 status code is not returned: *First at 60 seconds after the original attempt. *Second at 120 seconds after the first retry attempt. *Third at 240 seconds after the second retry attempt.
Possible status values
Endpoint | Status | Explanation |
---|---|---|
brand | created | Brand creation request was submitted to TCR for processing. |
rejected | Brand creation was rejected by TCR. Reach out to our support team to learn why. | |
registered | Brand was registered with TCR. You can now create campaigns using this brand. | |
campaign | created | Campaign creation request was submitted to TCR for processing. |
rejected | Campaign creation request was rejected by TCR. Reach out to our support team to learn why. | |
registered | Campaign was registered with TCR. You can now link your Plivo long codes with this campaign. | |
number_linking | created | Request to link your Plivo long code with the campaign was submitted to operators. |
failed | Request to link your Plivo long code with the campaign was rejected by operators. Retry the request; if the issue persists, contact our support team. | |
success | Request to link your Plivo long code with the campaign was processed by operators. | |
number_unlinking | created | Request to unlink your Plivo long code with the campaign was submitted to operators. |
failed | Request to unlink your Plivo long code with the campaign was rejected by operators. Retry the request; if the issue persists, contact our support team. | |
success | Request to unlink your Plivo long code with the campaign was processed by operators. This number can now be linked to other campaigns. |
Test and Validate
Let’s take a look at an example. Typically, you would include a URL that points to your web app, but we’ll use a URL from RequestBin, a service that lets you collect, analyze, and debug HTTP requests, so we can check the callbacks.
- Create a new bin in RequestBin.
- Replace the “url” placeholder with the URL of the new bin.
- Run the code that appear above. You should see callback requests in RequestBin similar to the screenshots below for various callback events.
Brand created callback
Brand registered callback
Campaign created callback
Campaign registered callback
Number linking created callback
Number unlinking created callback
Validating callbacks
To avoid spoof attacks, you can validate the callbacks that your server URL receives. All requests made by Plivo to your server URLs include X-Plivo-Signature-V2, X-Plivo-Signature-Ma-V2, and X-Plivo-Signature-V2-Nonce HTTP headers. You can use them to validate that a request is from Plivo, as we discuss in our signature validation guide.