APIKeys object
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, that can be instantly revoked.
The APIKeys object is available on the Clerk object. Use the useClerk() hook to access the clerk object, as shown in the following example.
import { useClerk } from '@clerk/react'
export default function Example() {
// Use the useClerk hook to access the clerk object
const clerk = useClerk()
// Access the APIKeys object
const apiKeys = clerk.apiKeys
return <pre>{JSON.stringify(apiKeys, null, 2)}</pre>
}Properties
The APIKeys methods create, list, and revoke APIKeyResource objects. The properties below describe APIKeyResource.
- Name
-
secret? - Type
string- Description
The API key secret. This property is only present in the response from create() and cannot be retrieved later.
Methods
create()
Creates a new API key.
Returns an APIKeyResource object that includes the secret property.
function create(params: CreateAPIKeyParams): Promise<APIKeyResource>getAll()
Gets a paginated list of API keys for the current user or organization.
Returns a ClerkPaginatedResponse of APIKeyResource objects.
function getAll(params?: GetAPIKeysParams): Promise<ClerkPaginatedResponse<APIKeyResource>>- Name
query?- Type
string- Description
A search query to filter API keys by name.
- Name
subject?- Type
string- Description
The user or organization ID to query API keys by. If not provided, defaults to the , then the current User.
reload()
Reloads the resource, which is useful when you want to access the latest user data after performing a mutation. To make the updated data immediately available, this method forces a session token refresh instead of waiting for the automatic refresh cycle that could temporarily retain stale information. Learn more about forcing a token refresh.
function reload(p?: ClerkResourceReloadParams): Promise<APIKeyResource>function revoke(params: RevokeAPIKeyParams): Promise<APIKeyResource>Feedback
Last updated on