ruta1212_29251
10/28/2025, 11:34 AMAI Evy
10/28/2025, 11:34 AMAI Evy
10/28/2025, 11:35 AMjavascript
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',
}) ;
console.log(phoneNumberResponse.inbound_agent_id) ;
Required parameters:
- `phone_number`: The number in E.164 format (e.g., "+14157774444")
- `termination_uri`: The termination URI to uniquely identify your elastic SIP trunk (for Twilio elastic SIP trunks it always ends with ".pstn.twilio.com")
Optional parameters:
- `sip_trunk_auth_username`: Username for SIP trunk authentication
- `sip_trunk_auth_password`: Password for SIP trunk authentication
- `inbound_agent_id`: Agent ID to bind for inbound calls
- `outbound_agent_id`: Agent ID to bind for outbound calls
- `nickname`: A reference name for the number
- `inbound_webhook_url`: Webhook URL for inbound calls
If you want to purchase a new number from Retell instead, check out the [Create Phone Number API Reference]() [(2) ]() .AI Evy
10/28/2025, 11:35 AMAI Evy
10/28/2025, 11:35 AMruta1212_29251
10/28/2025, 11:44 AMAI Evy
10/28/2025, 11:45 AMAI Evy
10/28/2025, 11:45 AMsomeuri.pstn.twilio.com) . Remove any spaces in the URI
- **Origination SIP URI**: Must be set to sip:sip.retellai.com
2. Authentication Setup
For termination to accept Retell's outbound requests, you need either:
- Whitelist all IP addresses in the range (Retell currently doesn't have static IPs)
- Create credentials with username and password
3. Move Number to Elastic SIP Trunk
Ensure your purchased number is actually assigned to the Elastic SIP trunk you created
4. Import with Correct Parameters [(2) ]()
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',
sip_trunk_auth_username: 'username', // if using auth
sip_trunk_auth_password: '123456', // if using auth
}) ;
Common Issues: [(1) ]()
- Space in Termination SIP URI
- Wrong username (use the actual username, not the friendly name from credential list)
- Number not moved to the trunk
- Missing geo permissions for international dialing
Check your Twilio console to verify all these settings are correct.AI Evy
10/28/2025, 11:45 AMAI Evy
10/28/2025, 11:45 AMruta1212_29251
10/28/2025, 12:22 PMAI Evy
10/28/2025, 12:22 PMAI Evy
10/28/2025, 12:22 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
await client.phoneNumber.delete('+14157774444') ;
API Details:
- **Method**: DELETE
- **Endpoint**: /delete-phone-number/{phone_number}
- **Authorization**: Bearer token with your API key in the header
- **Path Parameter**: phone_number in E.164 format (e.g., "+14157774444")
- **Response**: 204 No Content on success
The phone number parameter must be in E.164 format (country code + number with no spaces or special characters) .
According to community discussions, when you delete a number purchased through Retell, billing for that number stops [(2) ]() [(3) ]() . The Delete Phone Number API is available at the endpoint documented in the official API reference [(3) ]() .AI Evy
10/28/2025, 12:22 PMAI Evy
10/28/2025, 12:22 PMruta1212_29251
10/28/2025, 1:22 PMAI Evy
10/28/2025, 1:22 PMAI Evy
10/28/2025, 1:22 PMretell_llm_dynamic_variables must be strings [(1) ]() . This requirement applies to all data types—numbers, booleans, and null values must all be converted to strings .
Based on the documentation, when using the inbound webhook to pre-populate dynamic variables, any non-string values (including INT and BOOL values) will cause issues . The solution is to cast all values to strings before sending them .
So for null values, you should convert them to the string "null" or use an empty string "" depending on your use case, rather than sending a raw null value.
**AI Evy
10/28/2025, 1:22 PMAI Evy
10/28/2025, 1:22 PM