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

# API Keys API

> Create, list and revoke API keys from your own tools, with at most the access of the key that creates them

Create API keys from your own tools, for example to give each new customer integration or each environment its own key, without going through **Studio** > **API Keys**.

These endpoints are not available as MCP tools.

## Authentication

Listing keys requires an API key with the `api_keys:read` scope; creating and revoking keys requires `api_keys:write`. These scopes can only be granted to API keys, not to OAuth connections.

See [API Key Authentication](https://ago.mintlify.site/security/api-key-authentication.md) to create the first key in AGO.

## What a key can create

A key never gives more access than it has:

* **Scopes**: the new key can only have scopes the creating key holds. A `write` scope lets it give the matching `read` scope, and only a key with `*` can give `*`.
* **IP allowlist**: when the creating key only accepts some IP addresses, the new key gets the same allowlist by default. You can give it a narrower one, such as a single address from the same range, but not a wider one.
* **Expiry**: when the creating key expires, or was rotated and is in its grace period, the new key gets the same end date by default. You can choose an earlier date, but not a later one.
* **Owner**: the new key has the same owner as the key that creates it. Features that act as the key's owner, such as `resolutions:write`, act as that person.

A key only lists and revokes its direct managed children: those it created and those transferred to it by rotation. Unrelated keys created from **Studio** > **API Keys** are not visible to it.

A delegated key is usable only while its parent and all ancestors remain usable.

Keys can be created up to 10 levels below a key created in **Studio** > **API Keys**.

Revoking a key, through the API or in **Studio** > **API Keys**, also revokes the keys it currently manages and their descendants. After you rotate a key, its replacement manages the keys the old one created, including those created during the grace period. Revoking the old secret does not revoke the children transferred to its replacement. Those new keys still expire no later than the end of the old key’s grace period. Once the replacement is revoked, the old key can no longer create keys.

Keys with the `apps:invoke` scope cannot be created through the API: create them from the app's page.

***

## Create a key

```
POST /api/v1/api-keys
```

```bash theme={null}
curl -X POST https://your-workspace.api.useago.com/api/v1/api-keys \
  -H "X-API-Key: ago_v1_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Docs sync - Acme",
    "scopes": ["knowledge:read"],
    "allowed_cidrs": ["203.0.113.10"],
    "expires_at": "2027-06-30T00:00:00Z"
  }'
```

| Field | Required | Description |
| - | - | - |
| `name` | Yes | A name to recognize the key, up to 255 characters |
| `scopes` | Yes | The scopes to give, at least one (see [Scopes](https://ago.mintlify.site/security/api-key-authentication.md#scopes)) |
| `description` | No | A free-text description |
| `allowed_cidrs` | No | IP addresses or CIDR blocks allowed to use the key. Omit it to copy the creating key's allowlist; send `[]` to allow every IP address, which only works when the creating key allows every IP address |
| `expires_at` | No | When the key stops working. Omit it to use the creating key's end date, if any |

The response has status `201` and contains the new key in `key`. Store it right away: it is returned only once.

```json theme={null}
{
  "id": "5cc8e29b-530d-4586-9179-51576ba670a7",
  "object": "api_key",
  "name": "Docs sync - Acme",
  "description": "",
  "key_prefix": "ago_v1_sk_10",
  "scopes": ["knowledge:read"],
  "allowed_cidrs": ["203.0.113.10/32"],
  "is_active": true,
  "expires_at": "2027-06-30T00:00:00Z",
  "rotated_at": null,
  "locked_at": null,
  "last_used_at": null,
  "created_at": "2026-12-05T14:03:59.154Z",
  "key": "ago_v1_sk_..."
}
```

### Errors

| Status | Code | Cause |
| - | - | - |
| `400` | `invalid_name` | The name is empty |
| `400` | `invalid_scope` | No scope, an unknown scope, or `apps:invoke`, which you create from the app's page |
| `400` | `invalid_cidr` | An entry of `allowed_cidrs` is not an IP address or a CIDR block |
| `400` | `invalid_expiry` | `expires_at` is in the past |
| `401` | `invalid_api_key` | The creating key, or a key above it, was revoked, locked or expired during the request |
| `403` | `insufficient_scope` | The creating key lacks one of the requested scopes; the message lists them |
| `403` | `cidr_not_allowed` | The allowlist is wider than the creating key's |
| `403` | `expiry_not_allowed` | `expires_at` is later than the creating key's end date |
| `403` | `invalid_api_key` | The creating key is in its grace period and its replacement can no longer be used |
| `403` | `delegation_too_deep` | The creating key is already 10 levels below a key created in Studio |
| `409` | `too_many_rotations` | The creating key is in its grace period and was replaced more than 10 times since; use its latest replacement |
| `409` | `key_rotated` | The creating key was rotated during the request; retry with its latest replacement |
| `422` | `validation_error` | A required field is missing, a field has the wrong type, or the name is longer than 255 characters |

## List keys

```
GET /api/v1/api-keys?page=1&page_size=50
```

Returns your key’s direct managed children, newest first, revoked ones included, as a [paginated list](https://ago.mintlify.site/api/public-api-v1.md). Secrets are never returned.

## Get a key

```
GET /api/v1/api-keys/{key_id}
```

Returns `404` for a key outside your key’s direct managed children.

## Revoke a key

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

Revokes the key immediately, together with the keys it currently manages and their descendants, and returns it with `is_active` set to `false`. A revoked key cannot be restored. Returns `404` for a key outside your key’s direct managed children.


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