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

# Authentication required

> HTTP 401, unauthenticated. The request carries no valid API key.

| | |
| - | - |
| Type | `https://docs.pinakelai.com/errors/unauthenticated` |
| Status | 401 |
| Retry | No. Fix the credential. Repeated failures block your IP address. |

## When it happens

* No `Authorization` header.
* Only an `X-API-Key` header. Send the key as `Authorization: Bearer <key>` instead.
* A key in the query string, under any parameter name (`api_key`, `access_token`, `key`, `token`, ...). Such keys are rejected even when valid, and removed from our logs.
* An unknown or malformed key.
* Your IP address is temporarily blocked: after 20 lookups of unknown keys from one address within a minute, requests from it get this error for 5 minutes, with a `Retry-After` header. A valid key that was used successfully within the last minute may still get through.

Every 401 carries a `WWW-Authenticate` header; for unknown and malformed keys it includes `error="invalid_token"`. A blocked address's 401 does not, because its key was not checked: do not discard a key because of it.

## What to do

Send `Authorization: Bearer <key>` with a current key. Do not retry automatically: a deployment that keeps retrying a wrong key can block every system behind the same egress address. See [Authentication](https://docs.pinakelai.com/authentication.md).

## Example

```http Headers theme={null}
HTTP/1.1 401 Unauthorized
Content-Type: application/problem+json
WWW-Authenticate: Bearer realm="api.pinakelai.com", error="invalid_token"
```

```json Body theme={null}
{
  "type": "https://docs.pinakelai.com/errors/unauthenticated",
  "title": "Authentication required",
  "status": 401,
  "detail": "Unknown API key.",
  "request_id": "req_01M7Q40D4E5F6G7H8J9KMNPQRS"
}
```

See the [errors catalogue](https://docs.pinakelai.com/api-reference/errors.md) for every error type, and [Handling errors](https://docs.pinakelai.com/guides/errors.md) for retry strategy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.