Getting 400 bad requests
# support
t
Hi vapi team, I've been getting 400 bad requests. Haven't really changed the code, it was working like 20 minutes ago: import requests # Create Call (POST /call) response = requests.post( "https://api.vapi.ai/call", headers={ "Authorization": "Bearer 1-31f91206b993" }, json={ "customers": [ { "numberE164CheckEnabled": true, "number": "+19254056671", "name": "Brian" } ], "phoneNumberId": "d0ea18ff-8157-49f5-856b-dc1ad8d13fed", "assistant": { "voice": { "provider": "11labs", "voiceId": "marissa" }, "voicemailDetection": { "provider": "twilio" }, "model": { "provider": "anthropic", "model": "claude-3-5-haiku-20241022" }, "transcriber": { "provider": "deepgram", "model": "nova-2-phonecall" }, "startSpeakingPlan": { "waitSeconds": 0.5, "smartEndpointingPlan": { "provider": "livekit", "waitFunction": "100 + 4000 * x" } }, "backgroundSound": "off" } }, ) print(response.json())
just masked the API key so that's not the issue
v
Hi there! 👋 I'm sorry to hear you're experiencing 400 Bad Request errors with your Vapi API calls. While I can't determine the exact cause without seeing the specific error message you're receiving, I can definitely help troubleshoot based on common issues with the POST /call endpoint. Here are several potential causes and solutions to investigate: ### 1. Concurrency Limits You might be exceeding the maximum number of concurrent calls allowed by your Voice API plan. According to [information from Vapi's community](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334142600772456508), this can result in a "Over Concurrency Limit" error. Check if you're making multiple simultaneous calls that might exceed your plan's limits. ### 2. Invalid JSON Payload Your JSON payload might contain unexpected properties or formatting issues: - Check for unexpected properties that shouldn't be included in the request - Ensure all required fields have the correct format and values - Verify that any nested JSON structures are properly formatted ### 3. Authorization Issues While your code includes an Authorization header, there might be issues with the token: - Verify that your API key/token is still valid and hasn't expired - Ensure the token has the necessary permissions - Check if the token format is correct (should be in the format
Bearer <token>
) ### 4. Model or Provider Configuration There might be issues with your assistant configuration: - Some models might not support certain features or configurations - The
11labs
provider with
marissa
voice might need verification - The
smartEndpointingPlan
configuration might need adjustment ### 5. Check for Recent API Changes Since you mentioned it was working 20 minutes ago, it's possible there might have been recent API changes or temporary service issues.
To better diagnose the issue, could you share the specific error message you're receiving in the response? This would help pinpoint the exact cause of the 400 error. Sources: - [Discord Thread on Concurrency Limits](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334142600772456508) - [Discord Thread on Invalid JSON Payloads](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333747605628391434) - [Discord Thread on Authorization Issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336414771309838448)
t
{'message': 'Failed to create calls for the following customers: +19254056671', 'error': 'Bad Request', 'statusCode': 400}
k
Send your Call id
v
Hey there is no such property named customers instead its name is customer and its type is of record which accepts name number and e1 for check. So you need to change from customers to customer from area of records to record type and then it will work.
t
Thanks, @Shubham Bajaj you're the goat. Only a suggestion, I wish there were some logs to debug that. using 'customer' worked. The property "customers" exists, I was trying it directly from the API reference: https://docs.vapi.ai/api-reference/calls/create There are no call-logs; The API logs show the durations as 0.1s with a status 200 and the CuRl command shows Error 400 bad request. If possible, please try to give out descriptive logging/errors. Thanks again for helping out.
v
You can raise an feature request for it over here: https://roadmap.vapi.ai
t
bruh adding a feature request for basic error validation and logging for something in the docs that breaks functionality is crazy but yea I'll add it. ty
v
The idea here is to add the and improvise the feedback loop. Even if it is a small feedback or improvement or a feature request. It should be going through our feedback loop. So that we can build better evaluation system for you. So it might sound crazy but it is not. If we consider the vision it's good to put everything under transparency and inside the feedback evaluation system.