> The index of all pages is at https://docs.afffast.com/llms.txt.

# api_key_in_query

The request has an API key in the query string. Send the key in the Authorization header.

HTTP status: **400**. Error type: `authentication_error`.

The request has an API key in the query string. Send the key in the Authorization header.

## Example

```json
{
  "error": {
    "type": "authentication_error",
    "code": "api_key_in_query",
    "message": "The request has an API key in the query string. Send the key in the Authorization header.",
    "param": "api_key",
    "doc_url": "https://docs.afffast.com/errors/api-key-in-query",
    "request_id": "req_3kQ9x7WmZpL2vNd8TfYb4A"
  }
}
```

## Causes

- The URL has a query parameter with an API key, for example `?api_key=sk_live_...`. The API refuses it, because URLs are kept in logs.

## How to fix

- Remove the key from the URL. Send it in the header: `Authorization: Bearer sk_...`.
- If the key was in a real URL, treat the key as leaked. Make a new key in the dashboard and revoke the old key.
