Example
{
  "meta": {
    "requestId": "req_2c9a0jf23l4k567"
  },
  "error": {
    "detail": "The requested API key could not be found",
    "status": 404,
    "title": "Not Found",
    "type": "https://unkey.com/docs/api-reference/errors-v2/unkey/data/key_not_found"
  }
}

What Happened?

This error occurs when you’re trying to perform an operation on a specific API key using its ID, but the key with that ID doesn’t exist in the system. This is different from the authentication error err:unkey:authentication:key_not_found, which occurs during the authentication process.

Common scenarios that trigger this error:

  • Attempting to update, delete, or get information about a key that has been deleted
  • Using an incorrect or malformed key ID
  • Trying to access a key that exists in a different workspace
  • Reference to a key that hasn’t been created yet

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

# Attempting to get details for a non-existent key
curl -X POST https://api.unkey.com/v1/keys.getKey \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer unkey_YOUR_API_KEY" \
  -d '{
    "keyId": "key_nonexistent"
  }'

How To Fix

Verify that you’re using the correct key ID and that the key still exists in your workspace:

  1. Check the key ID in your request for typos or formatting errors
  2. Confirm the key exists by listing all keys in your workspace via the Unkey dashboard or the API
  3. Verify you’re working in the correct workspace
  4. If you need to create a new key, use the keys.createKey endpoint

Here’s how to list all keys to find the correct ID:

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

Common Mistakes

  • Copy-paste errors: Incorrect key IDs due to copy-paste mistakes
  • Deleted keys: Attempting to reference keys that have been deleted
  • Environment confusion: Looking for a key in production that only exists in development
  • Workspace boundaries: Trying to access a key that exists in another workspace