Example
{
  "meta": {
    "requestId": "req_2c9a0jf23l4k567"
  },
  "error": {
    "detail": "Authentication credentials were not provided",
    "status": 401,
    "title": "Unauthorized",
    "type": "https://unkey.com/docs/api-reference/errors-v2/unkey/authentication/missing"
  }
}

What Happened?

This error occurs when you make a request to the Unkey API without including your API key in the Authorization header. The Unkey API requires authentication for most endpoints to verify your identity and permissions.

Here’s an example of a request that would trigger this error:

# Request to Unkey API without an API key
curl -X POST https://api.unkey.com/v1/keys.listKeys \
  -H "Content-Type: application/json"

Authentication is required to:

  • Verify your identity
  • Ensure you have permission to perform the requested operation
  • Track usage and apply appropriate rate limits
  • Maintain security and audit trails

How To Fix

To fix this error, you need to include your Unkey API key in the Authorization header of your request:

  1. Get your Unkey API key: Obtain your API key from the Unkey dashboard
  2. Add the Authorization header: Include your Unkey API key with the format Bearer unkey_YOUR_API_KEY

Here’s the corrected request:

curl -X POST https://api.unkey.com/v1/keys.listKeys \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_YOUR_API_KEY"

When properly authenticated, you’ll receive a successful response like this:

{
  "meta": {
    "requestId": "req_8f7g6h5j4k3l2m1n"
  },
  "data": {
    "keys": [
      {
        "keyId": "key_123abc456def",
        "name": "Production API Key"
      }
    ]
  }
}

Common Mistakes

  • Missing the Bearer prefix: Unkey requires the format Bearer unkey_YOUR_API_KEY with a space after “Bearer”
  • Headers lost in proxies: Some proxy servers or API gateways might strip custom headers
  • Expired or revoked keys: Using keys that are no longer valid
  • Wrong environment: Using development keys in production or vice versa