Setting up a Webhook to Receive Call Statuses

In this section, you will be acquainted with a simplistic Webhook API for you to receive call status update notifications for your voice calls.

To set up a Webhook on your Voice Application

Create Webhook API

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,
    "username":"XX",  //optional
    "password":"XXX". //optional
}}'

If basicAuthNeeded is true, the username and password must be included. Otherwise, feel free to omit it.

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
 "recordingUrl":"https://demorecording.com/call"
 }

👍

New feature

Following our latest release, if there were a call recording activity during the call, a recording URL will appear in the webhook payload. The recording URL would be accessible for 72 hours. Thereafter, this URL will expire. The recording can still be downloaded from the Unifonic Console, depending on the Service Agreement you have with Unifonic.

Retrieve existing webhook

Check what is the configured endpoint to receive your call status updates.

curl --location --request GET '<https://voice.unifonic.com/v1/providers/webhook>'  
--header '_AppsId: 'XXXXXXXXXXXXXX_'  
--header 'Content-Type: application/json'  
}'