# invalid_api_key — Shorty API error

> Invalid API key (HTTP 401): when the Shorty API returns the invalid_api_key error, why, and how to fix it.

| Code | HTTP status | Type URI |
| --- | --- | --- |
| `invalid_api_key` | 401 | `https://aishorty.com/docs/api/errors/invalid_api_key` |

## When it happens

An `Authorization` header was present but the key is unknown, malformed, disabled, or revoked.

## Example response

```json
{
  "type": "https://aishorty.com/docs/api/errors/invalid_api_key",
  "title": "Invalid API key",
  "status": 401,
  "detail": "The provided API key is not valid.",
  "instance": "urn:request:req_01J9Z8ABCDEFGH0123456789",
  "code": "invalid_api_key",
  "request_id": "req_01J9Z8ABCDEFGH0123456789"
}
```

## How to fix it

Check the key was copied whole (it is shown only once at creation), that it has not been rolled or revoked, and that you are hitting the right host.

## Related errors

- [unauthorized](/docs/api/errors/unauthorized) — Unauthorized (HTTP 401)
- [insufficient_scope](/docs/api/errors/insufficient_scope) — Insufficient scope (HTTP 403)
