Skip to main content

Using Telnyx as a Termination Carrier for Twilio

Users with accounts in both Telnyx and Twilio portals can send calls from Twilio to Telnyx via SIP and have Telnyx terminate those calls on the PSTN.

Intro To Twilio And Telnyx

The following instructions will explain how to configure both sides so that calls from Twilio are authenticated using your Telnyx SIP Connection.

In this guide we use a TwiML application as an example, but the token configuration on Twilio side will follow the same analogy for any other Twilio API based application (SDK, node, python, etc).

Telnyx Settings For Twilio

  1. Login to the Telnyx Mission Control portal

  2. Click on the SIP Connections menu option and then Add SIP Connection.

  3. Enter a Name and select Type: IP address.

  4. Under Expert IP Auth Settings choose the option Token and register the suggested Token (or define any alphanumeric value that you prefer). Click Save.

  5. On the same connection, click + Add IP to add the following Signaling IP addresses that belong to Twilio. To do that just go to Twilio’s Networking Information page on the portal, and see what are the Signaling IPs for your region. For example, if you are using Twilio North America Virginia those would be:





  6. Click on Save all Changes. Your SIP Connection should look like the image below.

  7. Click on the Outbound menu option and create a new Outbound Profile or use an existing one.

  8. Assign the new SIP Connection to the Outbound Profile to allow outbound calls to be authorized.

Your Telnyx SIP Connection is now ready to accept traffic from your Twilio account!

Twilio Settings

Note: the following example uses a TwiML based application, but the same analogy and guidance for the Telnyx Token configuration is the same for any other Twilio API based application, i.e. SDK, Python, Node, etc.

  1. Login to the Twilio Portal.

  2. Have your TwiML application set in TwiML Apps tab

  • Create an TwiML application that forwards calls to Telnyx and adds a Token header like the one from this example:
<Say>Please hold while we connect the call.</Say>

Note: After pasting the above content, Kindly check and remove any new line added

  • You can trigger your application by adding it to a call flow, e.g. assigning it to a Twilio phone number and making a call to that number.

  • Once the application reaches that step, Twilio will send a SIP INVITE message to Telnyx to establish the call like the one from this example.

INVITE sip:<your-to-number> SIP/2.0
Record-Route: <sip:;lr>
From: "<your-from-number>" <sip:<your-from-number>>;tag=-------------
To: <sip:<your-to-number>>
Max-Forwards: 67
Date: Wed, 16 Oct 2019 21:20:40 GMT
Min-SE: 120
X-Telnyx-Token: <your-token>
Call-ID: ------------------------
Via: SIP/2.0/UDP;branch=-------------
Via: SIP/2.0/UDP;rport=5060;received=;branch=----------------
Contact: "<your-from-number>" <sip:<your-from-number>@;transport=udp>
User-Agent: Twilio Gateway
X-Twilio-AccountSid: <your-twilio-id>
Content-Type: application/sdp
X-Twilio-CallSid: --------------
Content-Length: 238

o=root 1836844584 1836844584 IN IP4
s=Twilio Media Gateway
c=IN IP4
t=0 0
m=audio 12240 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

Note: After pasting the above content, Kindly check and remove any new line added

  • Telnyx will accept that SIP INVITE and will place/redirect the call to the PSTN number placed in the SIP URI.

Additional Resources

On this page