WhatsApp API Documentation & Integration Guide
Build and integrate WhatsApp automation with the NullChat WhatsApp API. This developer documentation explains how to authenticate API requests, create and manage WhatsApp sessions, connect numbers with QR codes, send messages and media, receive webhook events, and integrate WhatsApp into your applications.
Whether you are building a website, automation system, customer support platform, or custom backend, this guide walks you through the main WhatsApp API integration workflow from your first request to production deployment.
DEVELOPER DOCUMENTATION
From Zero to Your First WhatsApp API Request
curl -X POST "http://localhost:3000/api/v1/sessions" \ -H "Authorization: Bearer YOUR_SANDBOX_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"Development","mode":"sandbox"}'
simulated: true.
They do not send messages to WhatsApp.
WhatsApp API Authentication for Developers
Keep API keys secure and store them in server-side environment variables. Never place API keys inside HTML, browser-side JavaScript, public repositories, or URLs.Before making API requests, make sure you understand your account and available WhatsApp API plans.
If a key becomes exposed, revoke it and generate a replacement from your NullChat dashboard.
curl "http://localhost:3000/api/v1/me" -H "Authorization: Bearer YOUR_API_KEY"
Manage WhatsApp Sessions and QR Connections
When a QR code becomes available, scan it using WhatsApp under Linked devices.
| Method | Endpoint | Behavior |
|---|---|---|
| GET | /sessions | List sessions for the current API environment. |
| POST | /sessions | Create a new session. |
| GET | /sessions/id | Read session status and QR information. |
| POST | /sessions/id/connect | Start a live QR connection or mark sandbox ready. |
| POST | /sessions/id/disconnect | Stop the connection while retaining credentials. |
| DELETE | /sessions/id | Log out and remove the session. |
Send WhatsApp Messages and Media
const response = await fetch("http://localhost:3000/api/v1/messages", { method: "POST", headers: { "Authorization": "Bearer " + process.env.WA_API_KEY, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ session_id: "YOUR_SESSION_ID", to: "923001234567", body: "Hello from my application!" }) }); const data = await response.json(); if (!response.ok) throw new Error(data.error); console.log(data);
{ "session_id": "YOUR_SESSION_ID", "to": "923001234567", "body": "Your invoice is attached.", "media": { "mimetype": "application/pdf", "filename": "invoice.pdf", "data": "BASE64_ENCODED_FILE" } }
Receive and Verify WhatsApp Webhook Events
Add a WhatsApp Chat Widget to Your Website
<script src="http://localhost:3000/embed.js" data-widget="YOUR_WIDGET_ID" defer></script>
WhatsApp API Plans and NayaPay Payments
WhatsApp API Limits and Error Handling
| Status | Meaning |
|---|---|
| 400 | Invalid request fields. Check the error property. |
| 401 | Missing, invalid, revoked key, or expired sign-in. |
| 402 | A paid plan is required or access has expired. |
| 403 | Access denied, domain restriction, or session limit. |
| 404 | Resource not found in the current account or environment. |
| 409 | Conflicting request, disconnected session, or duplicate reference. |
| 429 | Message quota or request rate limit reached. |
| 502 | Provider result is uncertain. Check message history before retrying. |
| 503 | Required server integration is not configured. |