Skip to main content
POST
Create API Key

Authorizations

Authorization
string
header
required

An API key, sent as Authorization: Bearer <key>. Create one in the SWITCH Copilot under Settings → API keys (needs the API keys permission in your company), or with POST /auth/api-keys. The key is shown once, at creation.

Body

application/json

Schema for creating a new API key.

Used in API requests to create a new API key resource, optionally specifying expiration and scopes.

name
string
required

Name of the new API key.

exp
string<date-time> | null

When the key expires (ISO 8601), in the future and at most 365 days ahead (422 config_invalid otherwise). Omitted: 365 days from now.

auth_scopes
string[] | null

Deprecated, prefer narrowing: legacy scope slugs for the key, each one you hold (400 otherwise). Without narrowing, the key's cap is derived from them. Omitted: all your scopes.

narrowing
Narrowing · object | null

Optional cap per resource, {resource: level} with levels none, read, use, manage (resources as in access.resources of GET /auth/me). The key acts with the lower of the cap and your own level; a cap above your level is refused (422). Omitted: the key acts with your permissions.

Response

API key successfully created with metadata and key string.

Public schema for an API key returned at creation time.

Extends ApiKeyPublic to include the actual key string, which is only shown once at creation.

uuid
string
required

Unique UUID identifier for the API key.

name
string
required

Name of the API key.

created_at
string<date-time>
required

Datetime when the API key was created.

auth_scopes
AuthScopePublic · object[]
required

List of authorization scopes assigned to the API key.

key
string
required

The API key itself, returned only in this response: store it now. Send it as Authorization: Bearer <key>.

exp
string<date-time> | null

When the key expires (UTC).