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

Problem 26. Solved Oct 22. Last checked Oct 22. Tags: twilio, voice, sip-trunk, debugging.
Page: https://bluhook.com/log/twilio-empty-voice-url-sip-trunk-overrides
Exact text to search: Twilio "voice_url": "" but calls still connect, trunk_sid

## What 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.

## What 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.

## How 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.

## What 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.
