Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Outbound - Receiving SIP from Twilio


Learn to initiate SIP sessions from Twilio to your infrastructure by using the <Sip> noun within a <Dial> verb or by triggering a POST request. You can use this guide to create outbound call centers, self-service automation, or AI/ML transcription.

See Related reference documentation to learn more about the reference page elements used in this guide.


How it works

how-it-works page anchor
Twilio SIP flow from inbound call to customer SIP network via internet or private connections.

With Programmable Voice SIP, there are a couple of ways to connect your Twilio application to your SIP communications infrastructure.

  1. Your application can use Twilio's REST APIs to initiate a new SIP call towards your SIP communications infrastructure
  2. An inbound PSTN or SIP call can invoke your application which can respond using the <Sip> noun of the <Dial> verb, to establish a call with your SIP endpoint.
1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:jack@example.com</Sip>
5
</Dial>
6
</Response>

To start receiving SIP from Twilio towards your communications infrastructure, there is one major step you need to follow:

Allow Twilio's SIP IP addresses and media ports in your system

allow-twilios-sip-ip-addresses-and-media-ports-in-your-system page anchor

To ensure that your communications infrastructure doesn't block communication, you must update your allowed list of IP Addresses. See here for details.

Now that Twilio's IPs are allowed in your system, your Twilio app can begin sending SIP traffic to your SIP communications infrastructure. If you are new to Twilio, it's best to start out with <Sip> noun of the <Dial> for your first app. See here for details.


Twilio allows you to send custom SIP headers as part of the outgoing initial INVITE request.

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:jack@example.com?x-myotherheader=bar</Sip>
5
</Dial>
6
</Response>

You can also send multiple param & value pairs as part of the same header, as well as combine multiple headers by separating them with &amp; between each. For example,

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:+14158675309@your.domain?X-customName=Bob%2CShield%2BTitle%2DManager&amp;X-otherHeader=true</Sip>
5
</Dial>
6
</Response>

Twilio allows you to pass the custom header as part of Dial action URL or the call screening URL. On a successful call setup (when a 200 OK SIP response is returned) any X-headers in the 200 OK message are posted in the format SipHeader_X-headername=headervalue and in the final SIP response message (any 4xx or 5xx message or the final BYE/200) are posted in the format DialSipHeader_X-headername=headervalue.

UUI (User-to-User Information) Header

uui-user-to-user-information-header page anchor

In order to pass the contextual information of the caller, customers use UUI (User-to-User Information) header in SIP request messages. Twilio allows you to pass UUI header as part of <Sip> request.

Note: For non X-headers like UUI action and call screening URL are not supported.

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:jack@example.com?User-to-User=123456789%3Bencoding%3Dhex&amp;x-myotherheader=bar</Sip>
5
</Dial>
6
</Response>

UUI headers can also send with "X-" prefix. See below...

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:jack@example.com?X-User-to-User=123456789%3Bencoding%3Dhex&amp;x-myotherheader=bar</Sip>
5
</Dial>
6
</Response>

Other supported standard SIP headers

other-supported-standard-sip-headers page anchor

In order to pass other contextual information, Twilio allows you to pass the following standard SIP headers as part of an outbound SIP call:

  • Remote-Party-ID
  • P-Preferred-Identity
  • P-Called-Party-ID

Note: For these headers, action and call screening URL are not supported.

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:bob@example.com?x-foo%3Dbar&amp;User-To-User=foobar&amp;Remote-Party-ID=%3Csip%3Afoo%40example.com%3E%3Bparty%3Dcalling&amp;P-Preferred-Identity=%3Csip%3Afoo%40example.com%3E&amp;P-Called-Party-ID=%3Csip%3Afoo%40example.com%3E</Sip>
5
</Dial>
6
</Response>

The edge Parameter

sip-uri-edge page anchor

To specify the geographic edge from which Twilio will send SIP-out traffic towards your communication infrastructure, you must include the edge parameter in your SIP URI. For example, if the edge=frankfurt parameter is included in your SIP URI, Twilio will send the SIP traffic from the Frankfurt, Germany edge:

1
<?xml version="1.0" encoding="UTF-8"?>
2
<Response>
3
<Dial>
4
<Sip>sip:alice@example.com;edge=frankfurt</Sip>
5
</Dial>
6
</Response>
EdgeLocation
ashburnNorth America Virginia
san-joseNorth America Oregon
dublinEurope Ireland
frankfurtEurope Frankfurt
singaporeAsia Pacific Singapore
tokyoAsia Pacific Tokyo
sao-pauloSouth America São Paulo
sydneyAsia Pacific Sydney
(information)

Info

You can find the legacy region list here.

eg: <Sip>sip:alice@example.com;region=de1</Sip>

If the edge parameter is not specified, Twilio will send SIP-out traffic from the North America, Virginia edge.

Notes:

  • You must make sure you allow the IP addresses of the Twilio edge for SIP signaling and RTP media traffic.
  • The edge parameter is not supported when calling SIP registered endpoints, the parameter will be ignored if present. SIP-out traffic will always be sent from the Twilio edge the SIP endpoint registered with.

Use cases for receiving SIP with Twilio Programmable Voice

use-cases-for-receiving-sip-with-twilio-programmable-voice page anchor

This guide teaches the basics required for the following use cases:

Create an outbound call center with Twilio Programmable Voice

create-an-outbound-call-center-with-twilio-programmable-voice page anchor

You can use this guide to create a programmatic outbound call center that dials customers or agents via SIP for telemarketing or support.

To learn more advanced features that you can use with outbound call centers, see Voice outbound call centers.

Create self-service automation with Twilio Programmable Voice

create-self-service-automation-with-twilio-programmable-voice page anchor

Together with the gather guide, you can use this guide to automate outbound SIP calls that gather user input using the keypad for self-service automation.

To learn more advanced features that you can use with self-service automation, see Voice self-service automation.

Create transcriptions for AI or ML with Twilio Programmable Voice

create-transcriptions-for-ai-or-ml-with-twilio-programmable-voice page anchor

You can use this guide to capture the audio of your outbound SIP sessions for AI-driven analysis, allowing you to send raw audio to machine learning models for real-time transcription.

To learn more advanced features that you can use with AI or ML transcription, see Voice AI and ML transcription.


After following this guide, you can initiate a SIP session programmatically from Twilio to your existing communications infrastructure. You might also have customized your SIP INVITE requests with custom X-headers, UUI information, and specific geographic edge routing.


Explore the following guides to build on what you've learned in this guide: