API Keys
An API key is one version of a consumer's credential. A consumer's keys are
listed and rolled at …/consumers/{consumerId}/api-keys, and each key is
addressed by its ID, /v4/buckets/{bucketId}/api-keys/{apiKeyId}, for example
to revoke a leaked key without looking up its consumer.
Rolling is creating the replacement: a new key for the consumer, whose other
keys expire right away or after previousKeyGracePeriodSeconds. Outside a
roll's grace period, a consumer has one working key.
The full secret is returned when a key is created. After that, reads show only
maskedKey. The one exception is a person's own consumers in a user app: the
person reads a key's secret at …/api-keys/{apiKeyId}/secret, for example for
a key an admin issued for them. The secret belongs to a key, not to its
consumer, which can have several keys during a roll's grace period.
Get an API key
Returns an API key and the consumer it belongs to, with only the masked key.
List a consumer's keys at …/consumers/{consumerId}/api-keys. Anyone who
can read the key's consumer can read the key.
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
apiKeyIdThe API key ID (key_…). This is the key's identifier, not its secret.
Get an API key › Responses
The API key.
idThe key ID. Not the secret.
consumerIdThe consumer the key belongs to.
descriptionWhat the key is used for.
maskedKeyThe first and last characters of the secret, to recognize the key.
expiresOnWhen the key stops working, or null if it never expires.
createdOnWhen the key was created.
updatedOnWhen the key was last changed.
Update an API key
Updates an API key's description or expiry with JSON Merge Patch semantics.
A key cannot move to another consumer. Anyone who can change the key's
consumer can change the key; others get 403.
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
apiKeyIdThe API key ID (key_…). This is the key's identifier, not its secret.
Update an API key › Request Body
descriptionWhat the key is used for. Null clears it.
expiresOnWhen the key stops working. Null removes the expiry.
Update an API key › Responses
The updated API key.
idThe key ID. Not the secret.
consumerIdThe consumer the key belongs to.
descriptionWhat the key is used for.
maskedKeyThe first and last characters of the secret, to recognize the key.
expiresOnWhen the key stops working, or null if it never expires.
createdOnWhen the key was created.
updatedOnWhen the key was last changed.
Revoke an API key
Revokes an API key immediately, for example when it leaked or to end a roll's
grace period early. Its ID is enough: you do not need its consumer. A repeated
delete returns 404, which clients should treat as success. Anyone who can
change the key's consumer can revoke the key; others get 403.
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
apiKeyIdThe API key ID (key_…). This is the key's identifier, not its secret.
Revoke an API key › Responses
The key was revoked.
Get an API key's secret
Returns the full secret of one key of a personal consumer to the person who
holds the consumer. Nobody else can read it, user app admins included: they
see the secret only in the response that created the key. The keys of app and
bucket consumers show their secret only when they are created, so this fails
with 403 for them. Find the key in the consumer's keys,
GET …/consumers/{consumerId}/api-keys, which lists the newest first.
The response must not be stored (Cache-Control: no-store).
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
apiKeyIdThe API key ID (key_…). This is the key's identifier, not its secret.
Get an API key's secret › Responses
The key's secret.
apiKeyIdThe key the secret belongs to.
secretThe full API key. Send it as Authorization: Bearer <secret>.
List a consumer's API keys
Lists the consumer's keys, newest first: its current key and the keys it replaced. Only masked keys are returned. Anyone who can read the consumer can list its keys.
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
consumerIdThe consumer ID (csmr_…).
query Parameters
limitThe maximum number of items to return.
offsetThe number of items to skip before the first item returned.
List a consumer's API keys › Responses
A page of the consumer's API keys.
The API keys on this page.
limitThe page size that was applied.
offsetThe number of items skipped before this page.
totalThe number of items in the whole collection.
hasMoreWhether there are more items after this page.
nextThe relative URL of the next page, or null on the last page.
Roll a consumer's API key
Issues a new key for the consumer, which is how a key is rolled: the
consumer's other keys expire right away, or after the
previousKeyGracePeriodSeconds in the query so its clients can switch over.
A key that already expires sooner keeps its expiry. The body is the new key.
Anyone who can change the consumer can roll it; pool admins cannot roll an
app's consumer, and get 403. A consumer that holds a subscription (API
monetization) cannot be rolled through v4 and gets 409.
The response contains the full secret. This is the only time it is
returned to the caller, so store it now. A retry issues another key, which
replaces this one, so keep the key from the last response.
path Parameters
bucketIdThe bucket ID (bckt_…). Everything in a bucket is addressed under it.
consumerIdThe consumer ID (csmr_…).
query Parameters
previousKeyGracePeriodSecondsHow long the consumer's other keys keep working after the new key is issued, in seconds (at most 30 days). Omit or send 0 to expire them right away. A key that already expires sooner keeps its expiry.
Roll a consumer's API key › Request Body
descriptionWhat the key is used for.
expiresOnWhen the key stops working. Omit for a key that never expires.
Roll a consumer's API key › Responses
The key was created. secret is shown only in this response.
idThe key ID. Not the secret.
consumerIdThe consumer the key belongs to.
descriptionWhat the key is used for.
maskedKeyThe first and last characters of the secret, to recognize the key later.
expiresOnWhen the key stops working, or null if it never expires.
createdOnWhen the key was created.
updatedOnWhen the key was last changed.
secretThe full API key. Send it as Authorization: Bearer <secret>. Returned only in this response.