Passing custom information via requests to Twilio


If you have custom headers or tracking details you want associated with your requests you can pass the details in the voice request URL, and when the API call is answered you will receive a callback to their server with those details.

For example, if you have two custom headers, let's call them customParameter and customValue, you would construct their voice request URL like this:

Note that Twilio's request to this URL must still return valid TwiML call processing instructions.

Client (JavaScript)

Twilio.Device.connect() has an optional params argument which allows for a JavaScript object to be passed to the application as POST/GET parameters.

For example, the following code will pass the params app=Support and location=Seattle to the Twilio application associated with this Device's capability token.

var connection = Twilio.Device.connect({ app:"Support", location:"Seattle"});

To deliver parameters to a Client instance using version 1.6 or later, use the <Parameter> noun of the <Client> verb and these parameters will be added to Connection.customParameters. For example:

<?xml version="1.0" encoding="UTF-8"?>
      <Param name="foo" value="bar"/>
      <Param name="baz" value="123"/>
device.on('incoming', connection => {
  assert.equal(connection.customParameters.get('foo'), 'bar');
  assert.equal(connection.customParameters.get('baz'), '123');

Note that the following restrictions apply to the Parameter noun:

  • Parameter name must be a string, up to 32 bytes.
  • Parameter value must be a string, up to 128 bytes.
  • Up to 8 parameters can be sent per <Dial>.

Client 1.x/2.x (Mobile)

There is no method to pass custom information via mobile SDK version 1.x/2.x on Android or iOS.  

Programmable Voice SDK Android 3.0 (Mobile)

Custom parameters can be added to CallInvite via the getCustomParamaters()method:

<?xml version="1.0" encoding="UTF-8"?>
        <Dial answerOnBridge="false" callerId="client:alice">
                <Parameter name="caller_first_name" value="alice"  />
                <Parameter name="caller_last_name" value="smith"  />

callInvite.getCustomParameters() returns a map of key-value pair passed in the TwiML.

"caller_first_name" -> "alice"
"caller_last_name" -> "smith" 

Programmable Voice SDK iOS 3.0 (Mobile)

Custom parameters can be added using the customParameters property of TVOCallInvite.

  <?xml version="1.0" encoding="UTF-8"?>
    <Dial callerId="client:alice">
        <Parameter name="caller_first_name" value="alice" />
        <Parameter name="caller_last_name" value="smith" />


    "caller_first_name" = "alice";
    "caller_last_name" = "smith";

SIP Domains

Add the custom headers to the SIP URI:

SIP Trunking Origination

It is possible to send any SIP header beginning with the X- prefix, by appending them to the origination SIP URI. For example, you could configure

to send X-customParameter and X-customValue on all originated calls.

Have more questions? Submit a request
Powered by Zendesk