promote_member
Promote a participant to admin role in a WhatsApp group using session ID, group ID, and participant phone ID.
Instructions
Promote a group participant to admin role
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID | |
| groupId | Yes | Group ID | |
| participantId | Yes | Phone ID of the participant to promote |
Implementation Reference
- src/tools/groups.ts:94-111 (registration)Registration of the 'promote_member' tool with description and input schema using server.registerTool().
server.registerTool( "promote_member", { description: "Promote a group participant to admin role", inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), participantId: z.string().describe("Phone ID of the participant to promote"), }, }, async ({ sessionId, groupId, participantId }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/groups/${groupId}/members/${participantId}/promote`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } ); - src/tools/groups.ts:104-110 (handler)Handler function for 'promote_member' that calls openwaClient with POST to the promote endpoint and returns JSON response.
async ({ sessionId, groupId, participantId }) => { const data = await openwaClient({ method: "POST", path: `/sessions/${sessionId}/groups/${groupId}/members/${participantId}/promote`, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } - src/tools/groups.ts:98-102 (schema)Input schema for 'promote_member' defining required parameters: sessionId, groupId, and participantId (all strings).
inputSchema: { sessionId: z.string().describe("Session ID"), groupId: z.string().describe("Group ID"), participantId: z.string().describe("Phone ID of the participant to promote"), }, - 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; } }