Overview
The Voice service provides endpoints for initiating phone calls and handling voice call events and instructions through Africa’s Talking Voice API.GET /voice/
Check Voice service status.Response
Service name (“voice”)
Service status (“ready”)
Example Request
Example Response
GET /voice/invoke-call
Initiate an outbound phone call to a specified number.Query Parameters
Phone number to call (without the + prefix, e.g., 2547XXXXXXX)
Response
Success message indicating call was initiated
Response object from Africa’s Talking API
Example Request
Example Response
Error Codes
- 400 - Missing ‘phone’ query parameter
- 500 - Internal server error or Africa’s Talking API error
POST /voice/instruct
Webhook endpoint that provides call flow instructions when a call is answered.Request Body (Form Data)
Unique session ID for the call
Phone number of the caller
Phone number that was called
Response
Returns XML instructions in text/plain format. The XML defines the call flow using Africa’s Talking Voice XML elements.Example Request
Example Response
Available XML Elements
You can use the following Africa’s Talking Voice XML elements:<Say>- Text-to-speech<Play>- Play audio file<GetDigits>- Collect user input<Dial>- Connect to another phone number<Record>- Record audio<Redirect>- Redirect to another URL<Reject>- Reject the call<Conference>- Conference call<Enqueue>- Add to call queue
POST /voice/events
Webhook callback for voice call events from Africa’s Talking.Request Body (Form Data)
Unique session ID for the call
Type of event (e.g., “SessionStarted”, “SessionEnded”, “SessionFailed”)
Phone number of the caller
Phone number that was called
Reason for call termination (if applicable)
Call direction (“inbound” or “outbound”)
Timestamp when the call started
Call duration in seconds
Currency code for the call cost
Cost of the call
Response
Returns “OK” with status 200.Example Request
Example Response
Event Types
Common event types you may receive:- SessionStarted - Call has been initiated
- SessionRinging - Phone is ringing
- SessionAnswered - Call was answered
- SessionEnded - Call ended normally
- SessionFailed - Call failed to connect
- SessionTransferred - Call was transferred
- SessionQueued - Call was added to queue
Hangup Causes
Common hangup causes:- NORMAL_CLEARING - Call ended normally
- USER_BUSY - Number was busy
- NO_ANSWER - No answer
- CALL_REJECTED - Call was rejected
- INVALID_NUMBER - Invalid phone number
- NETWORK_ERROR - Network error occurred
