---
title: Connect Twilio to TelecomsXchange
url: https://help.telecomsxchange.com/integrations/twilio/
audience: Integrations
summary: Twilio isn't a switch you point at TelecomsXchange as a trunk. To buy, return
  TwiML <Dial><Sip> to sip:TECH_PREFIX%23NUMBER@sip01.telecomsxchange.com with the
  account's VoIP login and password as username and password. To receive TelecomsXchange
  phone numbers, create a Twilio SIP domain with an IP access control list for 174.136.44.213
  and set it as the number's SIP endpoint.
updated: '2026-10-23'
verified_commit: 83b4ebc96d0081a25213776d5a8871bd04941125
---

# Connect Twilio to TelecomsXchange

> Twilio isn't a switch you point at TelecomsXchange as a trunk. To buy, return TwiML <Dial><Sip> to sip:TECH_PREFIX%23NUMBER@sip01.telecomsxchange.com with the account's VoIP login and password as username and password. To receive TelecomsXchange phone numbers, create a Twilio SIP domain with an IP access control list for 174.136.44.213 and set it as the number's SIP endpoint.

## Twilio to a purchased route

1. **Your Twilio app**: TwiML <Dial><Sip> with username and password
2. **TelecomsXchange** (via `80039%23447700900123`): sip01, UDP 5060, digest auth
3. **Seller's route**: The route you purchased

Twilio is a CPaaS carrier, not a switch you configure as a trunk to TelecomsXchange. You can combine them in two ways: your Twilio application sends calls to a purchased TelecomsXchange route with `<Dial><Sip>`, and TelecomsXchange delivers phone numbers you bought into a Twilio SIP domain. For every TelecomsXchange value in one place, see [Connect a SIP platform](https://help.telecomsxchange.com/integrations/connect-sip-platforms/).

!!! warning
    TelecomsXchange does not accept SIP REGISTER. Twilio reaches it with a plain INVITE and **digest authentication on the INVITE**, using the account's VoIP login and password. Don't authorise Twilio's shared IP ranges on your account.

## Before you start

- A [SIP account](https://help.telecomsxchange.com/buyers/create-your-first-account/) on TelecomsXchange with a VoIP login and password: **Edit Account → Add SIP Digest Auth**.
- A [purchased route](https://help.telecomsxchange.com/buyers/find-and-buy-routes/) and its tech prefix from **My Interconnections**, for example `80039#`.
- A Twilio account with a voice webhook (your own app, a TwiML Bin or a Studio flow) that can return TwiML.
- For numbers: a [phone number](https://help.telecomsxchange.com/buyers/virtual-numbers-dids/) bought on TelecomsXchange.

## How do I send calls to TelecomsXchange?

Return TwiML that dials a SIP URI on sip01. Put the tech prefix in front of the E.164 number and write `#` as `%23`: a raw `#` isn't allowed in the user part of a SIP URI.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial callerId="+14155550100" timeout="60">
    <!-- TECH_PREFIX 80039# written as 80039%23, then the E.164 number without + -->
    <Sip username="VOIP_LOGIN" password="VOIP_PASSWORD">sip:80039%23447700900123@sip01.telecomsxchange.com:5060;transport=udp</Sip>
  </Dial>
</Response>
```

- `VOIP_LOGIN` and `VOIP_PASSWORD` are the **VoIP Login** and **VoIP Password** from **Edit Account**. Twilio answers TelecomsXchange's 401 or 407 challenge with them.
- `transport=udp` is Twilio's default; keep it explicit. TelecomsXchange takes SIP over UDP on port 5060.
- Twilio sends SIP from its North America (Virginia) edge unless you add a `region` parameter to the URI, such as `;region=ie1`.
- `callerId` is the caller ID the route receives.

In your webhook code, build the URI from the number your caller dialled: strip `+` or `00`, then prepend `TECH_PREFIX` with `#` encoded as `%23`. Twilio bills its own leg of the call on top of the TelecomsXchange route price.

!!! tip
    Dial a [routing group](https://help.telecomsxchange.com/buyers/routing-groups-and-route-testing/) prefix such as `444101%23` to let TelecomsXchange pick the route, so your TwiML doesn't need a prefix per destination.

## How do I receive calls on numbers I bought?

TelecomsXchange delivers each number to its SIP endpoint from `174.136.44.213`. A Twilio SIP domain can accept those calls and run your voice webhook.

1. In the Twilio Console, go to **Voice → Manage → SIP domains** and create a domain, for example `yourco.sip.twilio.com`.
2. Under the domain's authentication, create an **IP access control list** with `174.136.44.213`. Twilio requires a full address; there are no wildcards.
3. Set the domain's voice **A call comes in** URL to the webhook or TwiML that should handle the call.
4. On TelecomsXchange, open the number's **DID Settings** and set **SIP Endpoint (Primary)** to:

```text
sip:14165551234@yourco.sip.twilio.com:5060
```

Your webhook receives the user part (`14165551234`) in the `To` parameter.

!!! warning
    `174.136.44.213` is TelecomsXchange's shared platform IP, and Twilio itself warns that IP authentication alone doesn't separate tenants of a multi-tenant carrier. In your webhook, accept only the numbers you own and reject everything else.

A Twilio BYOC trunk with the same IP access control list also works if you prefer to manage the numbers as BYOC numbers. Either way, TelecomsXchange passes codecs through, and Twilio accepts G.711.

## Can TelecomsXchange send calls to Twilio as a seller route?

Not covered here. Twilio isn't a destination you sell on TelecomsXchange: an Elastic SIP Trunk terminates your own traffic, and reselling it as a wholesale route depends on Twilio's terms.

## How do I test it?

1. Call your Twilio number, or create a call with the REST API, so the webhook returns the `<Dial><Sip>`.
2. In the Twilio Console, open **Monitor → Logs → Calls**, select the call and check the SIP leg's response code and the SIP URI dialled.
3. On TelecomsXchange, watch the call in **Live Calls** and find its SIP code in **Logs → CDR (Voice)**.
4. For numbers, call the TelecomsXchange number and check the Twilio call log for the SIP domain call.

## What if something goes wrong?

| You see | What to do |
|---|---|
| 401 or 407 in the Twilio log | Wrong `username` or `password` on `<Sip>`, or digest auth isn't enabled on the account. Copy them again from **Edit Account**. |
| 403 Forbidden | No valid credentials, or the account is blocked or out of balance. Twilio's source IP is never authorised on its own. |
| 404 Not Found | Missing or wrong tech prefix, a raw `#` in the URI, or `+` left in the number. Use `80039%23` followed by the E.164 number. |
| 408 Request Timeout, or no answer | Twilio couldn't reach sip01. Check the URI host and port, and `transport=udp`. |
| 503 Service Unavailable | The route is blocked or failed on the seller's side. Check **My Interconnections**; try another route or a routing group. |
| One-way or no audio | Codec mismatch: TelecomsXchange doesn't transcode, so the route must accept G.711 from Twilio. |
| Number calls never reach Twilio | `174.136.44.213` isn't in the SIP domain's IP access control list, or the number's SIP endpoint has a typo in the domain. |
| Number calls reach Twilio but play an error | The SIP domain has no voice URL, or the webhook rejects the `To` number. |

## References

- [Twilio TwiML `<Sip>` noun](https://www.twilio.com/docs/voice/twiml/sip)
- [Twilio: receiving SIP from Twilio (SIP-out)](https://www.twilio.com/docs/voice/api/receiving-sip)
- [Twilio: sending SIP to Twilio (SIP domains)](https://www.twilio.com/docs/voice/api/sending-sip)
- [Twilio SIP security: IP access control lists and credential lists](https://www.twilio.com/docs/voice/api/sip-security)
- [Twilio Bring Your Own Carrier (BYOC)](https://www.twilio.com/docs/voice/bring-your-own-carrier-byoc)

## Frequently asked questions

**Q: Can Twilio register to TelecomsXchange?**

A: No. TelecomsXchange is peering only and does not accept REGISTER. Twilio's <Sip> noun sends the INVITE and answers TelecomsXchange's digest challenge with the username and password you give it.

**Q: Why not authorise Twilio's IP addresses on my account?**

A: Twilio's SIP signalling addresses are shared by all Twilio customers. Authorising them would let any Twilio user send calls on your account. Use digest credentials instead.

**Q: Can I use a Twilio BYOC trunk to send calls to TelecomsXchange?**

A: Not well. Twilio doesn't authenticate to the carrier with credentials on BYOC origination, so you'd have to authorise Twilio's shared IPs, and BYOC dials E.164 numbers, which leaves no place for the tech prefix. Use <Dial><Sip>.

**Q: Can I sell Twilio termination on TelecomsXchange?**

A: This guide doesn't cover it. Pointing a TelecomsXchange seller route at a Twilio Elastic SIP Trunk is technically possible, but check Twilio's terms for wholesale resale first.
