WhaAPI Overview
WhaAPI is a crash-proof WhatsApp REST API gateway built on Fastify & Baileys. Connect WhatsApp or WhatsApp Business numbers via QR code or 8-digit pairing code and automate messaging without Meta per-conversation markups.
Live spec exposing 83 REST endpoints and 220 schema parameters.
4-Step Quickstart
Go from zero to live WhatsApp automation in four API calls.
Register Customer Account & Get API Key
Create Your WhatsApp Instance
Link Device via QR Code or 8-Digit Pairing Code
Send Your First Message
Authentication & Instance Isolation
Every API request validates your private API key or session token, checks active subscription status, and strictly isolates WhatsApp instances to your account.
Supported Credential Headers
# Recommended for server backends & webhooks
x-api-key: wha_live_your_api_key
# Alternate header alias
apikey: wha_live_your_api_key
# Dashboard session OR Bearer API Key
Authorization: Bearer <jwt_token_or_wha_live_key>
Quota & Ownership Protection
Active Number Quota: Each plan includes a connected-number allowance (`allowedInstances`). Exceeding your allowance returns `403 PlanQuotaExceeded` until upgraded.
Strict Instance Isolation: Requests are validated against account ownership on every route — unauthorized access returns `403 Forbidden`.
Connecting WhatsApp (QR & 8-Digit Pairing)
Supports both standard WhatsApp Messenger and WhatsApp Business via official Multi-Device companion sockets.
Method 1: Base64 QR Code
Call `GET /instance/connect/:instance` to initialize the socket and retrieve a PNG Base64 Data URL (`qrCode`). Also broadcasts real-time `qrcode.updated` webhook events.
Method 2: 8-Digit Phone Code
Ideal when users are on their phone without a second camera. Call `GET /instance/pairing-code/:instance?phoneNumber=919876543210` and enter the 8-digit code under WhatsApp → Linked Devices → Link with phone number.
BanSafe Anti-Ban & 14-Day SIM Warmup
Every instance includes an isolated `SafeQueue`, `WarmupManager`, and `HealthTracker` persisted in the database so daily quotas survive server restarts.
Sends `composing` presence for `1000–3500ms` proportional to text length (`~40ms/char`) before dispatch.
Waits randomized `minDelayMs` (`2000ms`) to `maxDelayMs` (`5000ms`) between queued messages.
Tracks delivery ACKs vs failures and disconnects (`-5` per unexpected disconnect; penalizes if failure rate `> 5%`).
Webhooks & HMAC Signature Verification
Receive real-time POST JSON events on incoming messages, delivery receipts, group changes, QR updates, and incoming calls.
Supported Webhook Events
Every webhook dispatch includes 3x automatic exponential backoff retries (500ms, 1500ms) on 429/5xx/network errors, persistent delivery logs (GET /webhook/logs/:instance), and optional event allowlist filtering via webhookEvents.
CRM-Ready Normalized messages.upsert Payload & @lid Resolution
WhatsApp v7 sends Linked Device IDs (@lid) for many contacts. WhaAPI automatically resolves the real E.164 phone number (senderPhone, chatPhone) via remoteJidAlt / Signal LID mapping and attaches a clean data.normalized array alongside raw data.messages. To decrypt inbound media attachments, pass the raw message object to POST /message/download-media/:instance to receive a base64 & dataUri payload.
{
"event": "messages.upsert",
"instance": "Sales",
"data": {
"type": "notify",
"normalized": [
{
"messageId": "3EB09A...",
"chatJid": "919876543210@s.whatsapp.net",
"chatPhone": "919876543210",
"senderPhone": "919876543210",
"fromMe": false,
"pushName": "Aarav",
"messageType": "image",
"text": "Invoice attached",
"hasMedia": true,
"mimetype": "image/jpeg"
}
],
"messages": [ ... ]
}
}
Verify `X-WhaAPI-Signature` (Node.js HMAC-SHA256)
import crypto from 'node:crypto';
export function verifyWhaApiWebhook(rawBody, signatureHeader, webhookSecret) {
const expected = crypto
.createHmac('sha256', webhookSecret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signatureHeader || ''),
Buffer.from(expected)
);
}
Smart Call Auto-Reject & Join Links
Prevent missed customer calls on automated lines while guiding callers immediately via text or scheduled WhatsApp call links.
1. Auto-Reject + Instant Reply: Configure `autoReject: true` and `autoRejectMessage` via `POST /call/settings/:instance`. Incoming `offer` events trigger instant call decline + immediate text reply (persisted in SQLite across restarts).
2. Official Voice/Video Join Links: Call `POST /call/create-link/:instance` with `{"type": "audio"}` or `{"type": "video"}` to mint `https://call.whatsapp.com/...` links.
Errors, Status Codes & Rate Limits
Predictable JSON error envelopes across all endpoints.
{
"statusCode": 403,
"error": "PlanQuotaExceeded",
"message": "Instance limit reached (1/1 numbers used). Please upgrade your subscription."
}
400Invalid schema, invalid `instanceName`, or SSRF-blocked private/local URL (`UnsafeUrlBlocked`).401Missing or expired API key / JWT token (`Unauthorized`).402Active subscription plan expired (`SubscriptionExpired`).403`AccountSuspended`, `PlanQuotaExceeded`, or cross-tenant IDOR attempt (`Forbidden`).404`InstanceNotFound` — call `POST /instance/create` before connecting or sending.409`InstanceNameTaken` — requested instance name belongs to another tenant.429Rate limit exceeded (`10 req/min` on `/auth/login` & `/auth/register`, `300 req/min` global).
Path Parameters
Query String Parameters
Request Body (application/json)