# API keys

Create, rotate and revoke organisation API keys.

Base URL: https://api.audiobly.com

### POST /v1/api-keys

Create API key

Create an API key for the caller's organisation with the given name, scopes and optional
expiry. The full secret is returned only in this response; store it securely. API and MCP
access come with the Enterprise plan: 403 PLAN_REQUIRED on any other plan.

Scope: org_manage

Body (JSON):

- `name` (string, required): A label that helps you recognise the key.
- `scopes` (array of string): The permissions this key is limited to; leave out for a key with full access.
- `expires_in_days` (integer): Number of days until the key expires; use this or expires_at.
- `expires_at` (string (date-time)): When the key expires, as an ISO 8601 date and time.

Responses:

- 201: Successful Response
- 422: The request did not validate.
- 401: The key is missing, unknown, revoked or expired.
- 403: The key lacks the scope this call needs, or the organisation is not on Enterprise.
- 429: Over the request rate. Wait for Retry-After seconds.

### GET /v1/api-keys

List API keys

List the organisation's active API keys (prefix, name, scopes, expiry), newest first.
Secrets are never returned.

Scope: org_manage

Parameters:

- `limit` (query, integer)
- `offset` (query, integer)

Responses:

- 200: Successful Response
- 422: The request did not validate.
- 401: The key is missing, unknown, revoked or expired.
- 403: The key lacks the scope this call needs, or the organisation is not on Enterprise.
- 429: Over the request rate. Wait for Retry-After seconds.

### POST /v1/api-keys/{key_id}/rotate

Rotate API key

Mint a fresh secret for an existing key: replace its hash + prefix, keep the same id,
scopes and expiry. The previous secret stops working immediately (its hash is gone).

Scope: org_manage

Parameters:

- `key_id` (path, string (uuid), required)

Responses:

- 200: Successful Response
- 422: The request did not validate.
- 401: The key is missing, unknown, revoked or expired.
- 403: The key lacks the scope this call needs, or the organisation is not on Enterprise.
- 429: Over the request rate. Wait for Retry-After seconds.

### DELETE /v1/api-keys/{key_id}

Revoke API key

Revoke an API key so it stops authenticating immediately; the revocation is audit-logged.
Returns 404 NOT_FOUND if the key is not in your organisation.

Scope: org_manage

Parameters:

- `key_id` (path, string (uuid), required)

Responses:

- 204: Successful Response
- 422: The request did not validate.
- 401: The key is missing, unknown, revoked or expired.
- 403: The key lacks the scope this call needs, or the organisation is not on Enterprise.
- 429: Over the request rate. Wait for Retry-After seconds.
