> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rasen.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rasen.ai/_mcp/server.

# Authentication

> Get a workspace API key, send it as a bearer token, check what it can do, and replace it without downtime.

## Summary

A workspace API key authenticates every request. This page covers how to get, send, check and
replace a key. It does not cover the capability of each operation; see the API reference.

## Send the key

Every request sends a workspace API key as a bearer token:

```bash
curl -sS "$RASEN_API_BASE/context" -H "Authorization: Bearer $RASEN_API_KEY"
```

A browser session cookie is never accepted. The key alone selects its workspace: a workspace
selection header is ignored for key callers, so do not send one.

## Get a key

Keys are managed in the Rasen app, on the **Developers** page under **API keys**. Any active,
platform-eligible member of the workspace, whatever their role, can create, list, rotate and revoke the workspace's keys, including a key another
member created.

* A key has a name of 1 to 120 characters and an optional expiry of 1 to 3650 days, or none.
* The value is shown **once**, when the key is created or rotated. Store it in a secret manager and
  never commit it. The app cannot show it again; if you lose it, rotate the key.
* Key metadata (name, prefix, state, timestamps, revocation reason and creator) is shown in the app.
  The app never shows a stored hash or the value again.
* `last_used_at` is a best-effort recorded use of the key on dedicated-host `/v1`. The platform tries to
  record a use at most once per key every five minutes, and never delays or fails a request to do
  so. It promises no freshness: a use that could not be recorded is skipped, so the value can be
  older than the key's real last use, by more than five minutes. A null means no use was recorded,
  not that the key was never used; the app shows "No use recorded".

An API key cannot list, create, change, rotate or revoke keys, and cannot reach the app's private
routes. Key management needs a signed-in session.

## One key family, full access

There is one key family, with full access to every operation in this API. There are no per-role or
per-operation key permissions. `GET /context` reports what the key can do:

```json
{
  "workspace_id": "ws_…",
  "key_id": "key_…",
  "creator_id": "usr_…",
  "capabilities": ["config.read", "agents.write", "agents.publish", "knowledge.write", "tools.write",
                   "secrets.read", "secrets.manage", "numbers.assign", "calls.write", "calls.read", "usage.read",
                   "webhooks.manage"],
  "api_version": "v1",
  "workspace_state": "active",
  "key_name": "ci",
  "expires_at": null
}
```

Each operation in the API reference names the capability it needs (`x-capability`). These labels
describe the operation; they do not add restrictions by member role.

| Capability        | Covers                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `config.read`     | Read agents, drafts, variables, versions and diffs, and the configuration they use: tools, MCP servers, knowledge, voices and phone numbers.                       |
| `agents.write`    | Create and edit agents, drafts and variables, validate drafts, and manage agent share links.                                                                       |
| `agents.publish`  | Publish and roll back agent versions.                                                                                                                              |
| `tools.write`     | Create, replace, delete and validate agent tools; create, replace and disable MCP servers and run discovery.                                                       |
| `secrets.read`    | Read secret metadata, versions and references, and reference an existing secret version from a tool or MCP server. Never values.                                   |
| `secrets.manage`  | Create, rotate, revoke and delete secrets, including secrets created by inline credentials and telephony connection credentials.                                   |
| `knowledge.write` | Create, upload, archive, delete and reingest knowledge sources, change agent libraries and build snapshots.                                                        |
| `numbers.assign`  | Manage telephony connections, discover and import numbers, remove local numbers, assign inbound and outbound agents, and retry provisioning.                       |
| `calls.write`     | Start and end calls and agent sessions, manage campaigns and destination suppression, and enable or rotate agent share-link tokens (also requires `agents.write`). |
| `calls.read`      | Read and search calls and their results, stream transcripts, and read campaigns and recipients.                                                                    |
| `usage.read`      | Read and query usage.                                                                                                                                              |
| `webhooks.manage` | List, create, replace, delete and test webhook endpoints, rotate their signing secrets, read their deliveries and resend a delivery.                               |

## Keys belong to the workspace

A key belongs to its workspace, not to the member who created it. `creator_id` is audit information
only: a key keeps working when its creator leaves the workspace or changes role.

A key stops working when it expires or is revoked, and the API then answers `401 unauthenticated`.
A key created before this API existed, with narrower permissions, is not accepted either: it also
answers `401`. Create a new key on the Developers page.

The key's state and the workspace's state are checked again on every request. Revocation takes
effect for every request admitted after it; a call already admitted keeps its normal lifecycle.

While a workspace is suspended, reads and key revocation still work, but new keys, rotations,
calls and configuration changes are refused: an API change answers `409 workspace_unavailable`.

## Replace a key

Rotating a key in the app revokes the old key and mints a new one with the same absolute expiry
(or none), in one step. An expired key cannot be rotated: create a new key instead.

To replace a key without a gap:

1. Create a second key in the app.
2. Deploy it, and check it with `GET /context`.
3. Revoke the old key.

> **Note**
>
> Every example on this site uses a placeholder such as `<your key>` or `$RASEN_API_KEY`. Never paste
> a real key into a page, a ticket or a chat.

## Related

* [Quickstart](/get-started/quickstart)
* [Errors](/concepts/errors)
* [Receive call events with webhooks](/guides/webhooks)