Setting up a Webhook to Receive Call Statuses
In this section, you will be acquainted with a simplistic Webhook API for you to create Webhook Notifications for your voice calls directly to your API Endpoint.
After you have successfully added a webhook for the Voice application, you will now receive real-time call status updates.
To set up a Webhook
- Type the following piece of code.
curl --location --request POST 'https://voice.unifonic.com/v1/providers/webhook'
--header 'AppsId: 'XXXXXXXXXXXXXX'
--header 'Content-Type: application/json'
--data-raw '{
"url":"insert your webhook endpoint here",
"basicAuthNeeded": false
}'
{
"url":"insert your webhook endpoint here",
"basicAuthNeeded": false,
"username":"XX", //optional
"password":"XXX". //optional
}
- If basicAuthNeeded is true, the username and password must be included. Otherwise, feel free to omit it.
Now your webhook has been added to our internal systems.
- Sample of a webhook notification sent to you
{
"applicationId": " XXXXXXXXXXXX",
"callSid": "XXXXXX-XXXX-XXXX-XXXX-XXXXXX",
"parentCallSid": null,
"from": "+966XXXXXX",
"to": "+966XXXXXX",
"duration": 6,
"direction": "OUTBOUND",
"status": "COMPLETED",
"timestamp": 1638192471,
"receivedAt": 1638192473.287809,
"useCase": "AUDIO_URL",
"accountId": "XXXXXXX-XXXX-XXXXXXXX",
"referenceId": "29389283923", //defined by customer
}
Updated 2 months ago