Voice API

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

Sign up and start building

Try a phone call from the Voice API

  • What’s happening
  • Technical version

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.

This call logic relies on a number of TwiML verbs including <Say> to speak audio to the caller, <Gather> to take dialpad input from the user, and <Play> to play audio back to the user.

  • PHP
  • Node
  • Python
  • Ruby
  • Java
  • .NET (C#)

require 'Services/Twilio.php';


$client = new Services_Twilio($sid, $token, $version);

$phonenumber = '+14154834499';

try {
  $call = $client->account->calls->create(
  echo 'Started call: ' . $call->sid;
} catch (Exception $e) {
  echo 'Error: ' . $e->getMessage();
@using Twilio;

  string accountSid = "ACXXXXXXXXXXXXXXXXX";
  string authToken = "YYYYYYYYYYYYYYYYYY";

  string phonenumber = "+14154834499";

  var client = new TwilioRestClient(accountSid, authToken);

  var call = client.InitiateOutboundCall(

  if (call.RestException == null)
    Response.Write(string.Format("Started call: {0}", call.Sid));
  } else {
    Response.Write(string.Format("Error: {0}",
import java.util.Map;
import java.util.HashMap;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.instance.Call;
import com.twilio.sdk.resource.factory.CallFactory;

public class MakeCall {

  public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX";
  public static final String AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY";

  public static void main(String[] args) throws TwilioRestException {

    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
    Account mainAccount = client.getAccount();
    CallFactory callFactory = mainAccount.getCallFactory();
    Map<String, String> callParams = new HashMap<String, String>();
    callParams.put("From", "+14154834499");
    callParams.put("To", "555-123-4567");
    callParams.put("Url", "http://ahoy.twilio.com/voice/api/demo");
    Call call = callFactory.create(callParams);
var client = require('twilio')('ACXXXXXXXXXXXXXXXXX', 'YYYYYYYYYYYYYYYYYY');

  from: '+14154834499',
  to: '555-123-4567',
  url: 'http://ahoy.twilio.com/voice/api/demo'
}, function (err, responseData) {
from twilio.rest import TwilioRestClient

client = TwilioRestClient(account_sid, auth_token)

call = client.calls.create(
print call.sid
require 'rubygems'
require 'twilio-ruby'


@client = Twilio::REST::Client.new account_sid, auth_token

@call = @client.account.calls.create(
  :from => '+14154834499',
  :to => '555-123-4567',
  :url => 'http://ahoy.twilio.com/voice/api/demo'
The Twilio advantage
  • Communicate reliably

    Experience a 99.95% uptime SLA made possible with automated failover and zero maintenance windows.

  • Operate at scale

    Extend the same app you write once to new markets with configurable features for localization and compliance.

  • Many channels

    Use the same platform you know for voice, SMS, video, chat, two-factor authentication, and more.

  • No shenanigans

    Get to market faster with pay-as-you-go pricing, free support, and the freedom to scale up or down without contracts.