Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Inbound - Sending SIP to Twilio



Overview

overview page anchor

Twilio's Programmable Voice SIP product enables you to use your existing SIP communications infrastructure (e.g. IP-PBX, SBC, etc) to initiate SIP sessions with Twilio and use TwiML and/or the REST APIs to create advanced voice applications. Twilio sits in the middle, enabling calls to be routed to your SIP communications infrastructure, PSTN, or to browsers and mobile apps. There are a few short steps to configure Twilio to interoperate with your infrastructure so you can start building and testing your voice app.

Programmable Voice SIP Diagram.{example}.sip.ashburn.twilio.com (North America Virginia)
  • {example}.sip.umatilla.twilio.com (North America Oregon)
  • {example}.sip.dublin.twilio.com (Europe Ireland)
  • {example}.sip.frankfurt.twilio.com (Europe Frankfurt)
  • {example}.sip.singapore.twilio.com (Asia Pacific Singapore)
  • {example}.sip.tokyo.twilio.com (Asia Pacific Tokyo)
  • {example}.sip.sao-paulo.twilio.com (South America São Paulo)
  • {example}.sip.sydney.twilio.com (Asia Pacific Sydney)
  • (information)

    Info

    If you are looking for a list of legacy SIP localized URIs, visit here.

    Request URL (webhook)

    request-url-webhook page anchor

    Please specify a URL that points to your web application that Twilio will invoke upon receipt of a SIP INVITE. The URL must respond with TwiML that specifies how to handle the incoming call. Alternatively, you can specify a URL that points to a static TwiML bin(link takes you to an external page).

    Below is a URL you can use as an example of a static TwiML. When Twilio receives the SIP INVITE, after authentication, it will accept the INVITE, establish the call and say a brief message to the caller.


    _10
    http://twimlets.com/message?Message%5B0%5D=Congratulations!%20You%20just%20made%20your%20first%20call%20with%20Twilio%20SIP.

    If the Request URL fails (for instance, due to an invalid TwiML), then optionally you can specify that this URL be invoked.

    Status Callback URL

    Optionally, you can specify a URL for Twilio to send webhook requests to as a call progresses from, initiated to ringing to answered to completed.

    Authentication

    Authentication limits access to your SIP Domain from only approved devices and users. You must configure a minimum of either an Access Control List or a credential list. If you configure both, then both ACLs and credential lists are enforced.

    IP Access Control Lists (ACL)

    ip-access-control-lists-acl page anchor

    If configured, then Twilio will only accept SIP traffic originating from the IPs in this list - all other packets will be dropped. You must specify a full IP address; no IP wildcarding is supported. IP Access Control Lists can be applied to one or more SIP Domains. There exists a REST API for creating IP ACLs.

    Credential Lists are sets of usernames and passwords that will be accepted by your SIP Domain.

    If a Credential List is configured, your SIP INVITE will be challenged with a 407 Proxy Authentication Required requesting the appropriate user name and password.

    For each username, you must set a password that meets the following minimum requirements:

    • Minimum of 12 characters
    • At least one mixed case
    • At least one digit

    Twilio does not store the passwords you provide for usernames in cleartext; instead, the passwords are MD5 hashed in accordance with the digest authentication specification. Once a password is set, Twilio does not provide a way to retrieve the stored password. Credential Lists can be applied to one or more SIP Domains.

    A REST API exists for creating Credential Lists.

    Step 2: Allow Twilio's IP addresses and ports

    step-2-allow-twilios-ip-addresses-and-ports page anchor

    To ensure that your communications infrastructure doesn't block communication, you must update your allow list. See the SIP documentation for details.

    Step 3: Start sending SIP to your Twilio SIP Domain

    step-3-start-sending-sip-to-your-twilio-sip-domain page anchor

    Now that Twilio's IPs and ports are allowed in your system and your SIP Domain is created, you can send SIP requests to Twilio. If you used the example URL from Step 1, you will hear:

    "Congratulations! You just made your first call with Twilio SIP."


    In order to better integrate with remote SIP applications, Twilio reads the headers that are sent in the SIP request and response messages. Twilio will read any headers beginning with the X- and prepended with SipHeader_ prefix in request parameters.

    You can send multiple param & value pairs as part of the same header. For example, X-TestHeader: param1=value1;param2=value2;param3=value3

    If you send headers without X- prefix, Twilio will not read the header. As a result, the header will not be passed in the output.

    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. You can pass a UUI (User-to-User) header through a webhook as a parameter for incoming calls to Twilio.

    Simply add UUI SIP header as part of the SIP message before sending it to Twilio. The headers will be sent as request parameters in the webhook requested from your server. For example, if you send the following SIP headers in your SIP message:

    User-to-User: 123456789;encoding=hex

    Twilio will prepend the UUI header with SipHeader_ prefix in webhook request to your server. For example,

    SipHeader_User-to-User "123456789;encoding=hex".


    Rate this page: