https://retellai.com/?utm_source=discord&utm_medium=seo logo
can you advise me on sip trunk set up from twiilo
# ❓・ai-evy-support
c
@AI Evy can you advise me on sip trunk set up from twiilo?
a
Thanks for tagging me @Client Nexus. I'll look through relevant sources and get back to you shortly.
### Answer Here's a step-by-step guide for setting up Twilio SIP trunking with Retell AI: ## Step 1: Create Elastic SIP Trunking in Twilio [(1) ]() 1. Create the trunk and give it a name 2. Setup Termination (for outbound calls) : - Note the termination SIP URI — you'll need it later - Use a localized termination URI near your region - Whitelist IP addresses or create auth with username/password - If using credentials, you'll need to specify them when importing the number to Retell 3. Setup Origination (for inbound calls) : - Set Retell's SIP server address as the origination SIP URI:
sip:sip.retellai.com
## Step 2: Move Numbers to Elastic SIP Trunking Purchase numbers or move existing numbers to this trunk in Twilio. ## Step 3: Import Numbers to Retell Import the number to Retell so it knows how to route calls. - Supply the termination SIP URI from Step 1 - If you set up auth via credentials, supply the username and password - You can also import programmatically via the [Import Number API]() [(2) ]() ## Common Issues [(1) ]() Outbound not working? - Check your Termination SIP URI for spaces and remove them - Use a localized termination URI near your region - Verify username and credentials are correct (username is different from the friendly name in the credential list) International dialing? - Search "geo" to find "Voice Geographic Permissions" setting, choose "Elastic Sip Trunking", and select the countries you want to dial
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy Is phone number +551150390856 imported in workspace with API key starting with key_... (your per-agency workspace)? What is the phone_number_id for this number in Retell? Is there a termination_uri configured for this number? Is there an inbound_agent_id / outbound_agent_id assigned? Why does Telephony_provider_permission_denied occur - is it missing termination_uri or SIP trunk not configured?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer I don't have access to your workspace data or API keys, so I cannot look up specific phone numbers, their IDs, or configurations in your account. However, I can help you check this yourself using the Retell API: To verify if a number is imported and see its configuration, use the List Phone Numbers API [(1) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponses = await client.phoneNumber.list() ;
console.log(phoneNumberResponses) ;
This will return all phone numbers in your workspace, including their
phone_number
,
inbound_agent_id
,
outbound_agent_id
, and other configuration details. **Regarding `telephony_provider_permission_denied`**: This disconnection reason indicates the telephony provider denied permission for the call. [(2) ]() Common causes include: 1. Missing or incorrect
termination_uri
— For Twilio, this should end with
.pstn.twilio.com
[(3) ]() 2. SIP trunk authentication issues — Verify your
sip_trunk_auth_username
and
sip_trunk_auth_password
are correct 3. Number not properly imported — Ensure the number was imported with the correct termination URI 4. Geographic permissions — For international numbers like Brazil (+55) , check Twilio's Voice Geographic Permissions settings [(4) ]() To troubleshoot, check your Termination SIP URI for spaces, use a localized termination URI, and verify credentials are correct (username differs from the friendly name) .
​ To learn more, see the sources I considered: [[1] List Phone Numbers](https://docs.retellai.com/api-references/list-phone-numbers) [[2] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[3] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[4] I’m trying to use a toll-free number (connected from Twilio through a SIP trunk)](https://retell.discourse.group/t/i-m-trying-to-use-a-toll-free-number-connected-from-twilio-through-a-sip-trunk/127) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy I have imported a brazilian number from twiilio to retell is showing there, but calls are not being made it is showing in retell hisotiry telephony provider permission denied, what do we need to check to set up correctly?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer The
telephony_provider_permission_denied
error means the SIP trunk credentials are not authenticated. [(1) ]() Here's what to check for your Brazilian Twilio number: 1. Verify Termination SIP URI Configuration [(2) ]() - Ensure there are no spaces in your Termination SIP URI - Use a localized termination URI near your region (check [Twilio's localized URIs documentation]() ) 2. Verify Username and Password - The username is not the friendly name shown in the credential list — these are different - Double-check you entered the correct username and password when importing the number to Retell 3. Check Twilio Geographic Permissions - In Twilio, search "geo" to find "Voice Geographic Permissions" - Select "Elastic Sip Trunking" and ensure Brazil is enabled for outbound dialing 4. Re-import the Number if Needed [(3) ]() - If the configuration is incorrect, delete the imported number and re-import with the correct termination URI and credentials 5. Check Twilio Logs [(4) ]() - Review logs in your Twilio console to see the specific error on their side — this can help identify if the issue is with credentials, permissions, or the number itself If you've verified all the above and it still doesn't work, contact Twilio support to check if there are any restrictions on your account or number for international outbound calls.
​ To learn more, see the sources I considered: [[1] Debug call disconnection](https://docs.retellai.com/reliability/debug-call-disconnect) [[2] Twilio](https://docs.retellai.com/deploy/twilio) [[3] Debug outbound connection issues](https://docs.retellai.com/reliability/debug-outbound-call) [[4] Outbound sip call getting Telephony_provider_permission_denied error](https://discord.com/channels/1186424376300679209/1433144721429106738) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy What username was used for SIP credentials? Note: The 'friendly name' bartelli-824dfee7 is NOT the username - I need to check the actual credential username in Twilio.
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer I don't have access to your Twilio account to look up your specific SIP credentials. To find the actual SIP credential username in Twilio (not the friendly name) , you need to: 1. Go to your Twilio Console → Elastic SIP Trunking → your trunk → Termination → Credentials [(1) ]() 2. The friendly name (like
bartelli-824dfee7
) is different from the username — you need to check the actual username you created when setting up credentials , [(2) ](

▾

) When creating credentials in Twilio, you specify both a friendly name and a username separately. The video tutorial shows this process: "Give your credentials a friendly name... Then I need to give this a username." To verify your username: - In the Twilio credential list, click on the credential entry - Look for the actual username field (not the friendly name displayed in the list) - This is the value you need to enter in Retell when importing the number If you can't find the original username, you may need to create new credentials in Twilio and then re-import the number to Retell with the correct username and password. [(1) ]()
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Retell AI - Connect to your own Twilio - Using Sip Trunking](

https://www.youtube.com/watch?v=JC3PV_R-Z1Y▾

) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy can you provide me a full set up list to make sure i have correctly set in my software? im basically have twilio to buy the phone numbers > user buy phones numbers from my software > and its sent to retell ai so the ai can use to do calls. this is our current set up, but in retell ai the call log show there but the only info provided is end reason = "telephony provider permission denied" and session status "not_connected"
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Here's the complete setup checklist for Twilio → Your Software → Retell AI: ## Step 1: Create Elastic SIP Trunk in Twilio [(1) ]() 1. Create the trunk and give it a name 2. Configure Termination (for outbound calls) : - Note the termination SIP URI (use a localized URI near your region) - Set up authentication via credentials (username/password) — this is required since Retell SIP server does not have a static IP - Important: The username you create is NOT the friendly name — these are different values 3. Configure Origination (for inbound calls) : - Set origination SIP URI to:
sip:sip.retellai.com
## Step 2: Move Numbers to the SIP Trunk Purchase numbers or move existing numbers to this elastic SIP trunk in Twilio. ## Step 3: Import Numbers to Retell When importing each number to Retell, you must provide: - The termination SIP URI from Step 1 - The username (not the friendly name) and password from your credentials ## Step 4: Assign Agents to Numbers [(2) ]() Ensure each imported number has an
outbound_agent_id
configured:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.update('+14157774444', {
  inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  outbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
## Troubleshooting
telephony_provider_permission_denied
[(1) ]() , [(3) ]() - Check Termination SIP URI for spaces — remove them [(1) ]() - Verify the actual username (not friendly name) and password are correct - Check Twilio logs to see the specific error on their side [(3) ]() - For international numbers (like Brazil) , enable geographic permissions in Twilio: search "geo" → "Voice Geographic Permissions" → select "Elastic Sip Trunking" → enable the country [(1) ]()
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) [[3] Outbound sip call getting Telephony_provider_permission_denied error](https://discord.com/channels/1186424376300679209/1433144721429106738) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy im setting the sip trunk, the phone number shows in retell but for the call agent both fields inbound and outbound shows none disable inbound/disable outbound, why? is this correct? will use the ai agent imi have set in my app to do the call? or its mandatory have an agent here to work? i have tested selecting one ai agent in both fields but even thought the call in retell shows "telephony provider permission denied", so two questions, is this call agent necessary have one? and if so can we auatomized this? would be better so users can select to set thghis in our app and then the phone number is choosed, as the normal set up, like user get phone number in our app like we buy from retell and then the ai agent is assigne when the user set
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer 1. Is an agent assignment necessary? For **inbound calls**: If
inbound_agent_id
is null, the number will not accept inbound calls. [(1) ]() For **outbound calls**: If
outbound_agent_id
is null, the number cannot initiate outbound calls without an agent id override in the API request. So you have two options: - Assign a default agent to the number - OR pass
override_agent_id
when making each outbound call via the API 2. Can you automate agent assignment? Yes. When importing numbers programmatically, you can include
inbound_agent_id
and
outbound_agent_id
in the import request:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.import({
  phone_number: '+14157774444',
  termination_uri: 'someuri.pstn.twilio.com',
  inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  outbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
3. About the
telephony_provider_permission_denied
error
This is a separate issue from agent assignment. Even with an agent assigned, you'll still get this error if your SIP trunk credentials or configuration are incorrect. [(2) ]() The error means the SIP trunk authentication failed. You need to: - Verify your
termination_uri
is correct (for Twilio, ends with
.pstn.twilio.com
) [(1) ]() - Verify the
sip_trunk_auth_username
and
sip_trunk_auth_password
are the actual credentials (not the friendly name) [(2) ]() - If configuration is incorrect, delete the imported number and re-import with correct details
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[2] Debug outbound connection issues](https://docs.retellai.com/reliability/debug-outbound-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer It looks like you just tagged me without a specific question. Based on our conversation thread, here's a quick summary of where things stand: Your Issue:
telephony_provider_permission_denied
error with Brazilian Twilio number imported via SIP trunk [(1) ]() Root Cause: SIP trunk credentials are not authenticated Key Things to Verify: 1. Termination SIP URI — no spaces, use localized URI [(2) ]() 2. SIP credentials — use the actual username (not the friendly name) and correct password 3. Geographic permissions in Twilio — ensure Brazil is enabled for Elastic SIP Trunking Agent Assignment: If
outbound_agent_id
is null, the number cannot initiate outbound calls without an
override_agent_id
in the API request [(3) ]() If you have a specific question or need help with a particular step, let me know!
​ To learn more, see the sources I considered: [[1] Debug call disconnection](https://docs.retellai.com/reliability/debug-call-disconnect) [[2] Twilio](https://docs.retellai.com/deploy/twilio) [[3] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy we a restill having the error "telephony provider permission denied" can you advise? Our full setup (end-to-end) A) Buying/importing the Brazil AI number (Twilio → SIP Trunk → Retell) This is done by supabase/functions/retell-manage-phone-numbers with action purchaseInternationalNumber: Ensure Twilio subaccount exists for the agency (ensureTwilioSubaccount). Create or reuse a Twilio Elastic SIP Trunk in that same Twilio subaccount via twilio-sip-trunk-setup: Creates trunk with DomainName = {sanitizedName}-{accountIdPrefix} Adds Origination URL (for inbound): sip:sip.retellai.com;transport=tcp Creates Credential List + Credential (username/password), then associates it to the trunk for Termination: POST .../SIP/CredentialLists POST .../CredentialLists/{sid}/Credentials (Username/Password) POST https://trunking.twilio.com/v1/Trunks/{trunkSid}/CredentialLists (attach list to trunk) Saves in accounts: twilio_sip_trunk_sid twilio_sip_username twilio_sip_password_encrypted (stored plaintext in current code) Purchase the BR number from Twilio (in the agency Twilio subaccount), including BundleSid + AddressSid if required. Attach the purchased number to the SIP trunk: POST https://trunking.twilio.com/v1/Trunks/{trunkSid}/PhoneNumbers with PhoneNumberSid= Import the number into Retell with SIP termination + credentials: POST https://api.retellai.com/import-phone-number body: { "phone_number": "+55....", "termination_uri": "{trunkDomain}.pstn.twilio.com", "sip_trunk_auth_username": "", "sip_trunk_auth_password": "", "inbound_agent_id": "", "outbound_agent_id": "" } Save in phone_numbers: phone_number_type = 'ai_only' phone_provider = 'retell' retell_phone_number_id = retellData.phone_number_id twilio_sid = purchasedNumber.sid country_code = 'BR'
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Your setup flow looks correct in structure, but here are specific items to verify based on the
telephony_provider_permission_denied
error: 1. Termination URI Format [(1) ]() - Ensure your
termination_uri
has no spaces and uses a localized termination URI near your region - For Twilio, it should end with
.pstn.twilio.com
[(2) ]() - Check [Twilio's localized URIs documentation]() to select one appropriate for your region 2. Credential Username vs Friendly Name [(1) ]() , [(3) ](

▾

) - The username you create is NOT the friendly name — these are different values - When you create credentials via
POST .../CredentialLists/{sid}/Credentials
, the username you specify there is what must be passed to Retell, not the credential list's friendly name 3. Geographic Permissions in Twilio [(1) ]() - Search "geo" in Twilio to find "Voice Geographic Permissions" - Select "Elastic Sip Trunking" and ensure Brazil is enabled for outbound dialing 4. Verify in Twilio Logs [(4) ]() - Check the logs in your Twilio console to see the specific error on their side — this can help identify if the issue is with credentials, permissions, or the number itself 5. Re-import if Configuration is Incorrect - If the configuration is not correct, delete the imported number and re-import with corrected details One potential issue I see: You mention
twilio_sip_password_encrypted (stored plaintext in current code)
— ensure the actual password value (not an encrypted/hashed version) is
being sent to Retell in the import request.
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[3] Retell AI - Connect to your own Twilio - Using Sip Trunking](

https://www.youtube.com/watch?v=JC3PV_R-Z1Y▾

) [[4] Debug outbound connection issues](https://docs.retellai.com/reliability/debug-outbound-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy ) “Fix” flow you ran (what it actually does) supabase/functions/diagnose-international-phone action fix does: Confirms number exists in the correct Twilio account/subaccount Ensures trunk has a domain and the number is attached to trunk Updates or imports the Retell phone number again with: termination_uri = {domain}.pstn.twilio.com sip_trunk_auth_username/password from accounts.twilio_sip_* So your screenshot “fixed successfully” only proves the metadata was updated; it doesn’t prove Twilio accepted auth from Retell. C) Outbound call initiation (Retell create-phone-call) Both initiate-call and initiate-demo-call ultimately call Retell: POST https://api.retellai.com/v2/create-phone-call { "from_number": "+55... (selectedPhone.phone_number)", "to_number": "+55...(destination)", "override_agent_id": "", "retell_llm_dynamic_variables": { ... }, "metadata": { ... } } Retell then uses the imported phone number configuration (termination URI + SIP creds) to reach Twilio via SIP trunk. What to verify with Twilio + Retell (most likely root cause) Given your specific Retell messages, the likely issue is termination auth mismatch (Retell is sending creds that Twilio isn’t accepting for that trunk). Ask Twilio/Retell to confirm these exact items: Twilio Console → (the same subaccount that owns the Brazil number) → Elastic SIP Trunk Trunk Domain matches what Retell shows as termination_uri (yours: bartelli-824dfee7.pstn.twilio.com) Under Termination → Authentication → Credential Lists: The credential list is attached It contains the exact sip_username we generated (format: sip_{sanitizedName}_{accountId8}) Password matches what Retell currently has The Brazil phone number is attached to that trunk Twilio trunk → Phone Numbers includes that PN... for +55... Twilio Voice Geographic Permissions (subaccount) WHAT ABOTU THIS?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Your verification checklist is correct. Here's what the documentation confirms you need to check: 1. Termination SIP URI [(1) ]() - Check for spaces in the URI and remove them - Use a localized termination URI near your region — check [Twilio's localized URIs documentation]() to select one 2. Username vs Friendly Name - The username is NOT the friendly name that shows in the credential list - The friendly name is different from the username — you need to verify the actual credential username in Twilio 3. Credential List Attachment - Confirm the credential list is attached to the trunk under Termination → Authentication 4. Phone Number Attached to Trunk - Verify the Brazil phone number is attached to the trunk 5. Geographic Permissions - Search "geo" to find "Voice Geographic Permissions" - Choose "Elastic Sip Trunking" and ensure Brazil is enabled 6. Localized URI Recommendation [(2) ]() - Set a localized URI closest to your region instead of the default — for example, use a regional URI like
yourtrunk.pstn.twilio.com
Your "fix" flow updating metadata doesn't prove Twilio accepted auth — you need to verify the actual credentials match in both systems.
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Hey everyone, I could use some help setting up international calls through Retell + Twilio.](https://discord.com/channels/1186424376300679209/1384845104132522024) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy im setting the sip´trunking in retell, in the termination in the console in twiilio show the termination sip uri, the one im using but also show "sho localized uri's" and there have spoecific coutntries and regions trunks, which one should i use? the main one? is to do global cals, but im setting this for now to use brazil phone number doing brazil calls, but would be good to set to international, but not sure if this impact or its a game changer plz advise
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Use a localized termination URI near your region. [(1) ]() For your Brazil number making Brazil calls, you should select a localized URI closest to Brazil/South America from the "show localized URIs" dropdown in Twilio. Why this matters: - The localized termination URI is recommended because it routes calls through infrastructure closer to your region, which can improve call quality and reduce latency - You can expand and view your localized URIs in the Twilio console For international calls: - If you plan to make calls to multiple countries, you have two options: 1. Use the main/default termination URI for general global coverage 2. Use a regional URI closest to where most of your calls will originate Recommendation for your setup: Since you're currently focused on Brazil-to-Brazil calls, select the South America or Brazil-specific localized URI from Twilio's list. This should also help resolve your
telephony_provider_permission_denied
error, as using the correct regional URI is one of the documented troubleshooting steps. When you expand to international calls later, you can update the termination URI — note that to change configuration on an imported number, you need to delete and re-import it. [(4) ]()
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy i want to know if using the main uri should be a reason on why our calls are not working with this sip number. also advise on Also: Retell mentioned “localized URIs”. If Retell requires a localized termination hostname, we need their exact expected format for Twilio Elastic SIP trunking in your region (this is not something we should guess).
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Can using the main URI cause calls to fail? Yes, using the main/default termination URI instead of a localized one could contribute to issues. The documentation states: "You might want to use a localized termination uri that's near your region. You can expand and view your localized uris in the twilio console." [(1) ]() Localized URI Format for Twilio Retell does not specify a proprietary format for localized URIs — the format comes from Twilio. The documentation directs you to Twilio's own documentation: "Check out this [doc]() to select one." For Twilio Elastic SIP Trunking, the termination URI always ends with
.pstn.twilio.com
. [(2) ]() What to do: 1. Go to your Twilio Console → Elastic SIP Trunking → your trunk → Termination [(1) ]() 2. Click "show localized URIs" to see region-specific options 3. Select the localized URI closest to Brazil/South America 4. Use that URI when importing the number to Retell Important: Using a localized URI is recommended but the documentation does not state it's strictly required. The
telephony_provider_permission_denied
error is more likely caused by incorrect credentials (username vs friendly name mismatch) or geographic permissions not being enabled for Brazil in Twilio.
​ To learn more, see the sources I considered: [[1] Twilio](https://docs.retellai.com/deploy/twilio) [[2] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
c
@AI Evy when im adding a phone number in retell from sip, the first field is phone number, then i add the correct phone number i think, the format im using is +557140400866 this is a brazilian number is correct? also the name after i save changed to +55(714)040-0866 not sure if the name impact in anything, bceause the () is the brazil state code and it is 71 but its adding automaticlly the 4 inside the ()
a
### Answer Phone Number Format The phone number must be in **E.164 format**:
+country code, then number with no space, no special characters
. [(1) ]() For your Brazilian number, the format
+557140400866
appears correct — it includes the
+55
country code followed by the number. About the Display Name Change The
phone_number_pretty
field is a "pretty printed phone number, provided for your reference." This is just a display format and does not affect functionality — it's cosmetic formatting that Retell applies automatically. The actual phone number stored and used for calls remains in E.164 format (what you entered) . The parentheses and formatting in the display name shouldn't impact your calls. Potential Issue to Check Looking at the pretty format
+55(714) 040-0866
, it seems to be grouping digits incorrectly. Brazilian numbers typically have a 2-digit area code (like 71 for Bahia) . If your original number is correct in E.164 format, this display quirk shouldn't affect functionality — but double-check that the underlying
phone_number
value stored is exactly
+557140400866
without any extra digits. Your
telephony_provider_permission_denied
error is more likely related to the SIP credentials or geographic permissions issue we discussed earlier, not the phone number format itself.
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy we ideintified one issue, when i called the number the ai pick up! so its only not working when itry to trigger the call what could be?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer ### Answer This is a key diagnostic finding. Inbound works, outbound fails — this means: - Origination (inbound) is configured correctly — Retell can receive calls via
sip:sip.retellai.com
[(1) ]() - Termination (outbound) has an issue — the SIP trunk authentication for outbound calls is failing [(2) ]() The
telephony_provider_permission_denied
error specifically means the SIP trunk authentication failed.
[(3) ]() What to check for outbound-specific issues: 1. Termination credentials — Verify the
sip_trunk_auth_username
and
sip_trunk_auth_password
you imported to Retell match exactly what's configured in Twilio under Termination → Authentication → Credential Lists [(2) ]() 2. Username vs Friendly Name — Confirm you're using the actual username (not the friendly name) from the credential [(4) ]() 3. Termination SIP URI — Check for spaces in the URI and remove them; use a localized termination URI near your region [(1) ]() 4. Geographic Permissions in Twilio — For outbound calls to Brazil, ensure Brazil is enabled under Voice Geographic Permissions → Elastic SIP Trunking Recommended next step: Since inbound works but outbound doesn't, the issue is isolated to your Termination configuration. Double-check the credential username/password in Twilio's Termination settings and ensure they match what Retell has stored. If incorrect
, delete the imported number and re-import with the correct credentials. [(2) ]()
​ To learn more, see the sources I considered: [[1] I’m trying to use a toll-free number (connected from Twilio through a SIP trunk)](https://retell.discourse.group/t/i-m-trying-to-use-a-toll-free-number-connected-from-twilio-through-a-sip-trunk/127) [[2] Debug outbound connection issues](https://docs.retellai.com/reliability/debug-outbound-call) [[3] Debug call disconnection](https://docs.retellai.com/reliability/debug-call-disconnect) [[4] Outbound sip call getting Telephony_provider_permission_denied error](https://discord.com/channels/1186424376300679209/1433144721429106738) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy fpor the sip trunk do i need to click in "add an inbound webhook" to use the twiilio numbers to receive calls? also does it have different sip trunks set up to inbound and outbound? or is the same edit phone number setting? "Edit SIP Trunk Phone Number Settings"
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] Inbound webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[3] Update Phone Number](https://docs.retellai.com/api-references/update-phone-number) ​
### Answer Do you need an inbound webhook to receive calls? No, the inbound webhook is optional. It's used when you want to customize behavior for each incoming call — like overriding the agent, setting dynamic variables, or filtering/rejecting certain calls. [(1) ]() If you have an
inbound_agent_id
assigned to the phone number, inbound calls will work without a webhook. The webhook is only needed if you want per-call customization. Same SIP trunk for inbound and outbound? Yes, it's the same phone number configuration in Retell. When you import a phone number, you provide: [(2) ]() -
termination_uri
— used for outbound calls (Retell → Twilio) -
inbound_agent_id
— handles inbound calls -
outbound_agent_id
— handles outbound calls The "Edit SIP Trunk Phone Number Settings" in Retell covers both directions in one configuration. You can update these settings via the API: [(3) ]()
Copy code
javascript
const phoneNumberResponse = await client.phoneNumber.update('+14157774444', {
  inbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  outbound_agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  inbound_webhook_url: '<https://example.com/inbound-webhook',>
}) ;
Since your inbound calls already work, your origination (Twilio → Retell via
sip:sip.retellai.com
) is configured correctly. The outbound issue is isolated to termination credentials.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy so basically the only issue is the termination set up?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Yes, based on your diagnostic findings: - Inbound works → Origination is configured correctly (Twilio → Retell via
sip:sip.retellai.com
) [(1) ]() - Outbound fails with
telephony_provider_permission_denied
→ Termination authentication is failing [(2) ]() , [(3) ]() The
telephony_provider_permission_denied
error specifically represents cases where the SIP trunk authentication failed. What to verify in your termination setup: 1. Termination SIP URI — Check for spaces and use a localized termination URI near your region [(1) ]() 2. Credentials — Ensure
sip_trunk_auth_username
and
sip_trunk_auth_password
match exactly what's in Twilio's Termination → Authentication → Credential Lists [(3) ]() 3. Username vs Friendly Name — Use the actual username, not the friendly name 4. Geographic Permissions — Ensure Brazil is enabled under Elastic SIP Trunking in Twilio If the configuration is incorrect, delete the imported number and re-import with correct details.
​ To learn more, see the sources I considered: [[1] Custom Telephony Overview](https://docs.retellai.com/deploy/custom-telephony) [[2] Debug call disconnection](https://docs.retellai.com/reliability/debug-call-disconnect) [[3] Debug outbound connection issues](https://docs.retellai.com/reliability/debug-outbound-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy what is the correct format for termination uri?
a
Thanks for the follow-up, @Client Nexus. I'll get back to you soon.
### Answer Termination URI Format for Twilio Elastic SIP Trunking: For Twilio, the termination URI always ends with
.pstn.twilio.com
. [(1) ]() Example format:
Copy code
someuri.pstn.twilio.com
Key requirements: 1. No spaces — Check your termination SIP URI and remove any spaces if present [(2) ]() 2. Use a localized termination URI near your region — you can expand and view your localized URIs in the Twilio console 3. The URI should match your trunk's domain name followed by
.pstn.twilio.com
[(1) ]() For your setup: Your current format
{trunkDomain}.pstn.twilio.com
(e.g.,
bartelli-824dfee7.pstn.twilio.com
) follows the correct pattern. However, check [Twilio's localized URIs documentation]() to select a regional termination URI closer to Brazil for better performance. [(2) ]() When importing to Retell via API:
Copy code
javascript
const phoneNumberResponse = await client.phoneNumber.import({
  phone_number: '+14157774444',
  termination_uri: 'someuri.pstn.twilio.com',
}) ;
[(1) ]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[2] Twilio](https://docs.retellai.com/deploy/twilio) ​