Voice API

Explore Twilio’s Programmable Voice API and create custom call experiences with speech recognition, call recording, conference calling and more.

Try a phone call from the Voice API

When you start the phone call, this code makes a request to the Twilio Voice API providing both a phone number to call, and a server location that will provide TwiML instructions on how to route the phone call.

Demo available in the U.S. and Canada.

<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);
$call = $twilio->calls
               ->create("+15558675310", // to
                  "+15017122661",       // from
                  array("url" => "http://demo.twilio.com/docs/voice.xml")
               );
print($call->sid);

Powerful Voice API Primitives

Programmatic call control

Your app instructs Twilio in real time on how a call should proceed — build nearly any workflow you can imagine.

<Response>
  <Play>/ahoy.mp3</Play>
  <Dial action="/forward">
    +15551234456
  </Dial>
</Response>

<Say> text and <Gather> keypad input

The basics of most call flows start with the ability to speak strings of text and gather DTMF keypad input.

<Response>
  <Gather action="/process-keypad-input">
    <Say language="en-gb">
      Ahoy! Choose an option.
      For Sales press 1.
      For Support press 2.
    </Say>
  </Gather>
</Response>

<Queue> and <Conference> built in

TwiML provides intelligent Conference and Queue primitives to take the heavy lifting out of building seamless call experiences.

<Response>
  <Dial>
    <Client>jenny</Client>
  </Dial>
</Response>

<Dial> a WebRTC‑powered <Client>        

Connect a call to a web or mobile app using the Twilio Client SDK. Your TwiML specifies to which client username to connect the call.

<Response>
  <Say language="en-gb">
    Ahoy! Please hold while we
    connect you to an agent.
  </Say>
  <Queue url="/support-hold">
    support-wait-queue
  </Queue>
</Response>

Call progress notifications  

Get webhooks notifying of call progress events as any call progresses through key events, such as Initiated, Ringing, Answered, and Completed.

<Response>
  <Dial>
    <Number
      statusCallbackEvent="initiated ringing answered completed"
      statusCallback="https://myapp.com/calls/events"
      statusCallbackMethod="POST">
        +14158675309
    </Number>
  </Dial>
</Response>

The Twilio Advantage

Trust at scale

Reliable platform that reduces the complexity of security and compliance across any channel in 180+ countries.

Freedom to build

Flexible, plug-and-play tools that make integration and onboarding simple.

Context-driven engagement

Actionable, context-driven  insights from real-time data to enhance interactions and improve efficiency.