Skip to main content

Create an API Key

POST/v1/api-keysTry it
View request and response examples ↓

Creates an API Key in the organization of the authenticated API Key. Requires an API Key with the OrganizationAdmin role and a RequestId header.

This endpoint cannot create an organization's first API Key: obtain the first OrganizationAdmin API Key from the console, then use that key to call this endpoint. The plaintext apiKey is returned only in this successful creation response. Store it securely; list and update responses never return the plaintext key or its hash.

The new API Key can contain multiple built-in or custom role IDs available to the authenticated organization. Its IP allowlist is enforced during API Key authentication.

Authorization

X-API-Keystring · headerrequired

API key for /v1 requests.

Headers

RequestIdstringrequired

Idempotency key for write requests.

Use a globally unique UUID or similar token for each logical write request. Never reuse a RequestId across different operations or payloads. You can safely retry the same RequestId only when the method, path, path parameters, query string, and request body are identical.

Minimum length1
Example8f6b0c2e-6a9a-4f2e-9c4c-0a1f9a2b7d31

Request body

application/jsonrequired

API Key metadata to create in the authenticated organization. name and roles are required.

Provide a future expiresAt when neverExpires is omitted or false. Set neverExpires to true to create an API Key without an expiration time; when true, omit expiresAt. Do not send expiresAt and neverExpires=true together.

Expiring API Key example: provide expiresAt. Never-expiring API Key example: provide neverExpires: true and omit expiresAt. roles can contain multiple built-in or custom role IDs available to the authenticated organization. Use the roleId values returned by GET /v1/roles. When allowIps is omitted, the API Key can be used from any source IP address; when present, it is enforced during API Key authentication.

namestringrequired

Display name for the API Key. Leading and trailing whitespace is removed.

Minimum length1
Maximum length128
Exampledeployment-automation

Optional description for the API Key.

ExampleAPI Key used by the deployment automation service.
rolesstring[]required

Required role IDs assigned to the API Key. Use the roleId values returned by GET /v1/roles.

Built-in role IDs are organizationadmin, warehouseadmin, warehouseview, WarehouseAdminReadOnly, and OrganizationBilling.

Minimum items1
Example["organizationadmin"]
allowIpsstring[]

Optional source IP allowlist. When omitted, the API Key can be used from any source IP address. When provided, it can be used only from the listed IPv4 or IPv6 addresses or CIDR ranges.

Example["203.0.113.10","2001:db8:100::/64"]
expiresAtstring · date-time

Expiration time in ISO 8601 format. Required unless neverExpires is true; must be later than the current time.

Example2027-04-21T08:30:00Z

Set to true for an API Key without an expiration time. When true, omit expiresAt.

Response

API Key created successfully. The plaintext API Key is returned only in this response.

application/json
successbooleanrequired

Indicates whether the request succeeded.

Exampletrue
requestIdstringrequired

Request ID returned by the server for tracing.

Examplereq-20260402-001
dataobjectrequired

API Key creation result. The plaintext apiKey is returned only once in the successful creation response.

Child fields
apiKeystringrequired

Newly generated plaintext API Key. Store it securely; it cannot be retrieved again.

Exampleopaque-api-key-returned-once
apiKeyInfoobjectrequired

Non-sensitive API Key metadata. This object never includes the plaintext API Key or its stored hash.

status is 1 for active, 2 for disabled, and 3 for expired. An API Key whose expiresAt has passed is returned as expired even if its stored status was previously active.

Child fields
keyIdstringrequired

Stable API Key identifier.

Examplekey_0123456789ABCDEF
namestringrequired

API Key display name.

Exampledeployment-automation

API Key description, when set.

ExampleAPI Key used by the deployment automation service.
statusintegerrequired

API Key status: 1 active, 2 disabled, or 3 expired.

Allowed values123
Example1

Reason supplied when the API Key was disabled, when present.

ExampleRotation in progress.
rolesstring[]required

Built-in or custom role IDs assigned to the API Key.

Example["organizationadmin"]
allowIpsstring[]required

Source IP allowlist enforced during API Key authentication. Empty when no allowlist is configured, which allows any source IP address.

Example["203.0.113.10","2001:db8:100::/64"]
createdBystring

ID of the API Key that created this API Key, when available.

Examplekey_ABCDEF0123456789
createdAtstring · date-timerequired

Creation time in ISO 8601 format.

Example2026-04-21T08:30:00Z
updatedAtstring · date-timerequired

Last update time in ISO 8601 format.

Example2026-04-21T08:30:00Z
lastUsedAtstring · date-time

Most recent successful authentication time in ISO 8601 format, when available.

Example2026-04-22T08:30:00Z

Source IP address used for the most recent successful authentication, when available.

Example203.0.113.10
expiresAtstring · date-time

Expiration time in ISO 8601 format, when configured.

Example2027-04-21T08:30:00Z

Enter to send · Shift+Enter for a new line