revoke() - API keys | Clerk Docs

revoke()

RevokeAPIKeyParams

Usage

Revoke an API key

const apiKeyId = 'apikey_123'

const response = await clerkClient.apiKeys.revoke({
  apiKeyId: apiKeyId,
})

Revoke an API key with a reason

const apiKeyId = 'apikey_123'

const response = await clerkClient.apiKeys.revoke({
  apiKeyId: apiKeyId,
  revocationReason: 'Key compromised',
})

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/api_keys/{apiKeyID}/revoke. See the BAPI reference for more information.

Revokes the given API key. This will immediately invalidate the API key and prevent it from being used to authenticate any future requests.

Returns the revoked APIKey object.

function revoke(params: RevokeAPIKeyParams): Promise<APIKey>

Important: When you revoke an API key, it is immediately invalidated. Any requests using that API key will be rejected. Make sure to notify users or update your systems before revoking API keys that are in active use.