Skip to content

Commit 56a81aa

Browse files
authored
chore(backend): Add API keys list method (#6948)
1 parent 65b7cc7 commit 56a81aa

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

.changeset/mighty-kids-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/backend": patch
3+
---
4+
5+
Added API keys list method to the backend SDK client

packages/backend/src/api/endpoints/APIKeysApi.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1+
import type { ClerkPaginationRequest } from '@clerk/types';
2+
13
import { joinPaths } from '../../util/path';
24
import type { APIKey } from '../resources/APIKey';
35
import { AbstractAPI } from './AbstractApi';
46

57
const basePath = '/api_keys';
68

9+
type GetAPIKeyListParams = ClerkPaginationRequest<{
10+
/**
11+
* The user or organization ID to query API keys by
12+
*/
13+
subject: string;
14+
/**
15+
* Whether to include invalid API keys.
16+
*
17+
* @default false
18+
*/
19+
includeInvalid?: boolean;
20+
}>;
21+
722
type CreateAPIKeyParams = {
823
type?: 'api_key';
924
/**
1025
* API key name
1126
*/
1227
name: string;
1328
/**
14-
* user or organization ID the API key is associated with
29+
* The user or organization ID to associate the API key with
1530
*/
1631
subject: string;
1732
/**
@@ -36,6 +51,14 @@ type RevokeAPIKeyParams = {
3651
};
3752

3853
export class APIKeysAPI extends AbstractAPI {
54+
async list(queryParams: GetAPIKeyListParams) {
55+
return this.request<APIKey[]>({
56+
method: 'GET',
57+
path: basePath,
58+
queryParams,
59+
});
60+
}
61+
3962
async create(params: CreateAPIKeyParams) {
4063
return this.request<APIKey>({
4164
method: 'POST',

0 commit comments

Comments
 (0)