Skip to main content
Glama
wsapi-chat
by wsapi-chat

whatsapp_get_pair_code

Generate a WhatsApp pairing code for logging into an account using a phone number. This tool enables authentication by creating a code that connects to the WhatsApp service.

Instructions

Get pairing code for WhatsApp login.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
phoneYesPhone number (10-15 digits)

Implementation Reference

  • The main handler implementation for the 'whatsapp_get_pair_code' tool. It validates the input phone number using getSessionLoginCodeSchema, logs the request, fetches the pair code from the WSAPI endpoint `/session/login/code/{phone}`, and returns the result.
    export const getPairCode: ToolHandler = { name: 'whatsapp_get_pair_code', description: 'Get pairing code for WhatsApp login.', inputSchema: { type: 'object', properties: { phone: { type: 'string', description: 'Phone number (10-15 digits)' } }, required: ['phone'], }, handler: async (args: any) => { const input = validateInput(getSessionLoginCodeSchema, args); logger.info('Getting pair code', { phone: input.phone }); const result = await wsapiClient.get(`/session/login/code/${input.phone}`); return { success: true, pairCode: result, message: 'Pair code retrieved successfully' }; }, };
  • Zod schema used for validating the input 'phone' parameter (10-15 digits) in the whatsapp_get_pair_code handler.
    export const getSessionLoginCodeSchema = z.object({ phone: z.string().regex(/^\d{10,15}$/), });
  • src/server.ts:53-79 (registration)
    Registers all tools including those from sessionTools (which contains whatsapp_get_pair_code) into the server's tools Map by iterating over tool categories and setting each tool by its name.
    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`); }
  • Groups and exports the session-related tools including getPairCode (whatsapp_get_pair_code) for registration in the server.
    export const sessionTools = { getSessionStatus, getQRCode, getQRCodeImage, getPairCode, logout };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wsapi-chat/wsapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server