Getting 401 Unauthorized , Invalid Key when creati...
# support
a
I am getting the {"message":"Invalid Key. Hot tip, you may be using the private key instead of the public key, or vice versa.","error":"Unauthorized","statusCode":401} when attempting to create a call. My curl request is same as mentioned on this page https://docs.vapi.ai/calls/websocket-transport and i am providing the correct public key from my dashboard. Then I even tried using the 'Try It' option on https://docs.vapi.ai/api-reference/calls/create page but when i get the same 401 error. I am on free plan at the moment and have credits. I am not using any integrations, its a pure curl request from my command line. Please help. https://cdn.discordapp.com/attachments/1375485862313197659/1375485862648873111/Screenshot_2025-05-23_at_8.15.24_PM.png?ex=68328548&is=683133c8&hm=f2aeb79cb78000a1d5d8779d960bec7222cb6d27a97b7797ae1e959ae440e222&
v
You are getting a 401 Unauthorized error because either your API key is incorrect or your request body is missing required fields. Make sure you use your API key (not a public/private key) from the Vapi dashboard, and your request body should include at least the assistant and transport, like this:
Copy code
bash
curl 'https://api.vapi.ai/call' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'content-type: application/json' \
  --data-raw '{
    "assistant": { "assistantId": "YOUR_ASSISTANT_ID" },
    "transport": { "provider": "vapi.websocket" }
  }'
If you still get the error after correcting these, double-check your API key in the dashboard or contact Vapi support for help. Reference: [Vapi WebSocket Transport Docs](https://docs.vapi.ai/calls/websocket-transport) Sources: - [Vapi WebSocket Transport Docs](https://docs.vapi.ai/calls/websocket-transport) - [Vapi API Reference: Create Call](https://docs.vapi.ai/api-reference/calls/create)
It looks like the Vapi API expects an API token (not a public or private key) in the Authorization header. Please ensure you are using the API token from your dashboard, not a public/private key, like this:
Copy code
bash
curl -X POST https://api.vapi.ai/call \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Double-check your dashboard for an "API token" or "server token" and use that value. If you continue to get 401 errors, try regenerating your API token in the dashboard and use the new one. [Reference: Vapi API docs](https://docs.vapi.ai/api-reference/calls/create?explorer=true) Source: - [Vapi API Reference Create Call](https://docs.vapi.ai/api-reference/calls/create?explorer=true)
k
You will need to use Private API key to solve it.