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

# Authentication

> How to send, store, rotate, and revoke an API key.

Every request to the API is authenticated with an API key. The key belongs to one installation: everything you do with it happens in that installation.

## Send the key

Send the key in the `Authorization` header with the `Bearer` scheme:

```http theme={null}
GET /public/v1/installation HTTP/1.1
Host: apex.federalaccess.cl
Authorization: Bearer fa_7Hk2mPqR_3vXy9...
```

The API doesn't accept the key in the URL or in the request body.

## Key format

A key looks like `fa_<prefix>_<secret>`:

* `fa_<prefix>` isn't secret. The dashboard shows it in the prefix column so you can tell your keys apart.
* `<secret>` is the private part. Federal Access doesn't store it, so it can't show it to you again or recover it.

## Store the key safely

* Keep it in an environment variable or a secrets manager, never in source code or a repository.
* Use it only from a server. Don't ship it in a web or mobile app, where anyone could read it.
* Create one key per integration. That way you can revoke one without cutting off the others, and the dashboard shows each key's last use.

## Rotate a key

Keys don't expire. To replace one without downtime:

1. Create a new key with the same scopes.
2. Configure your system with the new key.
3. Confirm your system works, then revoke the old key.

Each active key in an installation needs a distinct name. Revoking a key frees its name.

## Revoke a key

In the dashboard, go to **Configuración** (Settings) > **API**, find the key, and revoke it. To confirm, type the key's name.

* The key stops working from the next request: the API answers `401`.
* Revoking can't be undone.
* Revoked keys stay in the list for 7 days, then they're deleted.

If a key leaks, revoke it right away and create another.

## Authentication errors

| Situation | Response |
| - | - |
| The header is missing, the scheme isn't `Bearer`, or the key is malformed | `401 unauthorized` |
| The key doesn't exist or is revoked | `401 unauthorized` |
| The installation can't use the API | `401 unauthorized` |
| The installation is inactive | `403 forbidden` |
| The key lacks the scope the endpoint requires | `403 forbidden` |

Every `401` has the same message and the `WWW-Authenticate: Bearer realm="public_api"` header. The response doesn't say which part failed, so it gives no hints to someone trying to guess a key.

```json theme={null}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key.",
    "request_id": "7f3c1d2e-4b5a-4c6d-8e9f-0a1b2c3d4e5f"
  }
}
```

For scope `403`s, see [Scopes](https://docs.federalaccess.cl/en/guides/scopes.md).


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