A complete guide to sending WhatsApp messages programmatically using Node.js and MazeAPI. No complex setup — just a REST API call.
No dependencies to install, no Meta Business Account needed. Just Node.js and an HTTP client.
Create a free MazeAPI account, add a WhatsApp instance from the dashboard, and scan the QR code with your phone to connect your WhatsApp number.
Navigate to API Keys in your dashboard and create a new key. Copy the wa_live_… token — it's shown only once. Store it in an environment variable.
Make a single POST request from your Node.js code. The examples below show how with native fetch, axios, and how to receive webhooks with Express.
Copy, paste, and replace the placeholders with your credentials.
Using fetch (Node 18+)
const API_KEY = 'wa_live_your_key_here'; const INSTANCE_ID = 'your_instance_id'; async function sendWhatsApp(number, message) { const res = await fetch( `https://www.mazeapi.com/api/v1/instances/${INSTANCE_ID}/messages/text`, { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ number, text: { body: message }, }), } ); const data = await res.json(); console.log('Message sent:', data.messageId); return data; } sendWhatsApp('972501234567', 'Hello from Node.js!');
Using axios
const axios = require('axios'); const client = axios.create({ baseURL: 'https://www.mazeapi.com/api/v1', headers: { Authorization: `Bearer ${process.env.MAZEAPI_KEY}`, }, }); // Send a text message await client.post( `/instances/${INSTANCE_ID}/messages/text`, { number: '972501234567', text: { body: 'Hello from axios!' }, } );
Receiving webhooks with Express
const express = require('express'); const app = express(); app.use(express.json()); app.post('/webhook', (req, res) => { const { event, data } = req.body; if (event === 'message.received') { console.log('New message from:', data.from); console.log('Text:', data.body); } res.sendStatus(200); }); app.listen(3000);
No SDKs to install, no OAuth dance — just standard HTTP that works with every Node.js runtime.
Native fetch (Node 18+), axios, got, node-fetch — all work out of the box. No custom SDK required.
Receive inbound messages as POST events to your Express endpoint. Automatic retries with exponential backoff if your server is down.
Connect several WhatsApp numbers under one API key. Perfect for multi-tenant applications or SaaS products.
Send 100 or 100,000 messages for the same monthly price. Predictable costs that scale with your business, not your message volume.
Get your API key in minutes. No Meta approval, no setup fees.
Get Started →