list() - API keys | Clerk Docs
list()
Gets a list of API keys for the given user or Organization. By default, the list is returned in descending order by creation date (newest first).
Returns a PaginatedResourceResponse object with a data property containing an array of APIKey objects and a totalCount property containing the total number of API keys for the user or Organization.
function list(queryParams: GetAPIKeyListParams): Promise<PaginatedResourceResponse<APIKey[]>>
GetAPIKeyListParams
Name:
includeInvalid?
Type:boolean
Description: Whether to include invalid API keys (revoked or expired). Defaults tofalse.Name:
limit?
Type:number
Description: Maximum number of items returned per request. Must be an integer greater than zero and less than501. Can be used for paginating the results together with offset. Defaults to10.Name:
offset?
Type:number
Description: Skip the firstoffsetitems when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction withlimit. Defaults to0.Name:
subject
Type:string
Description: The user or Organization ID to query API keys by.
Usage
Filter by user ID
Gets a list of API keys for a user
const userId = 'user_123'
const apiKeys = await clerkClient.apiKeys.list({
subject: userId,
})
Filter by user ID, including invalid API keys
Gets a list of API keys for a user, including invalid ones
const userId = 'user_123'
const apiKeys = await clerkClient.apiKeys.list({
subject: userId,
includeInvalid: true,
})
Filter by user ID, including invalid API keys, with pagination
Gets a list of API keys for a user with pagination
const userId = 'user_123'
const apiKeys = await clerkClient.apiKeys.list({
subject: userId,
limit: 20,
offset: 0,
})
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint GET/api_keys. See the BAPI reference for more information.