Skip to main content

Note

Looking for the and you use to connect your own app to Clerk? Those are different from the API keys described here. You can copy them from the API keys page in the Clerk Dashboard, or learn more in the Clerk environment variables reference.

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[]>>
  • Name
    includeInvalid?
    Type
    boolean
    Description

    Whether to include invalid API keys (revoked or expired). Defaults to false.

  • Name
    limit?
    Type
    number
    Description

    Maximum number of items returned per request. Must be an integer greater than zero and less than 501. Can be used for paginating the results together with offset. Defaults to 10.

  • Name
    offset?
    Type
    number
    Description

    Skip the first offset items when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit. Defaults to 0.

  • Name
    subject
    Type
    string
    Description

    The user or Organization ID to query API keys by.

Note

Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.

Filer 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.

Feedback

What did you think of this content?

Last updated on