Revoke API Key
revoke_api_keyPermanently invalidate an API key to block all future requests. Any subsequent use returns a 401 error; this action cannot be reversed.
Instructions
Permanently invalidate an API key. Any subsequent request using it returns 401. Cannot be undone — the user would have to create_api_key again.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key_id | Yes | UUID of the key to revoke (from `list_api_keys`). |
Implementation Reference
- Tool definition with the handler function that calls ctx.api.revokeApiKey(input.key_id) and returns { revoked: true } on success.
export const revokeApiKeyTool: Tool<RevokeApiKeyInputShape, RevokeApiKeyOutput> = { name: "revoke_api_key", description: "Permanently invalidate an API key. Any subsequent request using it returns 401. Cannot be undone — the user would have to `create_api_key` again.", annotations: { title: "Revoke API Key", readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false, }, inputSchema: z.object(RevokeApiKeyInputShape), handler: async (input, ctx): Promise<Result<RevokeApiKeyOutput, ToolError>> => { const result = await ctx.api.revokeApiKey(input.key_id); if (result.isErr()) return err(mapApiError(result.error)); return ok({ revoked: true }); }, }; - Input schema requiring a UUID key_id string, and output type with { revoked: true }.
const RevokeApiKeyInputShape = { key_id: z.string().uuid().describe("UUID of the key to revoke (from `list_api_keys`)."), } as const; type RevokeApiKeyInputShape = typeof RevokeApiKeyInputShape; export interface RevokeApiKeyOutput { readonly revoked: true; } - src/application/tool-registry.ts:116-116 (registration)Registration of revokeApiKeyTool in the central tool registry (registerAllTools function).
register(revokeApiKeyTool); - The parseEmpty parser used by the HTTP gateway's revokeApiKey implementation for the 204 No Content response.
/** * Parser for `204 No Content` responses. Ignores the input (which is * `null` for a successful empty body, or whatever undici left in `data`) * and always returns `Ok(null)`. Used by every mutator that the API * answers without echoing the entity back — see e.g. `removeUser`, * `revokeApiKey`, `requestPolicySetApproval`, `setAlertDestinationVersion`. */ export function parseEmpty(_raw: unknown): Result<null, ApiError> { return ok(null); } - HTTP gateway implementation that sends a DELETE request to /api/v1/account/api-keys/{key_id}.
async revokeApiKey(keyId: string): Promise<Result<null, ApiError>> { return call( "DELETE", "/api/v1/account/api-keys/{key_id}", { params: { path: { key_id: keyId } } }, parseEmpty ); },