Rate this page:

Outgoing Calls with Twilio Client

Outgoing Capability

In order for your client device to be allowed to connect to Twilio so it can make an outgoing call, you need to make sure that the Capability Token you've provided allows for it. To do this, you will need a TwiML App SID and have your server application provide this SID to the outgoing capability of the token generator.


        TwiML App Configuration

        Configure your TwiML App to connect to a URL that returns the following TwiML:

        <?xml version="1.0" encoding="UTF-8"?>
            <Say>Thanks for calling!</Say>

        See our server application guide for more details on how to set this up.

        Connecting a Call

        Once you've created a Device, you can call it's connect() method to connect to Twilio. Twilio will make a request to the voice URL configured on your TwiML App. Since this return the <Say> verb that simply thanks the caller, you should hear the thank you message in your browser or on your device.


              Passing Parameters for a Call

              Just getting a message played to you in your browser isn't all that interesting. What we really want to do is have the client make a call to a real live phone number. In order to do this, our client needs to pass a parameter to our TwiML App. The parameter can be anything you like, but we'll create a parameter named "To" to indicate the number we want to make a call to.


                    The "To" parameter (and anything else you specify in the params object) will be passed to your server application's TwiML handler. Your server code can check for those parameters and then generate and return the appropriate TwiML, for example a <Dial> verb to connect the call.


                          Hanging Up a Call

                          Once you're on a call, you will probably want a way to hang up. This can be accomplished (albeit with less satisfaction than slamming a real phone handset into the receiver) using the disconnect() method.

                                David Prothero Devin Rader
                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.


                                      Thank you for your feedback!

                                      We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      Refer us and get $10 in 3 simple steps!

                                      Step 1

                                      Get link

                                      Get a free personal referral link here

                                      Step 2

                                      Give $10

                                      Your user signs up and upgrade using link

                                      Step 3

                                      Get $10

                                      1,250 free SMSes
                                      OR 1,000 free voice mins
                                      OR 12,000 chats
                                      OR more