Make a call

You make an outbound call through our Voice API by sending a HTTP POST requsest to one of the following endpoints:

Endpoints

Live: https://voice.africastalking.com/call
Sandbox: https://voice.sandbox.africastalking.com/call

Request Parameters

In addition to the standard request headers, the body of the request should contain the following fields:

Parameter Description
username
String
Required
Your Africa's Talking application username.
from
String
Required
Your Africa's Talking phone number (in international format i.e. +XXXYYYYYY)
to
String
Required
The phone number that you wish to dial (in international format)

API Response

The body of the response will be a JSON object containing the following fields:

Parameter Description
entries
List
A list of Entry items each corresponding to an individual phone number and their status.

Entry is a Map with details of queued numbers.
  • phoneNumber: String The phone number queued.
  • status: String The status of the request associated to this phone number. Will either be Sent or Failed.
  • sessionId: String A unique id for the request associated to this phone number.
errorMessage
String
Optional
Error message if the ENTIRE request was rejected by the API.
{
    "entries": [{
        "phoneNumber": "+234XXXYYYZZZZ",
        "status": "Queued",
        "sessionId": "ATVId_abcdef"
    }],
    "errorMessage": "None"
}

Initiate call sample code

The PHP code snippet below shows how to make a call.

The code uses our PHP SDK.

<?php
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;

// Set your app credentials
$username = "MyAppUsername";
$apikey   = "MyAppAPIKey";

// Initialize the SDK
$AT       = new AfricasTalking($username, $apiKey);

// Get the voice service
$voice    = $AT->sms();

// Set your Africa's Talking phone number in international format
$from     = "+254711082XXX";

// Set the numbers you want to call to in a comma-separated list
$to       = "+254711XXXYYY,+254733YYYZZZ";

try {
    // Make the call
    $results = $voice->call([
        'from' => $from,
        'to'   => $to
    ]);

    print_r($results); 
} catch (Exception $e) {
    echo "Error: ".$e->getMessage();
}