miguel
10/31/2025, 10:48 AMAI Evy
10/31/2025, 10:48 AMAI Evy
10/31/2025, 10:49 AM"+14157774444")
- `to_number`: The destination number in E.164 format (e.g., "+12137774445")
Common Issues That Cause 400 Errors:
1. **Phone Number Configuration**: Your from_number must be properly configured in Retell [(2) ]() . If the number doesn't have an outbound_agent_id set, you need to include override_agent_id in your request .
2. **Parameter Names**: Ensure you're using the correct parameter names :
- Use override_agent_id (not agent_id)
- Use retell_llm_dynamic_variables (not custom_data)
3. **E.164 Format**: Both phone numbers must be in proper E.164 format with country code [(1) ]()
Correct Request Format:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.createPhoneCall({
from_number: '+14157774444',
to_number: '+12137774445',
}) ;
console.log(phoneCallResponse.agent_id) ;
If using override parameters: [(2) ]()
json
{
"from_number": "+16504144521",
"to_number": "your_target_number",
"override_agent_id": "agent_71724df7636716ceb3a7e244c8",
"retell_llm_dynamic_variables": {
"name": "Sarah"
}
}AI Evy
10/31/2025, 10:49 AMAI Evy
10/31/2025, 10:49 AMmiguel
10/31/2025, 10:56 AMAI Evy
10/31/2025, 10:56 AMAI Evy
10/31/2025, 10:56 AMoverride_agent_id to null [(1) ]() .
The Issue:
When you don't specify an agent, you need to either:
1. Have an outbound_agent_id configured on your phone number, OR
2. Provide a valid override_agent_id in your request
Setting override_agent_id to null means no agent is specified, which causes the 400 error .
The Fix:
You need to provide a valid agent ID. Replace null with your actual agent ID :
json
{
"from_number": "+551150399187",
"to_number": "+5518997872005",
"override_agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"metadata": {},
"retell_llm_dynamic_variables": {
"customer_name": "Miguel Totti",
"bank_name": "Santander"
}
}
Additional Notes:
- You can remove the override_agent_version, custom_sip_headers, and ignore_e164_validation fields if they're null - they're optional
- The from_number must be a number purchased from Retell or imported to Retell
- The retell_llm_dynamic_variables you're using (customer_name and bank_name) will inject into your Response Engine prompt correctly [(1) ]() [(2) ]()
Get your agent ID from your Retell dashboard and use it in place of null, and your calls should work again.
**AI Evy
10/31/2025, 10:56 AMAI Evy
10/31/2025, 10:56 AMmiguel
10/31/2025, 11:05 AMAI Evy
10/31/2025, 11:05 AMAI Evy
10/31/2025, 11:05 AMfrom_number (+551150399187) must be properly configured in your Retell account [(1) ]() . If this number has an outbound_agent_id already set in the dashboard, it will override the override_agent_id parameter you're sending [(2) ]() .
To check your phone number configuration, you can retrieve its details [(3) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneNumberResponse = await client.phoneNumber.retrieve('+551150399187') ;
console.log(phoneNumberResponse.outbound_agent_id) ;
If the phone number already has an outbound_agent_id assigned, that agent will be used for the call instead of your override_agent_id [(2) ]() .
2. Clean Up Your Request
Remove the null values from your request - they're not needed [(4) ]() :
json
{
"from_number": "+551150399187",
"to_number": "+5518997872005",
"override_agent_id": "agent_612c47bf53ac3ec52abba700f7",
"metadata": {},
"retell_llm_dynamic_variables": {
"customer_name": "Miguel Totti",
"bank_name": "Santander"
},
"ignore_e164_validation": true
}AI Evy
10/31/2025, 11:05 AMfrom_number has an outbound_agent_id configured using the retrieve endpoint [(3) ]()
2. If it does, either remove it from the phone number configuration or don't use override_agent_id in your request [(2) ]()
3. Verify your phone number is properly set up for outbound calls [(1) ]()AI Evy
10/31/2025, 11:06 AMAI Evy
10/31/2025, 11:06 AMmiguel
10/31/2025, 11:33 AMAI Evy
10/31/2025, 11:33 AMAI Evy
10/31/2025, 11:34 AMAI Evy
10/31/2025, 11:34 AMAI Evy
10/31/2025, 11:34 AMAI Evy
10/31/2025, 11:34 AMmiguel
10/31/2025, 11:52 AMAI Evy
10/31/2025, 11:52 AMAI Evy
10/31/2025, 11:53 AMdata_storage_setting parameter [(2) ]() [(3) ]() :
javascript
const agentResponse = await client.agent.create({
response_engine: { llm_id: 'llm_234sdertfsdsfsdf', type: 'retell-llm' },
voice_id: '11labs-Adrian',
data_storage_setting: 'basic_attributes_only'
}) ;miguel
10/31/2025, 11:57 AMAI Evy
10/31/2025, 11:57 AMAI Evy
10/31/2025, 11:57 AMeverything, everything_except_pii, or basic_attributes_only) , you're only changing what gets retained in Retell's systems, not the real-time processing that happens during the call [(1) ]() [(2) ]() [(3) ]() [(4) ]() .
**AI Evy
10/31/2025, 11:58 AMAI Evy
10/31/2025, 11:58 AMmiguel
10/31/2025, 12:03 PMAI Evy
10/31/2025, 12:03 PMAI Evy
10/31/2025, 12:03 PMbegin_message_delay_ms) [(1) ]() .
How to Reduce the Initial Delay:
Set the begin_message_delay_ms parameter to around 500ms or less so the agent starts talking quickly after the call connects . This parameter controls the delay before the agent's first message [(2) ]() [(3) ]() [(4) ]() .
Using the API:
When creating or updating your agent, set begin_message_delay_ms [(2) ]() [(3) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.update('16b980523634a6dc504898cda492e939', {
begin_message_delay_ms: 500
}) ;AI Evy
10/31/2025, 12:03 PMbegin_message_delay_ms, you can minimize this startup latency .
---AI Evy
10/31/2025, 12:03 PMAI Evy
10/31/2025, 12:03 PMAI Evy
10/31/2025, 12:07 PMAI Evy
10/31/2025, 12:07 PMmiguel
10/31/2025, 1:24 PMAI Evy
10/31/2025, 1:24 PMAI Evy
10/31/2025, 1:24 PMretell_llm_dynamic_variables parameter when creating the call, then use that variable in your custom function configuration .
Verifying Requests from Retell:
Retell provides a built-in authentication measure to verify webhook requests are legitimate [(3) ]() . Every webhook request includes an x-retell-signature header which allows you to verify the Retell API Key, confirming the request is authentic and not from a malicious third party .
Security Implementation:
Retell AI offers a verify function in its SDKs to automate the security check . Additionally, you can allowlist Retell AI's IP address (100.20.5.228) to further safeguard your system against unauthorized access .
Webhook Security Best Practices:
These security measures help businesses maintain data integrity and prevent potential threats, ensuring that your AI phone agents acting on information with webhooks remains both efficient and secure .
For detailed implementation of webhook verification and custom function headers, I recommend checking the official documentation on webhooks and custom functions.
---
**AI Evy
10/31/2025, 1:25 PMAI Evy
10/31/2025, 1:25 PMmiguel
10/31/2025, 1:45 PMAI Evy
10/31/2025, 1:45 PMAI Evy
10/31/2025, 1:45 PMx-retell-signature header uses HMAC-SHA256 encryption to verify webhook authenticity [(1) ]() [(2) ]() [(3) ]() . You need to verify it using your Retell API Key (specifically the one with a webhook badge) [(1) ]() .
How the Signature Works:
The signature header format is: v=<timestamp>,d=<signature> [(4) ]() [(5) ]()
To verify without the SDK, you need to:
1. Extract the timestamp and signature from the header
2. Reconstruct the signed payload: {timestamp}.{raw_request_body}
3. Compute HMAC-SHA256 hash using your API key
4. Compare your computed signature with the received signature [(4) ]() [(5) ]() [(6) ]()
Implementation Without SDK:
Since you're not using the Retell SDK, here's the verification logic based on the documentation [(1) ]() [(2) ]() :
For Python (FastAPI example) :AI Evy
10/31/2025, 1:45 PMpython
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print(
"Received Unauthorized",
post_data["event"],
post_data["data"]["call_id"],
)
return JSONResponse(status_code=401, content={"message": "Unauthorized"})
[(2) ]()
For Node.js:
// install the sdk: <https://docs.retellai.com/get-started/sdk>
import { Retell } from "retell-sdk";
import express, { Request, Response } from "express";
const app = express() ;
app.use(express.json() ) ;
app.post("/webhook", (req: Request, res: Response) => {
if (
!Retell.verify(
JSON.stringify(req.body) ,
process.env.RETELL_API_KEY,
req.headers["x-retell-signature"] as string,
)
) {
console.error("Invalid signature") ;
return;
}
const {event, call} = req.body;
// process the webhook
// Acknowledge the receipt of the event
res.status(204) .send() ;
}) ;AI Evy
10/31/2025, 1:45 PM100.20.5.228 [(1) ]() [(2) ]() [(3) ]() .
Important Notes:
- Only the API key with a webhook badge can verify webhooks [(1) ]()
- The signature prevents replay attacks and confirms authenticity [(3) ]()
- You must use the raw request body (not parsed JSON) for verification [(4) ]() [(5) ]()AI Evy
10/31/2025, 1:46 PMAI Evy
10/31/2025, 1:46 PMmiguel
10/31/2025, 1:56 PMAI Evy
10/31/2025, 1:56 PMAI Evy
10/31/2025, 1:56 PMretell_llm_dynamic_variables when creating the call, these variables are immediately available to reference in your custom function configuration [(1) ]() . You can reference them using the {{variable_name}} syntax in your custom function headers [(1) ]() [(4) ]() .
Setting Up Your Custom Function Headers:
In your custom function configuration, you can add custom headers with dynamic variable values [(1) ]() :
1. In the custom function settings, add a header (e.g., "Authorization")
2. Set the value using the dynamic variable syntax: {{auth_token}} [(4) ]()
3. The token you passed when creating the call will be automatically injected into this header [(1) ]() [(4) ]()
Example Implementation:
When creating your phone call, pass the token:AI Evy
10/31/2025, 1:56 PMjson
{
"from_number": "+551150399187",
"to_number": "+5518997872005",
"override_agent_id": "agent_612c47bf53ac3ec52abba700f7",
"retell_llm_dynamic_variables": {
"auth_token": "your_authentication_token_here",
"customer_name": "Miguel Totti"
}
}
Then in your custom function header configuration, reference it as {{auth_token}} .
Why Extract Variables Node Is NOT Needed:
Extract Variables Nodes are used to extract information FROM the conversation and store them as dynamic variables [(2) ]() [(3) ]() . Since your token is already being passed as a dynamic variable when the call is created, it's immediately available throughout the conversation flow [(1) ]() . You don't need to extract it from the conversation because it's not coming from user speech—it's already in the system [(2) ]() [(3) ]() .
Important Note from Community Experience:
According to a community discussion, when using dynamic variables in custom function parameters or headers, make sure to format them correctly as {{variable_name}} in both the description and the parameter fields [(4) ]() . This ensures the variable is properly recognized and sent with the request .AI Evy
10/31/2025, 1:57 PMAI Evy
10/31/2025, 1:57 PM