https://retellai.com/?utm_source=discord&utm_medium=seo logo
I'm having trouble using de Retell API to make cal...
# ❓・ai-evy-support
m
@AI Evy I'm having trouble using de Retell API to make calls using the https://api.retellai.com/v2/create-phone-call endpoint, it allways returns 400 bad request. I tested earlier and it was working fine until it stopped workding and return 400 bad request. My API Key is correct and I'm sending the same request as before when it was working.
a
Thanks for tagging me @miguel. I'll look through relevant sources and get back to you shortly.
### Answer A 400 Bad Request typically means there's an issue with your request parameters [(1) ]() . Let me help you troubleshoot: Required Parameters for Create Phone Call: - `from_number`: Must be a number purchased from Retell or imported to Retell in E.164 format (e.g.,
"+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:
Copy code
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) ]()
Copy code
json
{
  "from_number": "+16504144521",
  "to_number": "your_target_number",
  "override_agent_id": "agent_71724df7636716ceb3a7e244c8",
  "retell_llm_dynamic_variables": {
    "name": "Sarah"
  }
}
Double-check that your
from_number
is a Retell-configured number and that all parameters match the expected format [(1) ]() [(2) ]() . **
​ To learn more, see the sources I considered: [[1] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[2] Here is how that can be fixed](https://retell.discourse.group/t/here-is-how-that-can-be-fixed/23) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy This is the request I`m sending to https://api.retellai.com/v2/create-phone-call endpoint { "from_number": "+551150399187", "to_number": "+5518997872005", "override_agent_id": null, "override_agent_version": null, "metadata": {}, "retell_llm_dynamic_variables": { "customer_name": "Miguel Totti", "bank_name": "Santander" }, "custom_sip_headers": null, "ignore_e164_validation": true }
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer I found the issue with your request. The problem is that you're setting
override_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 :
Copy code
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. **
​ To learn more, see the sources I considered: [[1] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy { "from_number": "+551150399187", "to_number": "+5518997872005", "override_agent_id": "agent_612c47bf53ac3ec52abba700f7", "override_agent_version": null, "metadata": {}, "retell_llm_dynamic_variables": { "customer_name": "Miguel Totti", "bank_name": "Santander" }, "custom_sip_headers": null, "ignore_e164_validation": true } This was the agent Id I got from agent page at Retell and it didnt work.
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer Based on the request you're sending, there are a few potential issues that could be causing the 400 Bad Request error: 1. Phone Number Configuration Issue Your
from_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) ]() :
Copy code
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) ]() :
Copy code
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
}
3. Verify Your Phone Number Setup Since you're using a Brazilian number (+55) , ensure that: - The number is properly purchased or imported into Retell - If using Retell's telephony, only US numbers are supported as destinations - You may need custom telephony for Brazilian numbers Next Steps: 1. Check if your
from_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) ]()
​ To learn more, see the sources I considered: [[1] Create Phone Number](https://docs.retellai.com/api-references/create-phone-number) [[2] Agent_ID problem (by using api)](https://discord.com/channels/1186424376300679209/1422374498459717633) [[3] Get Phone Number](https://docs.retellai.com/api-references/get-phone-number) [[4] Create Phone Call](https://docs.retellai.com/api-references/create-phone-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy I remove the null arguments from my request and it worked fine! Now I have one more problem. I configured my agent (conversation flow) will perform the node conversation to say something when the client accepts the call and make a question. If the client responds with "Yes" or "I Accept" or something similar, the agent will make a request to a custom function and after receiving the response, the agent will perform another node of conversation to thank the client and end the call. I'm facing a problem where the agent perform the last node of conversation but dont end the call, it waits unil the client ends, or the End Call on Silence timeout or the Max Call Duration reaches. I configured the transition of this last node of conversation with a prompt in portuguese connected to a Ending or End Call node. This is the prompt: "Finaliza a chamada após agradecer". I think the right prompt would be "Encerre a chamada após agradecer ao cliente." or "End the call after thanking the customer.", if it was in english, to sound like a action to be performed after this last node of conversation ends. I'm I right or there is some other way to end the call after the agent perform this last conversation node prompt?
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer \Great to hear the null arguments fix worked! For ending the call properly in Conversation Flow, you need to use a specific End Call node rather than relying on transition prompts [(1) ]() [(2) ]() . How to Properly End Calls in Conversation Flow: In Conversation Flow, transitions happen between nodes based on conditions [(2) ]() . Your transition prompt ("Finaliza a chamada após agradecer") is actually a transition condition, not an instruction to end the call [(1) ]() . The Correct Approach: 1. Your last conversation node should thank the customer 2. Connect this node to an End Call node (not just an "Ending" node) [(2) ]() 3. The transition condition should detect when the agent finishes speaking, not when to end the call [(1) ]() For your specific case: Since you want the call to end immediately after the agent thanks the customer, you should: - Enable Skip Response on your final conversation node - This allows transition to happen when the agent finishes speaking (without waiting for user response) - Connect the single edge from this node directly to an End Call node [(2) ]() About Transition Conditions: When transitions aren't working as expected, the debug guide suggests reviewing your transition conditions to ensure they precisely match your intended triggers [(3) ]() . However, for ending calls, the transition condi
tion isn't what terminates the call—the End Call node does that [(2) ]() . The transition prompt you're using should describe when to transition (e.g., "after agent finishes thanking") , not what action to perform. The action (ending the call) is determined by the node type you're transitioning to . **
​ To learn more, see the sources I considered: [[1] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) [[2] Conversation Flow Overview](https://docs.retellai.com/build/conversation-flow/overview) [[3] Debug guide](https://docs.retellai.com/build/conversation-flow/debug-guide) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy Thanks. Now, explain me what is sent in the webhook request to the server I configured when I choose a different Data Storage Settings in my Agent.
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer ### Answer When you configure different Data Storage Settings on your agent, it affects what data is stored in Retell's system, but webhook events continue to include all sensitive data regardless of your storage setting [(1) ]() . The Three Data Storage Options: 1. Everything – Store transcripts, recordings, and logs 2. Everything except PII – Store content, excluding PII when possible 3. Basic Attributes Only – Store only metadata (no transcripts/recordings/logs) What Happens with Webhooks: When you opt out of storing sensitive data, you will continue to receive webhook events where you can access the transcript, call recording, and other sensitive data . This means: - Webhook payloads contain the full data (transcripts, recordings, etc.) regardless of your storage setting - The call recording link will expire after 10 minutes upon receiving the webhook - If you later query the call with the get call API, you will not get these fields if you chose "Basic Attributes Only" Important Note: The data storage setting determines what Retell stores, not what gets sent to your webhook . Your webhook will receive all the sensitive data in real-time, giving you the opportunity to process or store it on your own systems before the recording link expires . Configuring Data Storage Settings: You can set this at the agent level using the
data_storage_setting
parameter [(2) ]() [(3) ]() :
Copy code
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'
}) ;
[(3) ]() The available values are:
everything
,
everything_except_pii
, or
basic_attributes_only
[(2) ]() [(3) ]() . **
m
@AI Evy Does it change the cost of each calls if I chose a different Data Storage Settings?
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer --- Based on the available documentation, the Data Storage Settings do not directly affect the cost per call [(1) ]() [(2) ]() [(3) ]() [(4) ]() . The Data Storage Settings control what Retell stores after the call (transcripts, recordings, logs) , but the pricing is based on the actual services used during the call—such as TTS (text-to-speech) , STT (speech-to-text) , LLM usage, and telephony minutes [(5) ]() . When you choose different storage settings (
everything
,
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) ]() . **
​ To learn more, see the sources I considered: [[1] Data Storage Settings - Retell AI](https://docs.retellai.com/accounts/privacy-disable) [[2] Update Agent](https://docs.retellai.com/api-references/update-agent) [[3] Create Agent](https://docs.retellai.com/api-references/create-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy Thanks. One more topic to discuss. I realized that there is a litle wait, about a few seconds, between the client aceppet the call and the agent start talking. Can I change it to faster and decrease this litle wait??
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer ### Answer Yes, you can reduce the delay between when a client accepts the call and when the agent starts speaking by adjusting the "Pause Before Speaking" setting (also known as
begin_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) ]() :
Copy code
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 
}) ;
[(3) ]() Parameter Details: - `begin_message_delay_ms`: Controls the delay (in milliseconds) before the agent starts speaking after the call connects [(2) ]() [(3) ]() [(4) ]() - Lower values (e.g., 500ms) mean the agent speaks sooner [(1) ]() - If unset, the default value of 1000ms (1 second) applies [(2) ]() [(3) ]() [(4) ]() Additional Note: The initial delay you're experiencing is typically longer than mid-conversation responses because the system needs to establish the connection and initialize the agent [(1) ]() . By reducing
begin_message_delay_ms
, you can minimize this startup latency . ---
​ To learn more, see the sources I considered: [[1] Best way to reduce latency at start of a call.](https://discord.com/channels/1186424376300679209/1382631452058976326) [[2] Create Agent](https://docs.retellai.com/api-references/create-agent) [[3] Update Agent](https://docs.retellai.com/api-references/update-agent) [[4] Get Agent](https://docs.retellai.com/api-references/get-agent) ​
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] Data Storage Settings - Retell AI](https://docs.retellai.com/accounts/privacy-disable) [[2] Update Agent](https://docs.retellai.com/api-references/update-agent) [[3] Update Agent](https://docs.retellai.com/api-references/update-agent) [[4] Create Agent](https://docs.retellai.com/api-references/create-agent) [[5] Get Call](https://docs.retellai.com/api-references/get-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy Can I configure a personalized value in the header of a webhook that the agent in a Conversation Flow sends to my server? I needed to authenticate the request from Retell to be able to access the webhook endpoint. If it cannot be configured, what are the values sent in the header of the webhook request? Can I verify that the request is coming from Retell instead of any other server?
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer ### Answer Custom Headers in Webhooks: For Custom Functions in Conversation Flow, you can configure custom headers [(1) ]() . When setting up a custom function, you can add headers (like Authorization tokens) that will be included in the webhook request your server receives . Authentication Token Example: You can pass authentication tokens through custom function headers [(2) ]() . One approach is to pass the token into the
retell_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. --- **
​ To learn more, see the sources I considered: [[1] List Conversation Flows](https://docs.retellai.com/api-references/list-conversation-flows) [[2] Discord message from @medivoice_63089 on 2025-02-05](https://discord.com/channels/1186424376300679209/1294891368505937952/1336750733042909245) [[3] Retell AI Webhooks | AI Voice Agents With Live Data | Retell AI](https://www.retellai.com/blog/retell-ai-webhooks-feature) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy The header x-retell-signature is encrypted or its easy to verify that the request is coming from Retell? I need to do some decription with my API key? How it works? I'm not using any kind of Retell sdk.
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer The
x-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) :
Copy code
python
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:
Copy code
// 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() ;
}) ;
[(1) ]() Additional Security: You can also allowlist Retell's IP address:
100.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) ]()
​ To learn more, see the sources I considered: [[1] Secure the webhook](https://docs.retellai.com/features/secure-webhook) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[3] Retell AI Webhooks | AI Voice Agents With Live Data | Retell AI](https://www.retellai.com/blog/retell-ai-webhooks-feature) [[4] Webhook Signature Verification Failed](https://discord.com/channels/1186424376300679209/1399212780183097498) [[5] Webhook Verification](https://discord.com/channels/1186424376300679209/1400483295082451026) [[6] Verify Webhook](https://discord.com/channels/1186424376300679209/1380381514390306816) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy I needed to set a Authentication header value for a custom function to be able to make a request to my server. I was thinking in passing the token by dynamic variables when I create a phone call. Can I get the token passed as dynamic variable and use it in the header of the custom function? I need to use the extract variables node or it isn`t necessary? If I need to use de extract variables node, how can I do that? I need to place it between the Begin node and the firts Conversation node I have?
a
Thanks for the follow-up, @miguel. I'll get back to you soon.
### Answer ### Answer Yes, you can pass a token via dynamic variables when creating a phone call and use it directly in your custom function headers [(1) ]() . You do NOT need to use an Extract Variables Node for this use case [(2) ]() [(3) ]() . How Dynamic Variables Work in Custom Functions: When you pass dynamic variables through
retell_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:
Copy code
json
{
  "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 .
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Extract Dynamic Variable Node](https://docs.retellai.com/build/conversation-flow/extract-dv-node) [[3] Discord message from @renovia_70920 on 2025-10-30](https://discord.com/channels/1186424376300679209/1186462578310910112/1433525353967652947) [[4] Dynamic Variable is not sending via custom function.](https://discord.com/channels/1186424376300679209/1430715756030722149) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.