This page has information to help you get your SIP infrastructure set up to receive traffic from Twilio, as well as some basics on Twilio's implementation of SIP.
The Session Initiation Protocol (SIP) is used to establish and manage VoIP communications. Use this feature to send VoIP traffic from Twilio to your SIP endpoint. Keep your IP-PBX, SIP gateway or other device -- but build all the application logic on Twilio's platform.
Initiate a new connection to your SIP endpoint via the TwiML
<Dial> verb or by using Twilio's REST API.
Twilio currently supports G.711/ulaw.
Twilio currently supports DTMF in accordance with RFC2833.
The following headers will always be added by Twilio to the outgoing initial INVITE request:
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.
X-Twilio-ApiVersion: The Twilio API version being used for this call session.
In order to better integrate with remote SIP applications, Twilio's SIP connections can read headers that are returned in the response messages. Twilio will read any headers beginning with the
X- prefix and copy them to either the Dial action URL or the call screening URL, in the format
On a successful call setup (as in, a
200 OK is returned) any X-headers on the 200 OK message are posted to the call screening URL. Headers on the final response message (4xx, 5xx messages or the final
BYE/200) are posted to the Dial action URL.
There are a couple important security considerations when configuring Twilio to connect to your SIP-enabled endpoint. Make sure you have configured your gateway and firewall correctly to receive SIP traffic from Twilio. Also, to receive media, you must enable RTP traffic to reach your SIP endpoint. Your SIP endpoint determines what ports you receive RTP traffic on, so make sure you enable your firewall or gateway to receive on those ports as well.
Twilio sends SIP traffic from a specific set of IP addresses. Set up a whitelist at the appropriate point in your network so that SIP traffic can reach your SIP endpoint. Add these IPs to your firewall to allow Twilio to communicate with your SIP endpoint:
North American Gateways:
South American Gateways (reserved for future use):
European Gateways (reserved for future use):
Asian Gateways (reserved for future use):
Media is transported via RTP and can be sent from a variable set of IP addresses. If you have a firewall in front of your media server, open your firewall so that RTP traffic can reach your media server from Twilio. If you can make calls and either the caller or person called cannot hear one or the other, please check your firewall settings.
Twilio supports users authenticating by allowing you to pass a username and password for each SIP session via TwiML or the REST API requests. Configuration for each SIP endpoint varies, so please consult your documentation more specifics on setting up authentication.