Ruby Quickstart: Making an Outgoing Call

To make a call, submit a POST request to the Calls resource.


The twilio-ruby library makes this very easy to do. Open a file called make_call.rb and write the following:

require 'rubygems' # not necessary with ruby 1.9 but included for completeness
require 'twilio-ruby'

# put your own credentials here - from
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'

# set up a client to talk to the Twilio REST API
@client = account_sid, auth_token

@call = @client.account.calls.create(
  :from => '+14159341234',   # From your Twilio number
  :to => '+18004567890',     # To any number
  # Fetch instructions from this URL when the call connects
  :url => ''

Lets look at the details:

  • First over to the Twilio website and log into your Twilio Account page. On the Dashboard there is a section labeled "API Credentials". There you will find your Account SID and Auth Token. Copy those values and paste them into the Account SID and Auth Token variables.
  • We then instantiate a new client object, fill in the 'From', 'To' and 'Url' parameters, and fire off the request to Twilio!

Call end callback

By default, your application does not get any notification when a call is complete, if the line is busy, or if no one answers. To get notifications about the status of a call, add the :status_callback parameter to the create method. The full list of parameters that can be passed is available in the Calls API Documentation.

When the call is complete, or if the line is busy or no one answers, Twilio will make a request to the URL you specify in the StatusCallback parameter.

Next: Access your call logs via our API »