update_webhook
Update an existing webhook by providing session ID and webhook ID. Specify new URL, event types, or signing secret.
Instructions
Update an existing webhook configuration
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| webhookId | Yes | Webhook ID to update | |
| url | No | New webhook endpoint URL | |
| events | No | Updated event types | |
| secret | No | Updated signing secret |
Implementation Reference
- src/tools/webhooks.ts:71-78 (handler)The handler function for the 'update_webhook' tool. It sends a PUT request to the OpenWA API with sessionId, webhookId, url, events, and secret to update an existing webhook configuration.
async ({ sessionId, webhookId, url, events, secret }) => { const data = await openwaClient({ method: "PUT", path: `/sessions/${sessionId}/webhooks/${webhookId}`, body: { url, events, secret }, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/webhooks.ts:63-69 (schema)The Zod input schema for the 'update_webhook' tool. Defines sessionId (required), webhookId (required), and optional fields: url, events (array of strings), and secret.
inputSchema: { sessionId: z.string().describe("Session ID"), webhookId: z.string().describe("Webhook ID to update"), url: z.string().optional().describe("New webhook endpoint URL"), events: z.array(z.string()).optional().describe("Updated event types"), secret: z.string().optional().describe("Updated signing secret"), }, - src/tools/webhooks.ts:59-79 (registration)The registration of the 'update_webhook' tool via server.registerTool() inside the registerWebhookTools function.
server.registerTool( "update_webhook", { description: "Update an existing webhook configuration", inputSchema: { sessionId: z.string().describe("Session ID"), webhookId: z.string().describe("Webhook ID to update"), url: z.string().optional().describe("New webhook endpoint URL"), events: z.array(z.string()).optional().describe("Updated event types"), secret: z.string().optional().describe("Updated signing secret"), }, }, async ({ sessionId, webhookId, url, events, secret }) => { const data = await openwaClient({ method: "PUT", path: `/sessions/${sessionId}/webhooks/${webhookId}`, body: { url, events, secret }, }); 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 HTTP requests to the OpenWA 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:20-21 (registration)Where registerWebhookTools is called to wire up all webhook tools (including update_webhook) to the MCP server.
registerWebhookTools(server); registerLabelTools(server);