Skip to content

UNAUTHORIZED — Missing or invalid API key

The request reached the API but didn’t include a valid key in the x-api-key header. The most common cause is sending the key in Authorization: Bearer ... instead, or omitting the header entirely.

401 Unauthorized. Standard envelope.

{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid API key. Pass it in the x-api-key header.",
"request_id": "req_01HXJZK4ABCDEF",
"doc_url": "https://docs.surveycoder.io/errors/unauthorized"
}
}
  • The x-api-key header is missing.
  • The key was sent as Authorization: Bearer ... (we don’t accept that — keys go in x-api-key).
  • The key value is malformed (must start with scp_live_ or scp_test_).
  • A proxy or middleware stripped the custom header before the request hit our edge.
  1. Confirm the header name is exactly x-api-key (lowercase by convention, but case-insensitive on our side).
  2. Confirm the value starts with scp_live_ (production) or scp_test_ (testing) and is 40+ characters long.
  3. If you use a fetch wrapper or HTTP client with Authorization-only defaults, set x-api-key explicitly:
Terminal window
curl https://api.surveycoder.io/v1/usage \
-H "x-api-key: $SCP_API_KEY"
  1. If your key looks right but still fails, it may have been revoked or expired.