The
api_keys client methods are currently in BETA. The API may change without notice. A one-time warning is emitted on first use.Key Capabilities
- List API keys with optional filtering by type or status
- Create user keys (account-scoped) or service keys (space-scoped)
- Revoke keys immediately and permanently
- Refresh (rotate) a key while preserving its name and scope
List API Keys
List API keys with cursor-based pagination. Optionally filter bykey_type ("USER" or "SERVICE"), status ("ACTIVE" or "REVOKED"), space (name or ID — returns service keys for that space), and user_id (filter by creator for service keys, or view another user’s keys as an account admin). When status is omitted, only active keys are returned.
Create an API Key
Two key types are supported via separate methods:- User key (
create) — authenticates as the creating user with their full permissions. - Service key (
create_service_key) — backed by a dedicated bot user, scoped to one or more organizations and the spaces within them, with configurable roles.
User Key
Service Key
Service keys are tied to a dedicated service account scoped to one or more organizations, each containing one or more spaces (all spaces must belong to the same account). Passorgs as a list of OrgBinding objects, each holding an org_id, at least one SpaceBinding, and an optional org-level role. When a role is omitted, the server applies the default predefined role (MEMBER for spaces, READ_ONLY for orgs, MEMBER for the account). All role assignments must be at or below the caller’s own privilege level.
role field on each SpaceBinding / OrgBinding (and pass an account_role for the account level). Use PredefinedRoleAssignment / OrganizationPredefinedRoleAssignment for built-in roles (ADMIN, MEMBER, READ_ONLY) or CustomRoleAssignment / OrganizationCustomRoleAssignment for custom RBAC roles:
Revoke an API Key
Revoke a key by ID. The key’s status is set toREVOKED and it is deactivated immediately and permanently. This operation is irreversible. Revoking an already-revoked key is a no-op and still succeeds.
Refresh an API Key
Revoke an existing key and issue a replacement with the same name, description, type, and scope. A new raw key value is returned. Usegrace_period_seconds to keep the old key valid briefly while your services rotate to the new key.