# API keys and security

URL: https://docs.assistantcore.com/en/developers/api-keys-security

Create scoped Developer API keys, restrict them by IP and expiry, and rotate, revoke, or delete them safely.

An API key authenticates your backend to one assistant. It carries a set of scopes, an optional expiry, and an optional IP allowlist. Requests never pass an `assistant_id`; the key decides which assistant answers.

## Before you begin [#before-you-begin]

- You have the **Assistant Owner** role. Other roles cannot manage keys.
- The owner's plan includes API access. Every standard plan does, including Free; see [Plans and pricing](/en/billing/plans-pricing). Without it, the **Developer API** page shows **Upgrade to use the Developer API**.

## Create a key [#create-a-key]

1. Open the [Admin Panel](https://admin.assistantcore.com), select the assistant, and select **Developer API** in the sidebar.
2. Select **Create API key**.
3. Fill in the form:

   | Field | Value |
   | :--- | :--- |
   | **Key name** | 1–100 characters, for example `Production backend`. |
   | **Scopes** | Only what this integration needs (see the table below). |
   | **Expiration** | **30 days**, **90 days**, **1 year**, or **Never expires**. |
   | **Allowed IP addresses (optional)** | One IP or CIDR range per line, for example `203.0.113.0/24`. Leave empty to allow any IP. |

4. Select **Create API key**, then **Copy API key**, store it in your server-side secret manager, and select **I've saved the key**.

The full key is shown only once. It has the form `ac_<public-id>_<secret><checksum>`. The last six characters are a checksum, so a mistyped or truncated key fails at once with `INVALID_API_KEY`, and secret scanners can recognise leaked keys.

## Scopes [#scopes]

| Scope | UI label | Allows |
| :--- | :--- | :--- |
| `chat:write` | **Chat** | Create chat responses and retrieve them. |
| `files:write` | **Files** | Upload files for an end user. |
| `conversations:read` | **Conversations** | Read conversations and their messages. |
| `feedback:write` | **Feedback** | Rate assistant messages. |
| `voice:connect` | **Voice** | Create voice sessions. |
| `users:delete` | **Delete users** | Permanently erase an end user's data. Marked **Sensitive**. |

A call with a key that lacks the endpoint's scope returns `403 INSUFFICIENT_SCOPE`, with the missing scope in `details.required_scope`.

## Send the key [#send-the-key]

Send the key in the `Authorization` header over HTTPS on every REST call:

```http
Authorization: Bearer <your-api-key>
```

The Voice WebSocket never receives the API key; your backend creates a voice session and the client sends that session's short-lived token instead (see [Voice API](/en/developers/voice-api)).

## Edit, rotate, revoke, or delete a key [#edit-rotate-revoke-or-delete-a-key]

Each key in the list shows its status (**Active**, **Expires soon**, **Expired**, or **Revoked**), when it was **Last used**, and its **IP access**.

| Action | What it does |
| :--- | :--- |
| **Edit** | Changes the name or the IP allowlist. The secret keeps working. Scopes and expiry cannot be edited; create or rotate a key instead. |
| **Rotate** | Issues a replacement key with the same name, scopes, IP allowlist, and expiry. Under **Current key stops working**, choose **Immediately**, **In 1 hour**, **In 24 hours**, or **In 7 days**. During the grace period both keys work; afterwards the old key returns `API_KEY_EXPIRED`. |
| **Revoke** | Blocks the key at once with `API_KEY_REVOKED`. It cannot be undone. |
| **Delete** | Removes the key from the list. A deleted key returns `INVALID_API_KEY`. Usage history is kept. |

For a planned rotation, deploy the new key to every instance and send a test request before the grace period ends. If a key may have leaked, rotate with **Immediately** or revoke it.

## Protect keys and end-user data [#protect-keys-and-end-user-data]

- Keep keys out of browsers, mobile and desktop apps, URLs, source control, and logs. A key shipped in an app can be extracted; give native apps a token from your own backend instead.
- Use one key per application and environment, and add an IP allowlist when your servers have fixed outbound IPs.
- Map each signed-in user to a stable `external_user_id` on your backend. Do not use an email address, phone number, or secret as the ID.
- Conversations, files, and memory are isolated per assistant and `external_user_id`. Erase a user with `DELETE /v1/users/{external_user_id}` (see [Chat API](/en/developers/chat-api)).
- All keys of an assistant share its rate limits, so more keys do not add capacity (see [Errors and limits](/en/developers/errors-limits)).

<Callout type="warn">
Preview has no separate sandbox. Staging calls create real data and use the owner's credits. Use a separate staging assistant and key.
</Callout>

<Cards>
<Card title="Quickstart" description="Send a first request with your new key." href="/en/developers/quickstart" />

<Card title="Errors and limits" description="Key errors, rate limits, and retries." href="/en/developers/errors-limits" />
</Cards>