Production-ready WhatsApp Business API with multi-tenant authentication
Base URL: https://whatsapp.nextmavens.cloud
All API requests require your API key in the request header:
apikey: YOUR_NEXTMAVENS_API_KEY
An 'instance' represents one WhatsApp phone number connection. Each company can have multiple instances — one per phone number they want to use.
POST /instance/create
{
"instanceName": "mycompany-sales",
"integration": "WHATSAPP-BAILEYS",
"qrcode": true,
"number": "",
"token": "optional-custom-token"
}
hash.apikey value from the response. This is the per-instance token used for all subsequent calls to this instance. It is different from your global API key.
GET /instance/connect/{instanceName}
Use when instance is disconnected and user needs to re-scan QR.
GET /instance/connectionState/{instanceName}
| Status | Meaning |
|---|---|
open | Connected and ready to send/receive messages |
connecting | QR was scanned, waiting for full connection |
close | Disconnected — user needs to re-scan QR code |
refused | Connection was refused by WhatsApp servers |
GET /instance/fetchInstances
DELETE /instance/delete/{instanceName}
POST /message/sendText/{instanceName}
{
"number": "254712345678",
"text": "Hello from NextMavens API!",
"delay": 1200
}
Parameters:
number: Always include country code, no + or spacesdelay: Delay in ms (RECOMMENDED: 1000-3000 ms)POST /message/sendMedia/{instanceName}
{
"number": "254712345678",
"mediatype": "image",
"mimetype": "image/jpeg",
"caption": "Check this out!",
"media": "https://example.com/image.jpg",
"delay": 2000
}
{
"number": "254712345678",
"mediatype": "document",
"mimetype": "application/pdf",
"caption": "Invoice #1234",
"fileName": "invoice_1234.pdf",
"media": "BASE64_ENCODED_PDF_DATA"
}
{
"number": "254712345678",
"audio": "BASE64_ENCODED_AUDIO",
"encoding": true
}
data:audio/ogg;base64, prefix. Set encoding: true so Evolution API converts it to WhatsApp's PTT format.
POST /message/sendButtons/{instanceName}
{
"number": "254712345678",
"title": "Choose an option",
"description": "Please select below:",
"footer": "NextMavens",
"buttons": [
{ "type": "reply", "displayText": "Yes", "id": "btn_yes" },
{ "type": "reply", "displayText": "No", "id": "btn_no" }
]
}
Configure webhooks to receive real-time events (incoming messages, status updates, QR code changes) on your server.
POST /webhook/set/{instanceName}
{
"enabled": true,
"url": "https://yourapp.com/webhook/whatsapp",
"webhookByEvents": false,
"webhookBase64": false,
"events": [
"MESSAGES_UPSERT",
"MESSAGES_UPDATE",
"CONNECTION_UPDATE",
"QRCODE_UPDATED",
"SEND_MESSAGE"
]
}
| Event | Triggered When |
|---|---|
MESSAGES_UPSERT | A new message is received or sent |
MESSAGES_UPDATE | A message status changes (sent, delivered, read) |
CONNECTION_UPDATE | Instance connects, disconnects, or QR is scanned |
QRCODE_UPDATED | A new QR code is generated (e.g., on session expiry) |
SEND_MESSAGE | A message is sent from the instance |
PRESENCE_UPDATE | A contact's online/typing status changes |
CONTACTS_UPSERT | Contact list is synced or updated |
{
"event": "messages.upsert",
"instance": "mycompany-sales",
"data": {
"key": {
"remoteJid": "254712345678@s.whatsapp.net",
"fromMe": false,
"id": "3EB0A12345ABCDEF"
},
"pushName": "John Doe",
"message": {
"conversation": "Hello! I need help with my order."
},
"messageTimestamp": 1714000000,
"messageType": "conversation"
}
}
POST /chat/whatsappNumbers/{instanceName}
{
"numbers": ["254712345678", "254700112233"]
}
POST /chat/findMessages/{instanceName}
{
"where": {
"key": { "remoteJid": "254712345678@s.whatsapp.net" }
},
"limit": 50
}
POST /chat/markMessageAsRead/{instanceName}
{
"readMessages": [
{ "remoteJid": "254712345678@s.whatsapp.net", "fromMe": false, "id": "MESSAGE_ID" }
]
}
GET /chat/fetchProfilePictureUrl/{instanceName}?number=254712345678
POST /group/create/{instanceName}
{
"subject": "Team Updates",
"description": "Company-wide announcements",
"participants": ["254712345678", "254700112233"]
}
POST /message/sendText/{instanceName}
{
"number": "120363XXXXXXXXXX@g.us",
"text": "Hello team!"
}
Use the group JID, not a phone number.
GET /group/fetchAllGroups/{instanceName}?getParticipants=false
| Code | Error | Resolution |
|---|---|---|
| 400 | Bad Request | Check your request body — missing or invalid field |
| 401 | Unauthorized | Missing apikey header in your request |
| 403 | Forbidden | Your API key is invalid or deactivated — contact support |
| 404 | Instance not found | The instanceName in your URL doesn't exist — check spelling |
| 409 | Instance exists | An instance with this name already exists — use fetchInstances to check |
| 429 | Rate limit exceeded | Slow down your requests — respect the delay parameter |
| 500 | Internal error | Server error — check with NextMavens support; include your instance name |
Here is the complete flow from receiving API credentials to sending your first message:
POST /instance/create with instanceNameGET /instance/connectionState/{instanceName} until status === 'open'hash.apikey) in your databasePOST /webhook/set/{instanceName}/ws) instead of polling for connection status. This is more efficient and gives instant connection updates.
# 1. Create instance
curl -X POST https://whatsapp.nextmavens.cloud/instance/create \
-H 'apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"instanceName": "test-instance",
"integration": "WHATSAPP-BAILEYS",
"qrcode": true
}'
# 2. Save the returned hash.apikey (instance token)
# 3. Wait for user to scan QR, then check status
curl -H 'apikey: YOUR_API_KEY' \
https://whatsapp.nextmavens.cloud/instance/connectionState/test-instance
# 4. Send a message (use instance token as apikey)
curl -X POST https://whatsapp.nextmavens.cloud/message/sendText/test-instance \
-H 'apikey: INSTANCE_TOKEN_FROM_STEP_2' \
-H 'Content-Type: application/json' \
-d '{
"number": "254712345678",
"text": "Hello!",
"delay": 1500
}'
To avoid WhatsApp account bans, follow these critical rules:
See WHATSAPP_BEST_PRACTICES.md in the project repository for complete guidelines.
| ─── INSTANCES ─────────────────────────────────── | ||
|---|---|---|
| POST | /instance/create | Create new instance + QR |
| GET | /instance/connect/{name} | Get QR code (reconnect) |
| GET | /instance/connectionState/{name} | Get connection status |
| GET | /instance/fetchInstances | List all instances |
| DELETE | /instance/delete/{name} | Delete instance |
| PUT | /instance/restart/{name} | Restart instance |
| PUT | /instance/logout/{name} | Log out (removes session) |
| ─── MESSAGES ──────────────────────────────────── | ||
| POST | /message/sendText/{name} | Send text message |
| POST | /message/sendMedia/{name} | Send image/video/document |
| POST | /message/sendWhatsAppAudio/{name} | Send voice note |
| POST | /message/sendButtons/{name} | Send interactive buttons |
| POST | /message/sendList/{name} | Send list message |
| POST | /message/sendLocation/{name} | Send location pin |
| DELETE | /message/delete/{name} | Delete sent message |
| ─── CHAT & CONTACTS ────────────────────────────── | ||
| POST | /chat/whatsappNumbers/{name} | Verify numbers on WhatsApp |
| POST | /chat/findMessages/{name} | Fetch chat history |
| POST | /chat/markMessageAsRead/{name} | Mark messages as read |
| GET | /chat/fetchProfilePictureUrl/{name} | Get profile picture |
| ─── GROUPS ────────────────────────────────────── | ||
| POST | /group/create/{name} | Create a group |
| GET | /group/fetchAllGroups/{name} | List all groups |
| PUT | /group/updateParticipant/{name} | Add/remove participants |
| ─── WEBHOOK ───────────────────────────────────── | ||
| POST | /webhook/set/{name} | Configure webhook |
| GET | /webhook/find/{name} | Get webhook config |
Base URL: https://whatsapp.nextmavens.cloud | Auth Header: apikey: YOUR_KEY
Evolution API ships with a built-in web interface for admin management.
https://whatsapp.nextmavens.cloud/managerAUTHENTICATION_API_KEYThe manager lets you visually: