whatsapp_update_api_key
Generate a new API key for your WhatsApp instance to maintain secure access and session management when using the WSAPI service.
Instructions
Generate a new API key for the instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/instance.ts:49-58 (handler)The handler function that implements the whatsapp_update_api_key tool. It generates a new API key by making a PUT request to the WSAPI endpoint '/instance/apikey' and returns the result.export const updateApiKey: ToolHandler = { name: 'whatsapp_update_api_key', description: 'Generate a new API key for the instance.', inputSchema: { type: 'object', properties: {} }, handler: async () => { logger.info('Updating API key'); const result = await wsapiClient.put('/instance/apikey', {}); return { success: true, apiKey: result, message: 'API key updated successfully' }; }, };
- src/tools/instance.ts:52-52 (schema)Input schema definition for the tool (no input parameters required).inputSchema: { type: 'object', properties: {} },
- src/tools/instance.ts:60-60 (registration)The updateApiKey tool is bundled into the instanceTools object for registration in the MCP server.export const instanceTools = { getInstanceSettings, updateInstanceSettings, restartInstance, updateApiKey };
- src/server.ts:53-79 (registration)The MCP server registers all tools from instanceTools (including whatsapp_update_api_key) into a Map for handling tool calls.private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
- src/server.ts:20-20 (registration)Imports the instanceTools object containing the whatsapp_update_api_key tool.import { instanceTools } from './tools/instance.js';