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

# Administration API: API keys

> List, create, and revoke account and workspace API keys from code. A key never gets more access than the key that creates it, and its token is shown only once.

Manage API keys from code: list the account and workspace API keys you can revoke, create keys for scripts and CI jobs, and revoke keys at once. Use it to give each job its own key, and to rotate keys without opening Paradime.

> [!NOTE]
>
> **Prerequisites:**
>
> * These operations are available on every plan.
> * For workspace API keys: an account API key with the `X-Paradime-Workspace` header, or a workspace API key. For account API keys: an account API key, with no `X-Paradime-Workspace` header needed.
> * The **API keys admin** capability group, and every capability group that you give the new key.
>
> The schema calls an account API key a *company* API key. Keys, errors, and pagination work the same in every area. See [Conventions](https://docs.paradime.io/developers/graphql-api/admin-api/conventions.md).

## Operations

| Operation | Type | What it does | Capability group |
| - | - | - | - |
| [`Workspace.apiKeys`](https://docs.paradime.io/graphql-reference/types/Workspace) | Field | Lists the workspace's working API keys that the calling key could revoke. Never returns a token. | API keys admin |
| [`createApiKey`](https://docs.paradime.io/graphql-reference/mutations/createApiKey) | Mutation | Creates a workspace API key in the targeted workspace, and returns its token once. | API keys admin |
| [`revokeApiKey`](https://docs.paradime.io/graphql-reference/mutations/revokeApiKey) | Mutation | Revokes a workspace API key at once. | API keys admin |
| [`companyApiKeys`](https://docs.paradime.io/graphql-reference/queries/companyApiKeys) | Query | Lists the account's active account API keys that the calling key could revoke. Account keys only. | API keys admin |
| [`createCompanyApiKey`](https://docs.paradime.io/graphql-reference/mutations/createCompanyApiKey) | Mutation | Creates an account API key for a set of workspaces, and returns its token once. Account keys only. | API keys admin |
| [`revokeCompanyApiKey`](https://docs.paradime.io/graphql-reference/mutations/revokeCompanyApiKey) | Mutation | Revokes an account API key at once. Account keys only. | API keys admin |

## Never more access than the calling key

Every key the API creates, lists, or revokes stays within the access of the key that calls it:

* **Capability groups.** Each group you give must be one the calling key holds in full. Otherwise the call fails with `MISSING_CAPABILITY` on that group's input path, such as `["input", "capabilityGroups", "1"]`. Give at least one group. Pass groups by their enum value, such as `MANAGE_BOLT_ADMIN` for **Bolt admin**: see [Capability groups](https://docs.paradime.io/developers/graphql-api/admin-api/conventions.md#capability-groups). Every group can go on both key types, except **Workspace admin**, which only account keys can hold.
* **Workspaces.** Each workspace of a new account key must be one the calling key can reach. Otherwise the call fails with `MISSING_CAPABILITY` on `["input", "workspaceUids", "<index>"]`. A workspace that doesn't exist gets the same error, so the answer never shows which workspaces exist.
* **Expiry.** `expiresAt` must be in the future, and no later than the calling key's own expiry. If the calling key expires, `expiresAt` is required. When you generate an account key in Paradime, **Lifetime (days)** is required, so that key expires, and every key it creates must send `expiresAt`. Leave `expiresAt` out for a key that never expires, which only a calling key that never expires can create.
* **Lists and revokes.** The lists show only the keys the calling key could revoke: keys with no capability, and for account keys no workspace, beyond its own. `totalCount` counts only those keys. An account key's `workspaces` lists only the workspaces the calling key can reach.

## Create a workspace API key

`createApiKey` creates a key in the targeted workspace. The name must be unique among the workspace's working keys, ignoring spaces at the start and end.

```graphql theme={"system"}
mutation CreateWorkspaceKey($input: CreateApiKeyInput!) {
  createApiKey(input: $input) {
    apiKey {
      id
      name
      capabilities
      createdAt
      expiresAt
    }
    token
  }
}
```

```json theme={"system"}
{
  "input": {
    "name": "ci-bolt-deploys",
    "capabilityGroups": ["MANAGE_BOLT_ADMIN"],
    "expiresAt": "2027-02-24T00:00:00Z"
  }
}
```

> [accordion] Example response
>
> ```json theme={"system"}
> {
>   "data": {
>     "createApiKey": {
>       "apiKey": {
>         "id": "1042",
>         "name": "ci-bolt-deploys",
>         "capabilities": [
>           "bolt:schedule:create",
>           "bolt:schedule:delete",
>           "bolt:schedule:parse",
>           "bolt:schedule:update",
>           "bolt:schedules:list",
>           "bolt:trigger_urls:read",
>           "bolt:trigger_urls:write"
>         ],
>         "createdAt": "2026-11-26T12:00:00+00:00",
>         "expiresAt": "2027-02-24T00:00:00+00:00"
>       },
>       "token": "prdm_wsp_<shown once>"
>     }
>   }
> }
> ```

> [!WARNING]
>
> `token` is shown only in this response, and never read back. Store it now, in a password manager or your CI secret store.

The token starts with `prdm_wsp_`. Send it as `Authorization: Bearer <token>`. A workspace key is bound to its workspace, so it needs no `X-Paradime-Workspace` header. See [Authentication](https://docs.paradime.io/developers/graphql-api/authentication.md).

## Create an account API key

`createCompanyApiKey` creates an account key that can reach the workspaces in `workspaceUids`. It needs an account key. The name must be unique among the account's active account keys.

```graphql theme={"system"}
mutation CreateAccountKey($input: CreateCompanyApiKeyInput!) {
  createCompanyApiKey(input: $input) {
    companyApiKey {
      id
      name
      capabilities
      expiresAt
      workspaces {
        edges {
          node {
            uid
            name
          }
        }
      }
    }
    token
  }
}
```

```json theme={"system"}
{
  "input": {
    "name": "usage-export",
    "capabilityGroups": ["VIEW_USAGE"],
    "workspaceUids": ["k2m9xq4w7v1d3h8p", "w4kq8m2x9v7d1h3p"],
    "expiresAt": "2027-02-24T00:00:00Z"
  }
}
```

The token starts with `prdm_cmp_`. Send it as `Authorization: Bearer <token>`, with `X-Paradime-Workspace` to pick the workspace of a workspace-level call.

## List and revoke keys

`Workspace.apiKeys` lists the targeted workspace's working keys, oldest first, and `companyApiKeys` the account's active account keys. Neither returns a token. `lastUsedAt` shows when a key last made a request.

```graphql theme={"system"}
query WorkspaceKeys {
  workspace {
    apiKeys {
      totalCount
      edges {
        node {
          id
          name
          capabilities
          createdAt
          expiresAt
          lastUsedAt
        }
      }
    }
  }
}
```

```graphql theme={"system"}
query AccountKeys {
  companyApiKeys {
    totalCount
    edges {
      node {
        id
        name
        capabilities
        createdAt
        expiresAt
        lastUsedAt
      }
    }
  }
}
```

`revokeApiKey` and `revokeCompanyApiKey` take the key's `id`, and the key stops working at once. The calling key can revoke itself. Revoking a key again, or a key that already expired, succeeds and writes no new audit entry. A revoked workspace key reads `expiresAt` as the moment it was revoked. A revoked account key has `revokedAt`.

```graphql theme={"system"}
mutation RevokeWorkspaceKey($input: RevokeApiKeyInput!) {
  revokeApiKey(input: $input) {
    apiKey {
      id
      name
      expiresAt
    }
  }
}
```

```json theme={"system"}
{
  "input": {
    "id": "1042"
  }
}
```

```graphql theme={"system"}
mutation RevokeAccountKey($input: RevokeCompanyApiKeyInput!) {
  revokeCompanyApiKey(input: $input) {
    companyApiKey {
      id
      name
      revokedAt
    }
  }
}
```

```json theme={"system"}
{
  "input": {
    "id": "87"
  }
}
```

## Rotate a key

To rotate a key, create its successor, move your clients to it, then revoke the old key.

**1. Create the successor**

Call `createApiKey` or `createCompanyApiKey` with the same capability groups and, for an account key, the same workspaces. Give it a new name, such as one with the date: a name that a working key holds is a `CONFLICT`.

**2. Move your clients**

Store the new token, and update every script, CI job, and secret store that uses the old one.

**3. Revoke the old key**

Call `revokeApiKey` or `revokeCompanyApiKey` with the old key's `id`. The old key can make this call itself, as its last request.

> [!NOTE]
>
> A key can't create a key that expires later than itself. To rotate to a later expiry, create the successor with a key that expires later, or never, or generate it in Paradime. The lists return each key's capabilities, such as `bolt:schedules:list`, not its capability groups, so keep the groups each key needs in your own configuration.

## Errors

These are the cases specific to API keys. For the error format and the codes every area shares, see [Errors](https://docs.paradime.io/developers/graphql-api/admin-api/conventions.md#errors).

| Code | When |
| - | - |
| `MISSING_CAPABILITY` | The calling key doesn't hold a group it gives, can't reach a workspace it grants, or tries to revoke a key with more access than its own. A workspace API key calls `companyApiKeys`, `createCompanyApiKey`, or `revokeCompanyApiKey`. |
| `VALIDATION_FAILED` | The name is blank. No group or no workspace is given. A group can't go on that key type. `expiresAt` is in the past, missing, or later than the calling key's expiry. |
| `CONFLICT` | A working key already has the name. Its token can't be shown again: create the key under another name, or revoke the old one first. |
| `NOT_FOUND` | No key with the `id` is in the workspace, or in the account. |
| `PLAN_UPGRADE_REQUIRED` | The account's plan doesn't include a group you give. |

## Related

* [API keys](https://docs.paradime.io/developers/api-keys.md): account and workspace API keys, and how to generate them in Paradime.
* [Authentication](https://docs.paradime.io/developers/graphql-api/authentication.md): send a key with each request.
* [API keys settings](https://docs.paradime.io/products/settings/configuration/api-keys.md): where API keys live in Paradime.

The Python SDK and the CLI have no commands for API keys: use the GraphQL API.


## Related topics

- [Administration API](https://docs.paradime.io/developers/graphql-api/admin-api/index.md)
- [API keys](https://docs.paradime.io/products/settings/configuration/api-keys.md)
- [Administration API: Conventions](https://docs.paradime.io/developers/graphql-api/admin-api/conventions.md)
- [Administration API: Integrations](https://docs.paradime.io/developers/graphql-api/admin-api/integrations.md)
- [Administration API: Workspaces](https://docs.paradime.io/developers/graphql-api/admin-api/workspaces.md)


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