# invalid_api_key

HTTP status 401. The API key is missing, wrong or revoked.

## Fix

Send a valid key in the Authorization header as 'Bearer at_test_...' or 'Bearer at_live_...'.

## More

Keys start with `at_test_`, `at_live_` or `at_agent_` followed by 32 letters and digits. A key is shown once, when it is created; if it was lost, the account owner revokes it and creates a new one in the dashboard under API keys. With the MCP server, the key goes in the server's `Authorization` header (see [mcp](../mcp.md)).

## What it looks like

```json
{
  "error": {
    "type": "invalid_api_key",
    "message": "The API key is missing, wrong or revoked.",
    "fix": "Send a valid key in the Authorization header as 'Bearer at_test_...' or 'Bearer at_live_...'.",
    "docs_url": "https://authtext.com.au/docs/errors/invalid_api_key.md",
    "request_id": "req_01JD3XA7Q2M7Q8R5T6V1W0XYZA"
  }
}
```

The `message` and `fix` can be more specific than shown here. `type` never changes, so branch on that. Quote the `request_id` if you ask for help.

All errors: [errors](../errors.md).
