Twilio’s Programmable Voice SIP product enables your advanced voice applications to initiate SIP sessions from the Twilio cloud towards your existing SIP communications infrastructure using TwiML and/or the REST APIs.
With Programmable Voice SIP, there are a couple of ways to connect your Twilio application to your SIP communications infrastructure.
- Your application can use Twilio’s REST APIs to initiate a new SIP call towards your SIP communications infrastructure
- 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.
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:firstname.lastname@example.org</Sip> </Dial> </Response>
To start receiving SIP from Twilio towards your communications infrastructure, there is one major step you need to follow:
To ensure that your communications infrastructure doesn’t block communication, you must update your whitelist. See here for details.
Now that Twilio’s IPs are whitelisted 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.
The following headers will always be added by Twilio to the outgoing initial INVITE request. You may optionally use these fields in your communications infrastructure.
- X-Twilio-CallSid: A unique identifier for this call, generated by Twilio. It is 34 characters long, and always starts with the letters CA.
- X-Twilio-AccountSid: Your Twilio account SID. It is 34 characters long, and always starts with the letters AC.
Beta You may send the UUI (User-to-User) header in the outgoing initial INVITE request as part of <Sip>. This is currently the only header you can send without prepending
"x-". If the UUI header is sent without
"x-" prefix then action and call screening URL are not supported.
To specify the geographic region from which Twilio will send SIP-out traffic towards your communication infrastructure, you must include the
region parameter in your SIP URI. For example, if the
region=ie1 parameter is included in your SIP URI, Twilio will send the SIP traffic from the Europe Ireland region:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Sip>sip:email@example.com;region=ie1</Sip> </Dial> </Response>
|us1||North America Virginia|
|us2||North America Oregon|
|sg1||Asia Pacific Singapore|
|jp1||Asia Pacific Tokyo|
|br1||South America São Paulo|
|au1||Asia Pacific Sydney|
region parameter is not specified, Twilio will send SIP-out traffic from the North America Virginia region.
- You must make sure you whitelist the IP addresses of the Twilio region for SIP signalling and RTP media traffic.
regionparameter 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 region the SIP endpoint registered with.