> ## Documentation Index
> Fetch the complete documentation index at: https://unkey.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# key_not_found

> The requested API key was not found in Unkey. Verify the key ID is correct, the key has not been deleted, and it belongs to your workspace.

<Danger>err:unkey:data:key\_not\_found</Danger>

```json Example theme={"theme":"kanagawa-wave"}
{
  "meta": {
    "requestId": "req_2c9a0jf23l4k567"
  },
  "error": {
    "detail": "The requested API key could not be found",
    "status": 404,
    "title": "Not Found",
    "type": "https://unkey.com/docs/errors/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:

```bash theme={"theme":"kanagawa-wave"}
# Attempting to get details for a non-existent key
curl -X POST https://api.unkey.com/v2/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](https://unkey.com/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:

```bash theme={"theme":"kanagawa-wave"}
curl -X POST https://api.unkey.com/v2/apis.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

## Related Errors

* [err:unkey:authentication:key\_not\_found](../authentication/key_not_found) - When an API key used for authentication doesn't exist
* [err:unkey:data:api\_not\_found](./api_not_found) - When the requested API doesn't exist
* [err:unkey:data:workspace\_not\_found](./workspace_not_found) - When the requested workspace doesn't exist
