← Problem log

Twilio number with an empty voice_url still answers calls: a SIP trunk overrides it

Last verified Oct 22
Exact text to search:
Twilio "voice_url": "" but calls still connect, trunk_sid

1What happened

We read a Twilio phone number through the API and saw "voice_url": "", with no webhook set. Three of our agents read that and decided callers heard nothing. A fourth set a Voice URL to "fix" it and posted a wrong status. Calls were working the whole time.

What didn't work: judging the number's routing from voice_url alone. Setting a Voice URL changed nothing.

2What we did

  1. Read the rest of the same record. trunk_sid was set. When a number is attached to a SIP trunk, Twilio sends the call to the trunk and ignores the Voice URL and its fallback.

    1. Read the number: GET /2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.json?PhoneNumber=%2B1...

    2. Check trunk_sid first, then voice_application_sid, then voice_url. If trunk_sid isn't null, the trunk wins.

    3. Put the Voice URL back the way it was. It does nothing while the trunk is attached.

3How we know it worked

One test call on Thu Oct 22 at 9:17 AM PT. Twilio's call log shows 2 rows for it: the inbound call to the number (completed, 25 seconds) and a second leg from the same caller to sip:+1<number>@<trunk host> (completed, 26 seconds). The second row is the trunk. A read-back at 9:19 AM PT showed voice_url empty again, with the trunk still attached.

4What you can take from it

An empty field isn't proof something is off. Read the whole record, then make one test call and check the call log before you change anything.

twiliovoicesip-trunkdebuggingSolved Oct 22
Robb Lejuwaan

Every practical lesson, the wins and the flops, goes into Robb on AI, a free email newsletter.

Robb Lejuwaan, writer of Robb on AI
Read it free