diff --git a/.changeset/mighty-kids-joke.md b/.changeset/mighty-kids-joke.md new file mode 100644 index 00000000000..1ba9b860f47 --- /dev/null +++ b/.changeset/mighty-kids-joke.md @@ -0,0 +1,5 @@ +--- +"@clerk/backend": patch +--- + +Added API keys list method to the backend SDK client diff --git a/packages/backend/src/api/endpoints/APIKeysApi.ts b/packages/backend/src/api/endpoints/APIKeysApi.ts index bf0767d3a16..cc78e803299 100644 --- a/packages/backend/src/api/endpoints/APIKeysApi.ts +++ b/packages/backend/src/api/endpoints/APIKeysApi.ts @@ -1,9 +1,24 @@ +import type { ClerkPaginationRequest } from '@clerk/types'; + import { joinPaths } from '../../util/path'; import type { APIKey } from '../resources/APIKey'; import { AbstractAPI } from './AbstractApi'; const basePath = '/api_keys'; +type GetAPIKeyListParams = ClerkPaginationRequest<{ + /** + * The user or organization ID to query API keys by + */ + subject: string; + /** + * Whether to include invalid API keys. + * + * @default false + */ + includeInvalid?: boolean; +}>; + type CreateAPIKeyParams = { type?: 'api_key'; /** @@ -11,7 +26,7 @@ type CreateAPIKeyParams = { */ name: string; /** - * user or organization ID the API key is associated with + * The user or organization ID to associate the API key with */ subject: string; /** @@ -36,6 +51,14 @@ type RevokeAPIKeyParams = { }; export class APIKeysAPI extends AbstractAPI { + async list(queryParams: GetAPIKeyListParams) { + return this.request({ + method: 'GET', + path: basePath, + queryParams, + }); + } + async create(params: CreateAPIKeyParams) { return this.request({ method: 'POST',