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.
<?php# Available in versions >= 4.29.0 (https://github.com/plivo/plivo-php/releases/tag/v4.29.0)require'/etc/plivo-php/vendor/autoload.php';usePlivo\RestClient;$client=newRestClient("<auth_id>","<auth_token>");$client->client->setTimeout(60);try{$callback=array("url"=>"https://<yourdomain>.com/tendlc_status/","method"=>"POST");$res=$client->brand->create("govt321","<profile_uuid>","STANDARD",true,$callback);print_r($res);}catch(PlivoRestException$ex){print_r($ex);}?>
// Available in versions >= 5.9.0 (https://github.com/plivo/plivo-dotnet/releases/tag/v5.9.0)usingSystem;usingSystem.Collections.Generic;usingPlivo;usingPlivo.Exception;namespacedotnet_project{classTen_dlc{staticvoidMain(string[]args){varapi=newPlivoApi("<auth_id>","<auth_token>");// Create Brandtry{varresponse=api.Brand.Create("brand_001","201faedc-7df9-4840-9ab1-3997ce3f7cf4","STANDARD",true,"https://<yourdomain>.com/tendlc_status/","POST");Console.WriteLine(response);}catch(PlivoRestExceptione){Console.WriteLine("Exception: "+e.Message);}}}}
letplivo=require('plivo');letclient=newplivo.Client("<auth_id>","<auth_token>");varoptional={"url":"https://<yourdomain>.com/tendlc_status/","method":"POST"}client.campaign.create("<brand_id>",//brand_id"campaign name sample",//campaign_alias"INSURANCE",//vertical"MIXED",//usecase["CUSTOMER_CARE",//sub_use cases"2FA"//sub_use cases],"sample description text",//descriptionfalse,//embedded_linkfalse,//embedded_phonefalse,//age_gatedfalse,//direct_lending true,//subscriber_optintrue,//subscriber_optouttrue,//subscriber_help"hey",//sample1"test",//sample2optional)//callback_url and method.then(function(response){console.log(JSON.stringify(response));}).catch(function(error){console.log("err");console.log(error);});
<?php# Available in versions >= 4.29.0 (https://github.com/plivo/plivo-php/releases/tag/v4.29.0)require'/etc/plivo-php/vendor/autoload.php';usePlivo\RestClient;$client=newRestClient("<auth_id>","<auth_token>");$client->client->setTimeout(60);try{$callback=array("url"=>"https://<yourdomain>.com/tendlc_status/","method"=>"POST");$res=$client->campaign->create("<brand_id>","campaign name sssample","INSURANCE","MIXED",["CUSTOMER_CARE","2FA"],"sample description text",False,False,False,False,True,True,True,"test 1","test 2",$callback);print_r($res);}catch(PlivoRestException$ex){print_r($ex);}?>
<?php# Available in versions >= 4.29.0 (https://github.com/plivo/plivo-php/releases/tag/v4.29.0)require'/etc/plivo-php/vendor/autoload.php';usePlivo\RestClient;$client=newRestClient("<auth_id>","<auth_token>");$client->client->setTimeout(60);try{$callback=array("url"=>"https://<yourdomain>.com/tendlc_status/","method"=>"POST");$res=$client->campaign->linkNumber("<campaign_id>",["<number>"],$callback);print_r($res);}catch(PlivoRestException$ex){print_r($ex);}?>
// Available in versions >= 5.9.0 (https://github.com/plivo/plivo-dotnet/releases/tag/v5.9.0)usingSystem;usingSystem.Collections.Generic;usingPlivo;usingPlivo.Exception;namespacedotnet_project{classTen_dlc{staticvoidMain(string[]args){varapi=newPlivoApi("<auth_id>","<auth_token>");Console.WriteLine("Link number to campaign");try{varresponse=api.Campaign.LinkNumber("<campaign_id>",newList<string>(){"<number>"},"https://<yourdomain>.com/tendlc_status/","POST");Console.WriteLine(response);}catch(PlivoRestExceptione){Console.WriteLine("Exception: "+e.Message);}}}}
<?php# Available in versions >= 4.29.0 (https://github.com/plivo/plivo-php/releases/tag/v4.29.0)require'/etc/plivo-php/vendor/autoload.php';usePlivo\RestClient;$client=newRestClient("<auth_id>","<auth_token>");$client->client->setTimeout(60);try{$callback=array("url"=>"https://<yourdomain>.com/tendlc_status/","method"=>"POST");$res=$client->campaign->deleteNumber("<campaign_id>","<number>",$callback);print_r($res);}catch(PlivoRestException$ex){print_r($ex);}?>
// Available in versions >= 5.9.0 (https://github.com/plivo/plivo-dotnet/releases/tag/v5.9.0)usingSystem;usingSystem.Collections.Generic;usingPlivo;usingPlivo.Exception;namespacedotnet_project{classTen_dlc{staticvoidMain(string[]args){varapi=newPlivoApi("<auth_id>","<auth_token>");Console.WriteLine("Unlink number from campaign");try{varresponse=api.Campaign.UnlinkNumber("<campaign_id>","<number>","https://<yourdomain>.com/tendlc_status/","POST");Console.WriteLine(response);}catch(PlivoRestExceptione){Console.WriteLine("Exception: "+e.Message);}}}}
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.
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input
for further improvements!