Example
{
  "meta": {
    "requestId": "req_2c9a0jf23l4k567"
  },
  "error": {
    "detail": "The provided API key was not found",
    "status": 401,
    "title": "Unauthorized",
    "type": "https://unkey.com/docs/api-reference/errors-v2/unkey/authentication/key_not_found"
  }
}

What Happened?

This error occurs when you’ve provided a properly formatted API key in your request to the Unkey API, but the key doesn’t exist in Unkey’s system. The key might have been deleted, revoked, or you might be using an incorrect key.

Common causes include:

  • Using an API key that has been deleted
  • Using an API key from a different workspace or environment
  • Typographical errors when entering the key
  • Using a test key in production or vice versa

Here’s an example of a request with a non-existent API key:

# Request to Unkey API with a non-existent key
curl -X POST https://api.unkey.com/v1/keys.listKeys \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_NONEXISTENT_KEY"

How To Fix

To fix this error, you need to use a valid API key when making requests to the Unkey API:

  1. Check your Unkey dashboard: Verify you’re using the correct Unkey API key from the Unkey dashboard
  2. Create a new key if needed: If your key was deleted, create a new one
  3. Use the correct environment: Make sure you’re using the appropriate key for your environment (development, production, etc.)

Here’s how to check and use the correct Unkey API key:

  1. Log in to your Unkey dashboard
  2. Navigate to the API keys section
  3. Copy the appropriate API key for your environment
  4. Use the key in your request as shown below
curl -X POST https://api.unkey.com/v1/keys.listKeys \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_YOUR_VALID_API_KEY"

Common Mistakes

  • Using revoked Unkey keys: API keys that have been revoked will return this error
  • Environment mismatch: Using development keys in production or vice versa
  • Workspace confusion: Using keys from one workspace in another workspace’s API calls
  • Copy-paste errors: Inadvertently omitting part of the key when copying
  • Expired keys: Keys that have expired will return this error
  • Using demo keys: Using example keys from documentation