Using Verify APIs, you can send requests to your users through SMS or voice channels. You can use event-based webhooks — user-defined HTTP callbacks — to track the delivery status of your requests. Plivo sends a status update to a URL you configure as a callback. You can store the information on your server for delivery status analysis. To handle a webhook, you must create a listener (web app) that can accept these HTTP requests from Plivo.
Code
1
2
3
4
5
6
7
8
9
10
curl -i --user auth_id:auth_token \
-H "Content-Type: application/json" \
-d '{
"app_uuid":"<app_uuid>",
"recipient": "<recipient>",
"url":"https://<yourdomain>.com/sms_status/",
"channel":"sms",
"method":"POST"
}' \
https://api.plivo.com/v1/Account/{auth_id}/Verify/Session/
To handle callbacks in your app, 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 type you’ve defined for the URL) and respond with a 200 OK response. You can store the callback data to your database.
Let’s 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.
Plivo sends the following fields to your application:
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.