The Complete 3CX Twilio SIP Trunk Setup Guide: Step-by-Step for Businesses

Your 3CX system already handles inbound calls, extensions, and agent queues. What many businesses add on top of that is an automated fallback: when no human agent picks up, the call forwards to an external system that handles it, whether that's an IVR, a voice bot, or an AI-powered call handler. Twilio is the platform most IT teams use to build and host that system.
This guide covers the specific call flow where 3CX Twilio SIP integration means 3CX is the PBX that receives the customer call and forwards it outbound to a Twilio SIP Domain when no agent answers. The customer dials your number.
This is a Twilio SIP trunk 3CX configuration guide for IT admins, VoIP engineers, and SMB IT teams who need the 3CX-side configuration done precisely and the Twilio SIP Domain set up correctly on the receiving end.
- In this flow, 3CX is the caller. When queue timeout fires, 3CX dials out through the SIP trunk to the Twilio SIP Domain URI.
- Twilio is the SIP UAS — it receives the call and routes it to your TwiML App, Studio flow, or AI agent webhook.
- Use Twilio SIP Domain (not Elastic SIP Trunking) for this use case.
- The custom SIP template is required to preserve the original customer caller ID on the forwarded leg.
- E164 must be disabled in 3CX — enabling it breaks the outbound SIP call to Twilio.
How the 3CX to Twilio SIP Domain Flow Works
This 3CX Twilio SIP integration runs in one direction for the fallback leg: 3CX is the SIP UAC (the caller), and your Twilio SIP Domain is the SIP UAS (the receiver). The customer never dials Twilio directly — they dial your inbound DID, and 3CX decides whether to connect them to an agent or forward to Twilio.
The Call Flow Step by Step
A customer dials your inbound DID. 3CX receives the call and routes it to the assigned queue or ring group. The queue rings all configured agents simultaneously for 10 seconds. If an agent picks up, the call connects normally. If no agent answers within the queue timeout, 3CX fires the Destination if no answer action. 3CX dials out through the SIP trunk to your Twilio SIP Domain URI. Twilio receives the SIP INVITE, authenticates it, and passes the call to your TwiML App, Studio flow, or AI agent webhook.
Why Twilio SIP Domain, Not Elastic SIP Trunking
Twilio Elastic SIP Trunking is designed for PSTN connectivity: it gives you inbound and outbound calls to regular phone numbers. For this use case, you don't need PSTN. You need a SIP endpoint inside Twilio's infrastructure that receives a SIP INVITE from 3CX and triggers a TwiML App or webhook.
The Twilio 3CX FQDN in this setup is the SIP Domain URI: something like yourdomain.sip.us1.twilio.com. This goes into your 3CX SIP trunk as the Registrar/Server address. When 3CX dials out through the trunk, it sends a SIP INVITE to this URI. Twilio receives it and routes it to your configured handler.
Setting Up the Twilio SIP Domain
Log in to console.twilio.com. In the left navigation, go to Explore Products, then Voice, then SIP Domains. Click Create new SIP Domain.
SIP Domain Name and URI
Give the SIP Domain a friendly name and choose a subdomain identifier. Twilio generates the full SIP Domain URI in the format your-identifier.sip.us1.twilio.com for the US1 region, or your-identifier.sip.ie1.twilio.com for EU. Copy the full URI — you'll paste it into 3CX's trunk configuration later.
TwiML App or Webhook
In the SIP Domain's Voice Configuration section, set "A call comes in" to TwiML App (if you've built a Twilio Studio flow or TwiML Bin) or to Webhook if you're pointing to an AI platform or custom application.
Authentication: Credential List or IP ACL
Twilio SIP Domains support two authentication methods. Choose one:
- Credential List: Create a credential list in Twilio with a username and password. Add it to the SIP Domain. In 3CX, enter the credentials in the trunk configuration. 3CX sends them in the SIP REGISTER or INVITE.
- IP ACL: Create an IP Access Control List in Twilio and add your 3CX server's public IP. In 3CX, set the trunk's authentication to Do not require (IP Based). No credentials needed.
For most IT teams, the IP ACL method is simpler to maintain. If your 3CX server has a static IP, use the IP ACL. If the IP changes or you can't whitelist it, use a credential list.
Our team at Third Rock Techkno has configured 3CX Twilio SIP integrations for IT teams across the USA, UK, Australia, and GCC. Talk to us →
Configuring 3CX: Queue, Ring Group, and Custom SIP Template
With the Twilio SIP Domain ready, move to the 3CX Management Console. The 3CX side of a 3CX Twilio SIP integration has five parts: queue or ring group, custom SIP template, trunk, DID mapping, outbound rule, and E164 setting.
Queue Setup
Navigate to Call Handling and add a new queue, or open an existing one. In Basic Settings, set the queue name. Leave Assigned DID number(s) empty for now. Add agents in the Users tab.
In Timing and Ring Strategy, configure these three values exactly as shown:
- Ring Strategy: Ring All
- Polling: 10 seconds
- Queue Timeout: 10 seconds (match your polling value)
In Destination if no answer, set Action to "Forward to Outside Number." Enter the Twilio phone number or SIP URI in full international format. This is the number 3CX dials via the SIP trunk when the queue times out.
Ring Group Setup (Alternative)
If your 3CX version doesn't support queues, use a ring group. Navigate to Call Handling and add a ring group. In Basic Settings, set the name and add user extensions. Leave Assigned DID number(s) empty. In the Timing section, set Ring Duration to 10 seconds. In Destination if no answer, set Action to Forward to Outside Number and enter the same Twilio number or SIP URI.
Custom SIP Template: Preserving Caller ID on the Forwarded Leg
Without the custom SIP template, when 3CX forwards the call to Twilio's SIP Domain, Twilio sees the 3CX trunk's own number instead of the original customer's caller ID. For any AI agent, voice bot, or IVR that needs to know who is calling, this breaks the entire flow.
First check your 3CX version: go to Admin, then Dashboard, and look at the version and update number in the system information panel.
Version 20.0 Update 8 (Build 1121 Release): Go to Advanced, then Templates, then Provider Templates. Click Import Provider and upload the template XML file. This creates the custom template directly in 3CX.
Version 20.0 Update 9 (Build 670 Alpha): Go to Advanced, then Templates, then Provider Templates. Find GenericSIPTrunk.pv.xml and click Create Copy. The built-in template can't be edited, so always work from the copy.
The four parameters that must be present in the template's ParameterOut section:
P-Asserted-Identity:$OriginatorCallerIDP-Preferred-Identity:$OriginatorCallerIDRemote-Party-ID:$OriginatorCallerIDFrom header CallerID:$OriginatorCallerID
These values must stay exactly as $OriginatorCallerID. Don't change them. The template also sets PCMU (G.711 ulaw) as the primary codec with PCMA and G.729 as fallbacks. G.711 is the correct choice for Twilio SIP Domain compatibility.
Creating the 3CX SIP Trunk, DID Mapping, Outbound Rule, and E164
With the queue and SIP template in place, you can create the trunk in 3CX that points to your Twilio SIP Domain, map the DID, add the outbound rule, and configure E164. These are the four steps that complete the call path from 3CX to Twilio.
Trunk General Settings
Navigate to Voice and Chat, then click Add Trunk. For Provider/Template, select the custom template you just created. Give the trunk a clear name such as "Twilio SIP Domain Trunk." For Default Route, leave it unset for now.
Server/Registrar Settings
In the Registrar/Server field, enter your Twilio SIP Domain FQDN exactly as it appears in the Twilio Console — for example yourdomain.sip.us1.twilio.com. Set Port to 5060. Set Outbound Proxy to the same FQDN. Leave SIP Transport as UDP.
DID Numbers
In the DID Numbers tab, click Add and enter your inbound customer-facing phone number. Leave Name empty. Leave Assigned To as Unassigned. You'll connect this DID to the queue or ring group in the next step.
Mapping the DID to the Queue or Ring Group
Navigate back to Call Handling and open your queue or ring group. In Assigned DID number(s), select the DID you just added. This closes the inbound routing chain: customer dials the DID, 3CX matches it to the queue, agents ring, and on timeout the call forwards outbound to Twilio.
Outbound Rule
An outbound rule tells 3CX which SIP trunk to use when it dials out for the queue fallback. Without it, 3CX doesn't know to use the Twilio SIP trunk for that outbound leg, and the call drops with a busy signal or routing error.
Navigate to Outbound Rules and add a new rule. Set Route 1 to the Twilio SIP Domain trunk you created. Set Strip Digits to "Strip no digits." Leave Prepend blank.
E164 Setting
Go to Advanced, then E164. Make sure "Process E164 numbers" is disabled. With E164 enabled, 3CX reformats the destination number you entered in Destination if no answer. This breaks the outbound SIP call to Twilio — the reformatted number doesn't match any Twilio SIP routing rule and the call either fails or connects to the wrong handler.
TRT's VoIP engineers handle end-to-end 3CX Twilio SIP configuration for businesses in the USA, UK, Australia, and GCC. Talk to us →
Pre-Go-Live Checklist and Troubleshooting
Before making test calls, verify both sides of the configuration. Nearly every failure in a 3CX Twilio SIP integration traces back to one item on this list.
Pre-Go-Live Checklist
- Twilio SIP Domain created with correct subdomain and FQDN noted.
- TwiML App or webhook configured and tested independently.
- Authentication set up: IP ACL with 3CX public IP listed, or credential list created and attached.
- Custom SIP template imported in 3CX with all four $OriginatorCallerID parameters present.
- 3CX SIP trunk created with the custom template and Twilio FQDN as Registrar/Server.
- DID added to trunk DID Numbers tab.
- DID assigned to queue or ring group.
- Outbound rule created with Route 1 pointing to the Twilio SIP trunk.
- E164 disabled in 3CX Advanced settings.
- Test call placed — all agents set to DND — confirming Twilio receives the call and the caller ID is the original customer number, not the trunk number.
Troubleshooting Common Issues
Twilio receives no call when queue timeout fires. The outbound rule is missing or pointing to the wrong trunk. Check Outbound Rules in 3CX and confirm Route 1 is the Twilio SIP Domain trunk. Also verify the queue's Destination if no answer action is set to Forward to Outside Number — not voicemail or another internal extension.
Twilio receives the call but rejects it with a 403. Authentication is failing. If you're using IP ACL, confirm your 3CX public IP is listed in the Twilio IP ACL and that the ACL is attached to the SIP Domain. If you're behind NAT, 3CX may be sending a different source IP than what you whitelisted.
Twilio sees the wrong caller ID on the forwarded call. The custom SIP template isn't applied to the trunk, or one or more of the four $OriginatorCallerID parameters are missing from the template. Open the template in 3CX's Provider Templates section and verify all four headers are present with the correct values.
Call drops immediately after forwarding. E164 is enabled in 3CX and reformatting the destination number before it reaches Twilio. Go to Advanced, E164, and disable "Process E164 numbers." Also confirm port 5060 outbound is not blocked by a firewall on the 3CX server.
Agents aren't being rung before fallback. User extensions may not be added to the queue or ring group, or one or more has Do Not Disturb active. Open the queue's Users tab and confirm all relevant extensions are listed and DND is off.
GCC Deployment Note
For the UAE, Saudi Arabia, Bahrain, and Qatar, the 3CX configuration is identical to US and UK deployments. Whether you're running Twilio elastic SIP trunking 3CX with PSTN numbers or a pure SIP Domain setup, the 3CX side is the same. For the Twilio SIP Domain region, use IE1 (yourdomain.sip.ie1.twilio.com) for lower latency from the Gulf.
Conclusion
3CX Twilio SIP integration in the 3CX-to-Twilio direction is a nine-step process: Twilio SIP Domain with TwiML App and authentication, custom SIP template in 3CX with four $OriginatorCallerID parameters, trunk pointing to the Twilio FQDN, DID mapped to the queue, outbound rule routing through the trunk, and E164 disabled.
Get those nine steps right and the integration is stable and repeatable. Your 3CX queue handles the inbound side. Twilio handles the fallback — whether that's an IVR, a Studio flow, or an AI voice agent — without touching your existing PBX setup.