Skip to main content

List API keys

Retrieve a paginated list of API keys for dashboard and administrative interfaces.

Use this to build key management dashboards, filter keys by user with externalId, or retrieve key details for administrative purposes. Each key includes status, metadata, permissions, and usage limits.

Important: Set decrypt: true only in secure contexts to retrieve plaintext key values from recoverable keys.

Required Permissions

Your root key must have one of the following permissions for basic key listing:

  • api.*.read_key (to read keys from any API)
  • api.<api_id>.read_key (to read keys from a specific API)

Additionally, you need read access to the API itself:

  • api.*.read_api or api.<api_id>.read_api

Additional permission required for decrypt functionality:

  • api.*.decrypt_key or api.<api_id>.decrypt_key
1 min read
post/v2/apis.listKeys
Request example
Response
post/v2/apis.listKeys

Authorization

Authorizationstringheaderrequired#

Unkey uses bearer tokens for authentication. Public integrations use root keys, while the dashboard proxy uses short-lived JWTs.
To authenticate, include the token in the Authorization header of each request:

Root keys have specific permissions attached to them, controlling what operations they can perform. Legacy permissions use tuple strings like api.*.create_key; resource permissions use Unkey Resource Names plus actions, like unkey:v1:ws_123:keyspaces/*#create_key.
Security best practices:

  • Keep root keys secure and never expose them in client-side code
  • Use different root keys for different environments
  • Rotate keys periodically, especially after team member departures
  • Create keys with minimal necessary permissions following least privilege principle
  • Monitor key usage with audit logs.

Body

application/json
apiIdstringrequired#

The API namespace whose keys you want to list.
Returns all keys in this API, subject to pagination and filters.

Length: min 1

limitinteger#

Maximum number of keys to return per request.
Balance between response size and number of pagination calls needed.

Default: 100

Range: 1–100

cursorstring#

Pagination cursor from previous response to fetch next page.
Use when hasMore: true in previous response.

externalIdstring#

Filter keys by external ID to find keys for a specific user or entity.
Must exactly match the externalId set during key creation.

Length: min 1

decryptboolean#

When true, attempts to include the plaintext key value in the response. SECURITY WARNING:

  • This requires special permissions on the calling root key
  • Only works for keys created with 'recoverable: true'
  • Exposes sensitive key material in the response
  • Should only be used in secure administrative contexts
  • Never enable this in user-facing applications

Default: false

revalidateKeysCacheboolean#

EXPERIMENTAL: Skip the cache and fetch the keys directly from the database. This ensures you see the most recent state, including keys created moments ago. Use this when:

  • You've just created a key and need to display it immediately
  • You need absolute certainty about the current key state
  • You're debugging cache consistency issues

This parameter comes with a performance cost and should be used sparingly.

Default: false

Responses

application/json
Successfully retrieved paginated keys. Use the pagination cursor for additional results when hasMore: true.
metaobjectrequired#
Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The requestId is particularly important when troubleshooting issues with the Unkey support team.
Show child attributes
requestIdstringrequired#
A unique id for this request. Always include this ID when contacting support about a specific API request. This identifier allows Unkey's support team to trace the exact request through logs and diagnostic systems to provide faster assistance.
dataobject[]required#
Array of API keys with complete configuration and metadata.

Items: max 100

Show child attributes
keyIdstringrequired#
Unique identifier for this key.

Length: 8–255Pattern: ^[a-zA-Z0-9_]+$

startstringrequired#
First few characters of the key for identification.

Length: 1–50

enabledbooleanrequired#
Whether the key is enabled or disabled.
namestring#
Human-readable name for this key.

Length: max 255

metaobject#
Custom metadata associated with this key.
createdAtintegerrequired#
Unix timestamp in milliseconds when key was created.

Range: 0–9223372036854776000

updatedAtinteger#
Unix timestamp in milliseconds when key was last updated.

Range: 0–9223372036854776000

lastUsedAtinteger#
Unix timestamp in milliseconds when key was last used for verification. This is an approximated value, accurate to within 5 minutes.

Range: >= 0

expiresinteger#
Unix timestamp in milliseconds when key expires (if set).

Range: 0–9223372036854776000

permissionsstring[]#
rolesstring[]#
creditsobject#
Credit configuration and remaining balance for this key.
Show child attributes
remainingintegerrequired#
Number of credits remaining (null for unlimited).

Range: 0–9223372036854776000

refillobject#
Configuration for automatic credit refill behavior.
Show child attributes
intervalenum<string>required#
How often credits are automatically refilled.
Options:dailymonthly
amountintegerrequired#
Number of credits to add during each refill cycle.

Range: 1–9223372036854776000

refillDayinteger#

Day of the month for monthly refills (1-31).
Only required when interval is 'monthly'.
For days beyond the month's length, refill occurs on the last day of the month.

Range: 1–31

identityobject#
Show child attributes
idstringrequired#
Identity ID
externalIdstringrequired#
External identity ID
metaobject#
Identity metadata
ratelimitsobject[]#
Identity ratelimits
Show child attributes
idstringrequired#
Unique identifier for this rate limit configuration.

Length: 8–255Pattern: ^rl_[a-zA-Z0-9_]+$

namestringrequired#
Human-readable name for this rate limit.

Length: 1–128

limitintegerrequired#
Maximum requests allowed within the time window.

Range: 1–1000000

durationintegerrequired#
Rate limit window duration in milliseconds.

Range: 1000–2592000000

autoApplybooleanrequired#
Whether this rate limit was automatically applied when verifying the key.
plaintextstring#
Decrypted key value (only when decrypt=true).
ratelimitsobject[]#

Items: max 50

Show child attributes
idstringrequired#
Unique identifier for this rate limit configuration.

Length: 8–255Pattern: ^rl_[a-zA-Z0-9_]+$

namestringrequired#
Human-readable name for this rate limit.

Length: 1–128

limitintegerrequired#
Maximum requests allowed within the time window.

Range: 1–1000000

durationintegerrequired#
Rate limit window duration in milliseconds.

Range: 1000–2592000000

autoApplybooleanrequired#
Whether this rate limit was automatically applied when verifying the key.
paginationobjectrequired#
Pagination metadata for list endpoints. Provides information necessary to traverse through large result sets efficiently using cursor-based pagination.
Show child attributes
cursorstring#

Opaque pagination token for retrieving the next page of results.
Include this exact value in the cursor field of subsequent requests.
Cursors are temporary and may expire after extended periods.

Length: 1–1024

hasMorebooleanrequired#

Indicates whether additional results exist beyond this page.
When true, use the cursor to fetch the next page.
When false, you have reached the end of the result set.