delete_message
Delete a specific message from a WhatsApp chat by providing session and message IDs.
Instructions
Delete a specific message from a WhatsApp chat
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| messageId | Yes | ID of the message to delete |
Implementation Reference
- src/tools/messages.ts:158-164 (handler)Handler function for the 'delete_message' tool. Makes a DELETE request to the OpenWA API at `/sessions/${sessionId}/messages/${messageId}`.
async ({ sessionId, messageId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/messages/${messageId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/messages.ts:151-156 (schema)Input schema for 'delete_message'. Defines required parameters: sessionId (string) and messageId (string).
{ description: "Delete a specific message from a WhatsApp chat", inputSchema: { sessionId: z.string().describe("Session ID"), messageId: z.string().describe("ID of the message to delete"), }, - src/tools/messages.ts:149-165 (registration)Registration of the 'delete_message' tool on the MCP server via server.registerTool().
server.registerTool( "delete_message", { description: "Delete a specific message from a WhatsApp chat", inputSchema: { sessionId: z.string().describe("Session ID"), messageId: z.string().describe("ID of the message to delete"), }, }, async ({ sessionId, messageId }) => { const data = await openwaClient({ method: "DELETE", path: `/sessions/${sessionId}/messages/${messageId}`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/client.ts:10-35 (helper)The openwaClient helper 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:15-16 (registration)Entry point where registerMessageTools (which registers delete_message) is called.
registerSessionTools(server); registerMessageTools(server);