WhatsApp API Documentation
Complete REST API for WhatsApp Web automation. Send messages, media, manage contacts, and receive real-time webhooks. Test endpoints directly from this page!
All API requests require authentication using your API key in the header.
| Header | Description | Required |
|---|---|---|
X-API-Key |
Your unique API key | Required |
X-Session-ID |
Session ID (1, 2, SESSION_1, or full format) | Optional |
Content-Type |
application/json (for JSON requests) | Required for POST |
Content-Type: application/json without quotes around the value.Status & Connection
Returns the current connection status of the WhatsApp session.
curl -X GET "http://localhost:3000/api/status" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
{
"success": true,
"sessionId": "admin-key-session-1",
"status": "ready",
"info": {
"pushname": "John Doe",
"phone": "919876543210",
"platform": "android"
}
}
Messages
Send a text message to a phone number or group.
| Parameter | Type | Description |
|---|---|---|
to | string | Phone number (e.g., 919876543210) Required |
message | string | Message text Required |
curl -X POST "http://localhost:3000/api/message/send" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"to": "919876543210", "message": "Hello!"}'
{
"success": true,
"messageId": "true_919876543210@c.us_XXXXX",
"to": "919876543210@c.us",
"toNumber": "919876543210",
"timestamp": 1704067200
}
Send a message to multiple phone numbers at once.
| Parameter | Type | Description |
|---|---|---|
recipients | array | Array of phone numbers Required |
message | string | Message text Required |
import requests
response = requests.post(
"http://localhost:3000/api/message/send-bulk",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1", "Content-Type": "application/json"},
json={"recipients": ["919876543210", "919876543211"], "message": "Hello!"}
)
print(response.json())
Send a location to a phone number.
curl -X POST "http://localhost:3000/api/message/send-location" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"to": "919876543210", "latitude": 40.7128, "longitude": -74.0060}'
Send a contact card to a phone number.
curl -X POST "http://localhost:3000/api/message/send-contact" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"to": "919876543210", "contactId": "919876543211"}'
Chats & Contacts
Retrieve all chats from the connected WhatsApp account.
curl -X GET "http://localhost:3000/api/message/chats" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Media
Fetch media (images, videos, documents) from received WhatsApp messages. The messageId is provided in the webhook payload when you receive a media message.
| messageId | Required. The message ID from the webhook (e.g., true_919876543210@c.us_3EB0ABC123) |
| X-API-Key | Required. Your API key (header or ?apiKey= query param) |
| X-Session-ID | Optional. Session number if you have multiple sessions (e.g., 1, 2) |
X-Session-ID to target a specific session.# Download image using message ID from webhook
curl -H "X-API-Key: your-api-key" \
"http://localhost:3000/m/true_919876543210%40c.us_3EB0ABC123" \
--output image.jpg
# With specific session (for multi-session users)
curl -H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
"http://localhost:3000/m/true_919876543210%40c.us_3EB0ABC123" \
--output image.jpg
# Using query parameter instead of header
curl "http://localhost:3000/m/true_919876543210%40c.us_3EB0ABC123?apiKey=your-api-key" \
--output image.jpg
Content-Type header. On error, returns JSON with error and message fields.# Download and save
import requests
r = requests.get(media_url, headers={"X-API-Key": key})
with open("image.jpg", "wb") as f:
f.write(r.content)
# Or get as base64
import base64
b64 = base64.b64encode(r.content).decode()
const fs = require('fs');
// Download and save
const response = await fetch(mediaUrl, {
headers: { 'X-API-Key': key }
});
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('image.jpg', buffer);
// Get as base64
const base64 = buffer.toString('base64');
// Display image directly
const img = document.createElement('img');
img.src = mediaUrl + '?apiKey=' + key;
document.body.appendChild(img);
// Or download as file
const a = document.createElement('a');
a.href = mediaUrl + '?apiKey=' + key;
a.download = 'image.jpg';
a.click();
Upload and send a media file (image, video, document).
multipart/form-data with a file field named media.curl -X POST "http://localhost:3000/api/media/send" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "media=@/path/to/file.jpg" \
-F "caption=Optional caption"
Send media by providing a URL.
curl -X POST "http://localhost:3000/api/media/send-url" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"to": "919876543210", "url": "https://example.com/image.jpg", "caption": "Check this out!"}'
Send media using base64 encoded data.
| Parameter | Type | Description |
|---|---|---|
to | string | Phone number Required |
base64 | string | Base64 encoded media data Required |
mimetype | string | MIME type (e.g., image/jpeg) Required |
filename | string | Filename Optional |
caption | string | Caption Optional |
curl -X POST "http://localhost:3000/api/media/send-base64" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"to": "919876543210", "base64": "BASE64_DATA", "mimetype": "image/jpeg", "filename": "image.jpg", "caption": "My image"}'
Upload and send an image file.
curl -X POST "http://localhost:3000/api/media/send-image" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "image=@/path/to/image.jpg" \
-F "caption=My image"
Upload and send a document file (PDF, DOC, etc.).
curl -X POST "http://localhost:3000/api/media/send-document" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "document=@/path/to/file.pdf"
Send an audio file or voice message.
ptt: true to send as a voice message. Audio will be automatically converted to OGG/Opus format.curl -X POST "http://localhost:3000/api/media/send-audio" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "audio=@/path/to/audio.mp3" \
-F "ptt=true"
Upload and send a video file.
curl -X POST "http://localhost:3000/api/media/send-video" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "video=@/path/to/video.mp4" \
-F "caption=My video"
Send a sticker (images will be converted to WebP format).
curl -X POST "http://localhost:3000/api/media/send-sticker" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-F "to=919876543210" \
-F "sticker=@/path/to/image.png"
Retrieve messages from a specific chat by chat ID.
curl -X GET "http://localhost:3000/api/message/chats/919876543210@c.us/messages?limit=50" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Get messages from a conversation using phone number.
curl -X GET "http://localhost:3000/api/message/by-number/919876543210?limit=50" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Retrieve all contacts from the WhatsApp account.
curl -X GET "http://localhost:3000/api/message/contacts" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Check if a phone number is registered on WhatsApp.
import requests
number = "919876543210"
response = requests.get(
f"http://localhost:3000/api/message/check/{number}",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
result = response.json()
print(f"Registered: {result['isRegistered']}")
Get the profile picture URL for a phone number.
import requests
number = "919876543210"
response = requests.get(
f"http://localhost:3000/api/message/profile-pic/{number}",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
result = response.json()
print(f"Profile Pic: {result.get('profilePicUrl', 'Not available')}")
Calls
Reject an incoming WhatsApp call.
| Parameter | Type | Description |
|---|---|---|
callId | string | Call ID from incoming_call event Required |
import requests
response = requests.post(
"http://localhost:3000/api/calls/reject",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1", "Content-Type": "application/json"},
json={"callId": "call-id-from-event"}
)
print(response.json())
Retrieve all call logs from all chats.
import requests
response = requests.get(
"http://localhost:3000/api/calls/logs?limit=100",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
print(response.json())
Get call logs for a specific phone number.
import requests
number = "919876543210"
response = requests.get(
f"http://localhost:3000/api/calls/logs/{number}?limit=50",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
print(response.json())
Webhooks
Get the current webhook URL configuration.
curl -X GET "http://localhost:3000/api/status/webhook" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Configure a webhook URL to receive real-time message notifications.
curl -X POST "http://localhost:3000/api/status/webhook" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1" \
-d '{"url": "https://your-server.com/webhook"}'
When a message is received, your webhook will receive this payload:
{
"event": "message",
"sessionId": "admin-key-session-1",
"timestamp": 1704067200000,
"data": {
"id": "true_919876543210@c.us_XXXXX",
"from": "919876543210@c.us",
"fromNumber": "919876543210",
"to": "917654321098@c.us",
"toNumber": "917654321098",
"body": "Hello!",
"type": "chat",
"timestamp": 1704067200,
"contactName": "John Doe",
"isGroup": false,
"hasMedia": false
}
}
hasMedia is true, the webhook includes a mediaUrl field with a direct link to download the media. Use GET /m/:messageId with your API key to fetch the image. See Download Media endpoint.{
"event": "message",
"data": {
"id": "true_919876543210@c.us_3EB0ABC123",
"hasMedia": true,
"mediaUrl": "http://localhost:3000/m/true_919876543210%40c.us_3EB0ABC123",
"mediaType": "image",
"media": {
"messageId": "true_919876543210@c.us_3EB0ABC123",
"url": "http://localhost:3000/m/true_919876543210%40c.us_3EB0ABC123",
"mimetype": "image/jpeg"
}
}
}
Disable the webhook by deleting it.
curl -X DELETE "http://localhost:3000/api/status/webhook" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Send a test payload to your configured webhook URL.
curl -X POST "http://localhost:3000/api/status/webhook/test" \
-H "X-API-Key: your-api-key" \
-H "X-Session-ID: 1"
Logout from the current WhatsApp session.
import requests
response = requests.post(
"http://localhost:3000/api/status/logout",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
print(response.json())
Restart the WhatsApp client connection.
import requests
response = requests.post(
"http://localhost:3000/api/status/restart",
headers={"X-API-Key": "your-api-key", "X-Session-ID": "1"}
)
print(response.json())