delete_webhook
Remove a webhook from a WhatsApp session by providing the session ID and webhook ID. Stops notifications from being sent to that webhook URL.
Instructions
Delete a webhook from a WhatsApp session
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| webhookId | Yes | Webhook ID to delete |
Implementation Reference
- src/tools/webhooks.ts:50-57 (handler)Handler function that executes the delete_webhook tool logic. It sends a DELETE request to the OpenWA API with the session ID and webhook ID.
async ({ sessionId, webhookId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/webhooks/${webhookId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/webhooks.ts:42-49 (schema)Schema and registration for the delete_webhook tool. Defines the input schema with sessionId (string) and webhookId (string) parameters.
"delete_webhook", { description: "Delete a webhook from a WhatsApp session", inputSchema: { sessionId: z.string().describe("Session ID"), webhookId: z.string().describe("Webhook ID to delete"), }, }, - src/tools/webhooks.ts:41-57 (registration)Registration of the delete_webhook tool via server.registerTool() within the registerWebhookTools function.
server.registerTool( "delete_webhook", { description: "Delete a webhook from a WhatsApp session", inputSchema: { sessionId: z.string().describe("Session ID"), webhookId: z.string().describe("Webhook ID to delete"), }, }, async ({ sessionId, webhookId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/webhooks/${webhookId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/client.ts:10-35 (helper)The openwaClient helper function used by the handler to make the HTTP DELETE request to the backend API.
export async function openwaClient<T = unknown>(opts: RequestOptions): Promise<T> { const url = `${BASE_URL}${opts.path}`; const headers: Record<string, string> = { "Content-Type": "application/json", "X-API-Key": API_KEY, }; const res = await fetch(url, { method: opts.method, headers, body: opts.body ? JSON.stringify(opts.body) : undefined, }); const text = await res.text(); if (!res.ok) { throw new Error(`OpenWA API ${res.status}: ${text}`); } try { return JSON.parse(text) as T; } catch { return text as T; } } - src/index.ts:9-20 (registration)Import and invocation of registerWebhookTools which registers the delete_webhook tool on the MCP server.
import { registerWebhookTools } from "./tools/webhooks.js"; import { registerLabelTools } from "./tools/labels.js"; import { registerMediaTools } from "./tools/media.js"; const server = new McpServer({ name: "openwa-mcp", version: "1.0.0" }); registerSessionTools(server); registerMessageTools(server); registerBulkTools(server); registerGroupTools(server); registerContactTools(server); registerWebhookTools(server);