Repository navigation
Expand file tree
/
Copy pathapiKeys.ts
More file actions
94 lines (92 loc) · 3.1 KB
/
Copy pathapiKeys.ts
File metadata and controls
94 lines (92 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import type { CreateAPIKeyParams, GetAPIKeysParams, RevokeAPIKeyParams } from './clerk';
import type { ClerkPaginatedResponse } from './pagination';
import type { ClerkResource } from './resource';
/**
* The `APIKeys` object provides methods for managing API keys that allow your application's users to grant third-party services programmatic access to your application's API endpoints on their behalf. API keys are long-lived, opaque tokens that can be instantly revoked.
*/
export interface APIKeyResource extends ClerkResource {
/**
* A unique identifier for the API key.
*/
id: string;
/**
* The type of the API key.
*/
type: string;
/**
* The name of the API key.
*/
name: string;
/**
* The user or organization ID that the API key is associated with.
*/
subject: string;
/**
* An array of scopes that define what the API key can access.
*/
scopes: string[];
/**
* Custom claims associated with the API key, or `null` if none.
*/
claims: Record<string, any> | null;
/**
* Indicates whether the API key has been revoked.
*/
revoked: boolean;
/**
* The reason the API key was revoked, or `null` if not revoked.
*/
revocationReason: string | null;
/**
* Indicates whether the API key has expired.
*/
expired: boolean;
/**
* The expiration date and time for the API key, or `null` if the key never expires.
*/
expiration: Date | null;
/**
* The ID of the user that created the API key.
*/
createdBy: string | null;
/**
* A description for the API key.
*/
description: string | null;
/**
* The API key secret. **This property is only present in the response from [`create()`](https://clerk.com/docs/reference/objects/api-keys#create) and cannot be retrieved later.**
*/
secret?: string;
/**
* The date and time when the API key was last used to authenticate a request, or `null` if it has never been used.
*/
lastUsedAt: Date | null;
/**
* The date and time when the API key was created.
*/
createdAt: Date;
/**
* The date and time when the API key was last updated.
*/
updatedAt: Date;
}
/** @generateWithEmptyComment */
export interface APIKeysNamespace {
/**
* Gets a paginated list of API keys for the current user or organization.
* @returns A [`ClerkPaginatedResponse`](https://clerk.com/docs/reference/types/clerk-paginated-response) of [`APIKeyResource`](https://clerk.com/docs/reference/types/api-key-resource) objects.
*/
getAll(params?: GetAPIKeysParams): Promise<ClerkPaginatedResponse<APIKeyResource>>;
/**
* Creates a new API key.
* @returns An [`APIKeyResource`](https://clerk.com/docs/reference/types/api-key-resource) object that includes the `secret` property.
* > [!WARNING]
* > Make sure to store the API key secret immediately after creation, as it will not be available again.
*/
create(params: CreateAPIKeyParams): Promise<APIKeyResource>;
/**
* Revokes a given API key by ID.
* @returns An [`APIKeyResource`](https://clerk.com/docs/reference/types/api-key-resource) object.
*/
revoke(params: RevokeAPIKeyParams): Promise<APIKeyResource>;
}