web3_revoke_key
Revoke an API key using a signed SIWE challenge and the key ID from web3_list_keys.
Instructions
Revoke a specific API key. Requires a fresh SIWE challenge signed with personal_sign. Use web3_list_keys first to get the key_id to revoke.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | The SIWE message from web3_challenge | |
| signature | Yes | Hex-encoded signature from personal_sign (0x-prefixed, 65 bytes) | |
| key_id | Yes | UUID of the API key to revoke (from web3_list_keys) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Result data object |
Implementation Reference
- src/index.ts:2195-2234 (handler)Handler function that executes the web3_revoke_key tool logic. Takes a SIWE message, signature, and key_id as input. Delegates to the SDK's web3.revokeKey method if a client exists, otherwise makes a direct POST to https://api.0xarchive.io/v1/web3/keys/revoke. Returns the API response or an error.
// Web3 revoke key — works even without API key server.registerTool( "web3_revoke_key", { description: "Revoke a specific API key. Requires a fresh SIWE challenge signed with personal_sign. " + "Use web3_list_keys first to get the key_id to revoke.", inputSchema: { message: z.string().describe("The SIWE message from web3_challenge"), signature: z.string().describe("Hex-encoded signature from personal_sign (0x-prefixed, 65 bytes)"), key_id: z.string().describe("UUID of the API key to revoke (from web3_list_keys)"), }, outputSchema: ObjectOutputSchema, annotations: AUTH_TOOL_ANNOTATIONS, }, async (params: any) => { try { if (client) { const data = await api().web3.revokeKey(params.message, params.signature, params.key_id); return formatResponse(data); } const response = await fetch("https://api.0xarchive.io/v1/web3/keys/revoke", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ message: params.message, signature: params.signature, key_id: params.key_id }), }); const data = await response.json(); if (!response.ok) { return { content: [{ type: "text" as const, text: `Error: ${data.error || "Revoke key failed"}` }], isError: true, }; } return formatResponse(data); } catch (err) { const error = err instanceof OxArchiveError ? err : new OxArchiveError(String(err), 500); return formatError(error); } } ); - src/index.ts:2202-2208 (schema)Input validation schema requiring message (SIWE challenge), signature (personal_sign hex), and key_id (API key UUID). Output schema is the shared ObjectOutputSchema.
inputSchema: { message: z.string().describe("The SIWE message from web3_challenge"), signature: z.string().describe("Hex-encoded signature from personal_sign (0x-prefixed, 65 bytes)"), key_id: z.string().describe("UUID of the API key to revoke (from web3_list_keys)"), }, outputSchema: ObjectOutputSchema, annotations: AUTH_TOOL_ANNOTATIONS, - src/index.ts:2196-2234 (registration)Registration of the web3_revoke_key tool via server.registerTool with its description, input/output schemas, AUTH_TOOL_ANNOTATIONS (readOnlyHint: false), and handler function.
server.registerTool( "web3_revoke_key", { description: "Revoke a specific API key. Requires a fresh SIWE challenge signed with personal_sign. " + "Use web3_list_keys first to get the key_id to revoke.", inputSchema: { message: z.string().describe("The SIWE message from web3_challenge"), signature: z.string().describe("Hex-encoded signature from personal_sign (0x-prefixed, 65 bytes)"), key_id: z.string().describe("UUID of the API key to revoke (from web3_list_keys)"), }, outputSchema: ObjectOutputSchema, annotations: AUTH_TOOL_ANNOTATIONS, }, async (params: any) => { try { if (client) { const data = await api().web3.revokeKey(params.message, params.signature, params.key_id); return formatResponse(data); } const response = await fetch("https://api.0xarchive.io/v1/web3/keys/revoke", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ message: params.message, signature: params.signature, key_id: params.key_id }), }); const data = await response.json(); if (!response.ok) { return { content: [{ type: "text" as const, text: `Error: ${data.error || "Revoke key failed"}` }], isError: true, }; } return formatResponse(data); } catch (err) { const error = err instanceof OxArchiveError ? err : new OxArchiveError(String(err), 500); return formatError(error); } } ); - src/index.ts:2065-2070 (helper)Shared annotations for web3 authentication tools, marking the tool as non-read-only (since it revokes API keys).
const AUTH_TOOL_ANNOTATIONS = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, } as const; - src/index.ts:139-141 (helper)Shared output schema used by web3_revoke_key for its response format.
const ObjectOutputSchema: ZodRawShape = { data: z.record(z.unknown()).describe("Result data object"), };