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

# Authentication

> Create an organization API key and send it as a Bearer token with every request to the Klatt API.

The Klatt API authenticates requests with an **organization API key**.

## Create a key

1. Open the Klatt console and go to **Settings**, then **API keys**.
2. Create a key and give it a name that says where it is used.
3. Copy the key immediately. It is shown only once and cannot be retrieved later.

Keys look like `sk_klt_...`. Older keys may start with a different prefix and work the same way.

> [!WARNING]
>
> An API key grants access to your organization's data. Keep it on your servers: never put it in a browser page, a mobile app, a public repository or a shared configuration file. Load it from an environment variable or a secrets manager. If a key leaks, delete it in the console and create a new one.

## Send the key

Send the key in the `Authorization` header as a Bearer token:

```bash theme={null}
curl https://api.klatt.ai/api/v1/agents/ \
  -H "Authorization: Bearer $KLATT_API_KEY"
```

The `X-API-Key: <key>` header is accepted as an alternative. Send exactly one credential per request: a request with both headers, or with a repeated header, is rejected.

## What a key can do

* A key belongs to **one organization** and can only reach that organization's data.
* A key acts with **Editor** permissions: it can read and change agents, conversations, contacts and knowledge, but not administer the organization. Actions are attributed to the member who created the key. A key keeps working after that member leaves the organization: delete their keys when they leave.
* A key **cannot** manage API keys, members or invitations, place customer calls, or run campaigns. These requests answer `403`.
* Operations that are not in this reference may still answer with a key, but they are not part of the API contract and can change without notice.

## Where keys work

Keys work only on `https://api.klatt.ai`. Sending a key to the console host is rejected with the code `api_key_wrong_host`, and sending a console sign-in token to the API host is rejected with `console_token_not_accepted`.

## Rotate and delete keys

To rotate a key, create a new one, deploy it, then delete the old key in the console. A deleted key stops working immediately. Keys do not expire. They work until you delete them.

## `401` and `403`

| Status | Meaning |
| - | - |
| `401` | The key is missing, malformed, unknown or deleted, or the request was sent to the wrong host. The response includes `WWW-Authenticate: Bearer`. |
| `403` | The key is valid but may not do this, for example `permission_required` or `Organization API keys cannot access this operation`. |

See [Errors](https://docs.klatt.ai/api-reference/errors.md) for the response format.


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