CallFire has a new API!

We are proud to announce the launch of our API 2.0! Learn more about our streamlined, transactional and broadcast APIs. This version of the API documentation will remain available for reference only. There will be no new development, only bug fixes. We highly recommend upgrading to our newer and more sophisticated documentation.

When developing an application with CallFire APIs, not only will you command CallFire to set up campaigns and send phone calls, your application will probably also need to get information about those campaigns and phone calls. Although there is a way to get data from CallFire with a pull strategy, the more elegant way to integrate your application with CallFire is to use a push strategy: expose part of your application to the Internet and register its URL with your CallFire account. This will help conserve resources and keep your application up to date with real-time data.


Registering a URL for notifications can be done programmatically with our APIs. However, before we begin with this example, you will need a couple of things:

  1. A CallFire API login and password. If you don't have an API login, click here.
  2. A website that can host PHP files.

First, let's write a program to register a URL for postbacks from CallFire:

$wsdl = "";

 * You'll need your login/password pair when you create the SOAP
 * client. Don't use this one; it's just for show and won't work.
$client = new SoapClient($wsdl, array(
    'login'        => '72f42300c1a1',    
    'password'     => '44261a4592146a63',
    'soap_version' => 'SOAP_1_2'));

 * You will need to provide a URL that you control to handle
 * the HTTP requests coming from
$endpoint = '';

$subscriptionRequest = array('Subscription' => array(
    'Endpoint' => $endpoint,
    'NotificationFormat' => 'XML'

$response = $client->createSubscription($subscriptionRequest);

echo "Response: $response\n";


If you run this program, CallFire will respond with the ID assigned to the newly created subscription. The URL that we just registered should start receiving HTTP posts from These include various events that happen in your account, such as when calls finish.

Here’s an example of a postback that was generated when I received an incoming SMS on one of my phone numbers that I own through CallFire:

//Example from incoming SMS
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<n:TextNotification xmlns="" xmlns:n="">
    <Text id="5707328001">
        <Message>Hello, World!</Message>
        <TextRecord id="3526268001">
            <Message>Hello, World!</Message>

As you can see, the postback contains a lot of useful information, including the number from which the SMS came, the CallFire number which received the SMS, the time the message was received, billing information, and the text within the SMS. This information will allow us to write applications that can react in nontrivial ways to events in CallFire.

I want to receive all the SMS that come to my CallFire numbers as emails, so that I can read them on my desktop computer as they come in. Converting the SMS postbacks to emails can be done with just a few lines of code in PHP:

// This code will reside at the endpoint we defined earlier ...

$xml = simplexml_load_string($HTTP_RAW_POST_DATA);
$text = $xml->Text or die('No text');
$inbound = $text->Inbound == 'true' or die('Not inbound');
$fromNumber = (string)$text->FromNumber;
$toNumber   = (string)$text->ToNumber;
$time       = (string)$text->Created;
$message    = (string)$text->Message;

$emailSubject = "$toNumber received a new SMS from $fromNumber";
$emailMessage = "From: $fromNumber\n".
                "  To: $toNumber\n".
                "Time: $time\n".
                "Text: $message";

mail('', $emailSubject, $emailMessage);


Finally, if we are changing our application or putting it permanently to bed, we can always cancel our subscriptions to postbacks. These next few lines demonstrate two things:

  1. Querying CallFire for our account's postbacks
  2. Deleting them one by one

// Let's assume we have $client defined from the first example:
$response = $client->querySubscriptions();
$subscriptions = is_array($response->Subscription) ?
                          $response->Subscription :

foreach($subscriptions as $sub) {
    $id = $sub->id;
    $deleteRequest = array('Id' => $id);
    echo "Deleting $id...\n";
    $response = $client->deleteSubscription($deleteRequest);