Complete API reference for WhatsApp Web.js integration
v2.1.0The QR ChatBot API provides a comprehensive WhatsApp Web.js integration with modern REST endpoints. All API routes are prefixed with /api/ and return standardized JSON responses.
http://localhost:7000/api/
All API responses follow this standardized format:
{
"success": boolean,
"data": any,
"message": string,
"timestamp": string,
"statusCode": number
}
All requests should use Content-Type: application/json for POST requests.
The API supports hybrid authentication: session-based for web interface and API key for programmatic access.
For API access, include your API key in the request header:
x-api-key: your_api_key_here
All /api/ endpoints (except /api/status) require API key authentication.
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | Required | Admin username |
| password | string | Required | Admin password |
{
"username": "admin",
"password": "your_password"
}
{
"success": true,
"data": {
"status": "running",
"version": "2.1.0",
"uptime": 3600,
"port": 7000,
"whatsappReady": true,
"timestamp": "2025-09-25T10:30:00.000Z"
},
"message": "Server status retrieved",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
{
"success": true,
"data": {
"state": "CONNECTED",
"info": {
"displayName": "User Name",
"me": {
"user": "6281234567890",
"server": "c.us"
}
}
},
"message": "Client state retrieved",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
{
"success": true,
"data": null,
"message": "WhatsApp client destroyed successfully",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
{
"success": true,
"data": true,
"message": "Logged out successfully",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
{
"success": true,
"data": [
{
"id": {
"user": "6281234567890",
"server": "c.us"
},
"name": "Contact Name",
"pushname": "Push Name",
"isUser": true,
"isGroup": false
}
],
"message": "Contacts retrieved successfully",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
{
"success": true,
"data": [
{
"id": {
"user": "6281234567890",
"server": "c.us"
},
"name": "Chat Name",
"isGroup": false,
"isReadOnly": false,
"unreadCount": 0,
"timestamp": 1726483800
}
],
"message": "Chats retrieved successfully",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number (will be formatted automatically) |
{
"number": "081234567890"
}
{
"success": true,
"data": {
"profilePicUrl": "https://pps.whatsapp.net/v/t61.24694-24/..."
},
"message": "Profile picture URL retrieved",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number (will be formatted automatically) |
{
"number": "081234567890"
}
{
"success": true,
"data": {
"id": {
"user": "6281234567890",
"server": "c.us"
},
"name": "Contact Name",
"pushname": "Push Name",
"isUser": true,
"isGroup": false,
"isBlocked": false
},
"message": "Contact information retrieved",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number |
| limit | integer | Optional | Number of messages to retrieve (1-100, default: 20) |
{
"number": "081234567890",
"limit": 50
}
{
"success": true,
"data": [
{
"id": {
"fromMe": false,
"remote": "6281234567890@c.us",
"id": "ABC123DEF456",
"_serialized": "false_6281234567890@c.us_ABC123DEF456"
},
"ack": 1,
"hasMedia": false,
"body": "Hello! How are you?",
"type": "chat",
"timestamp": 1726483800,
"notifyName": "Contact Name",
"from": "6281234567890@c.us",
"to": "6280987654321@c.us"
}
],
"message": "Chat messages retrieved successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Required | Search query |
| chatId | string | Optional | Specific chat ID to search in |
| limit | integer | Optional | Number of results (1-100, default: 50) |
{
"query": "hello world",
"chatId": "6281234567890@c.us",
"limit": 20
}
{
"success": true,
"data": [
{
"id": {
"fromMe": true,
"remote": "6281234567890@c.us",
"id": "ABC123DEF456",
"_serialized": "true_6281234567890@c.us_ABC123DEF456"
},
"body": "Hello world! How are you today?",
"type": "chat",
"timestamp": 1726483800,
"from": "6280987654321@c.us",
"to": "6281234567890@c.us",
"chat": {
"id": "6281234567890@c.us",
"name": "Contact Name"
}
}
],
"message": "Messages found successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to archive |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat archived successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to unarchive |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat unarchived successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to mute |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat muted successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to unmute |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat unmuted successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to pin |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat pinned successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to unpin |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat unpinned successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to clear messages |
{
"number": "081234567890"
}
{
"success": true,
"data": true,
"message": "Chat messages cleared successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number to mark as read |
{
"number": "081234567890"
}
{
"success": true,
"data": {
"chatId": "6281234567890@c.us",
"previousUnreadCount": 5,
"currentUnreadCount": 0,
"isRead": true,
"timestamp": "2025-10-04T10:30:00.000Z"
},
"message": "Chat marked as read successfully",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 200
}
chatId - Formatted phone number with WhatsApp domainpreviousUnreadCount - Number of unread messages before marking as readcurrentUnreadCount - Number of unread messages after marking as read (should be 0)isRead - Boolean indicating if chat is now fully readtimestamp - When the read status was updatedAll chat management endpoints require:
x-api-key header// Missing API Key (401)
{
"success": false,
"data": null,
"message": "Authentication required. Please provide x-api-key header.",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 401
}
// Invalid API Key (403)
{
"success": false,
"data": null,
"message": "Invalid API key provided.",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 403
}
// Validation Error (422)
{
"success": false,
"data": [
{
"field": "number",
"message": "Phone number is required"
}
],
"message": "Validation failed",
"timestamp": "2025-10-04T10:30:00.000Z",
"statusCode": 422
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number (will be formatted automatically) |
| message | string | Required | Message content |
{
"number": "081234567890",
"message": "Hello from QR ChatBot!"
}
{
"success": true,
"data": {
"id": {
"fromMe": true,
"remote": "6281234567890@c.us",
"id": "ABC123DEF456",
"_serialized": "true_6281234567890@c.us_ABC123DEF456"
},
"ack": 1,
"hasMedia": false,
"body": "Hello from QR ChatBot!",
"type": "chat",
"timestamp": 1726483800
},
"message": "Message sent successfully",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number |
| message | string | Required | Message content |
| quotedMessageId | string | Required | ID of the message to quote |
{
"number": "081234567890",
"message": "This is my reply to your message",
"quotedMessageId": "false_6281234567890@c.us_ABC123DEF456"
}
{
"success": true,
"data": {
"id": {
"fromMe": true,
"remote": "6281234567890@c.us",
"id": "XYZ789ABC123",
"_serialized": "true_6281234567890@c.us_XYZ789ABC123"
},
"ack": 1,
"hasMedia": false,
"body": "This is my reply to your message",
"type": "chat",
"timestamp": 1726483800,
"hasQuotedMsg": true,
"quotedMsg": {
"id": "false_6281234567890@c.us_ABC123DEF456",
"body": "Original quoted message content"
}
},
"message": "Quoted message sent successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| number | string | Required | Phone number |
| base64 | string | Required | Base64 encoded media data |
| mimetype | string | Required | MIME type (e.g., image/jpeg, video/mp4) |
| filename | string | Optional | Filename for the media |
| caption | string | Optional | Caption for the media |
{
"number": "081234567890",
"base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
"mimetype": "image/png",
"filename": "image.png",
"caption": "Hello, this is an image!"
}
{
"success": true,
"data": {
"id": {
"fromMe": true,
"remote": "6281234567890@c.us",
"id": "MEDIA123ABC456",
"_serialized": "true_6281234567890@c.us_MEDIA123ABC456"
},
"ack": 1,
"hasMedia": true,
"body": "Hello, this is an image!",
"type": "image",
"timestamp": 1726483800,
"mediaKey": "media_key_here",
"size": 1024
},
"message": "Media message sent successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional* | Group ID (either id or name required) |
| name | string | Optional* | Group name (either id or name required) |
| message | string | Required | Message content |
Either id or name must be provided. If name is used, the system will search for the group by name.
{
"id": "120363042833171234@g.us",
"message": "Hello everyone in the group!"
}
{
"name": "My WhatsApp Group",
"message": "Hello everyone in the group!"
}
{
"success": true,
"data": {
"id": {
"fromMe": true,
"remote": "120363042833171234@g.us",
"id": "GROUP123ABC456",
"_serialized": "true_120363042833171234@g.us_GROUP123ABC456"
},
"ack": 1,
"hasMedia": false,
"body": "Hello everyone in the group!",
"type": "chat",
"timestamp": 1726483800,
"from": "6280987654321@c.us",
"to": "120363042833171234@g.us"
},
"message": "Group message sent successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional* | Group ID (either id or name required) |
| name | string | Optional* | Group name (either id or name required) |
| base64 | string | Required | Base64 encoded media data |
| mimetype | string | Required | MIME type (e.g., image/jpeg, video/mp4) |
| filename | string | Optional | Filename for the media |
| caption | string | Optional | Caption for the media |
{
"id": "120363042833171234@g.us",
"base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
"mimetype": "image/png",
"filename": "group-image.png",
"caption": "Sharing this image with the group!"
}
{
"name": "My WhatsApp Group",
"base64": "/9j/4AAQSkZJRgABAQEAYABgAAD...",
"mimetype": "image/jpeg",
"filename": "photo.jpg",
"caption": "Check out this photo!"
}
{
"success": true,
"data": {
"id": {
"fromMe": true,
"remote": "120363042833171234@g.us",
"id": "GROUPMEDIA123ABC456",
"_serialized": "true_120363042833171234@g.us_GROUPMEDIA123ABC456"
},
"ack": 1,
"hasMedia": true,
"body": "Sharing this image with the group!",
"type": "image",
"timestamp": 1726483800,
"from": "6280987654321@c.us",
"to": "120363042833171234@g.us",
"mediaKey": "group_media_key_here",
"size": 2048
},
"message": "Group media message sent successfully",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 200
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| filename | string | Required | Filename in URL path |
GET /api/media/image_2025-09-25_10-30-00.jpg
Content-Type: image/jpeg Content-Disposition: inline; filename="image_2025-09-25_10-30-00.jpg" [Binary file data]
{
"success": false,
"data": null,
"message": "Media file not found",
"timestamp": "2025-09-25T10:30:00.000Z",
"statusCode": 404
}
Downloaded media files are accessible via two URLs:
/media/filename.ext - No authentication required/api/media/filename.ext - Requires API key authenticationThe response includes both URLs for convenience. Use the public URL for direct browser access or embedding.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | string | Required | WhatsApp chat ID (e.g., "6281234567890@c.us" for individual, "1234567890-1234567890@g.us" for group) |
| message_id | string | Required | Message ID that contains media. Can be full format (e.g., "false_6281234567890@c.us_3EB0123456789ABCDEF") or just the ID part (e.g., "3EB0123456789ABCDEF") |
curl -X POST http://localhost:7000/api/download-file \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"chat_id": "6281234567890@c.us",
"message_id": "3EB0123456789ABCDEF"
}'
{
"success": true,
"data": {
"filename": "3EB0123456789ABCDEF.jpg",
"original_message_id": "false_6281234567890@c.us_3EB0123456789ABCDEF",
"mimetype": "image/jpeg",
"filesize": 245760,
"download_url": "http://localhost:7000/media/3EB0123456789ABCDEF.jpg",
"api_download_url": "http://localhost:7000/api/media/3EB0123456789ABCDEF.jpg",
"saved_path": "./downloaded-media/3EB0123456789ABCDEF.jpg",
"chat_id": "6281234567890@c.us",
"message_id": "false_6281234567890@c.us_3EB0123456789ABCDEF"
},
"message": "File downloaded successfully",
"timestamp": "2025-09-28T10:30:00.000Z",
"statusCode": 200
}
{
"success": false,
"data": null,
"message": "Chat not found",
"timestamp": "2025-09-28T10:30:00.000Z",
"statusCode": 404
}
{
"success": false,
"data": null,
"message": "Message not found",
"timestamp": "2025-09-28T10:30:00.000Z",
"statusCode": 404
}
{
"success": false,
"data": null,
"message": "Message does not contain media",
"timestamp": "2025-09-28T10:30:00.000Z",
"statusCode": 400
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| filename | string | Required | Filename in URL path (e.g., "3EB0123456789ABCDEF.pdf") |
GET /media/false_6281320223846@c.us_3EB091C14A7158427C5BE5.pdf GET /media/3EB091C14A7158427C5BE5.pdf GET /media/image_2025-09-28_10-30-00.jpg
Content-Type: application/pdf Content-Disposition: inline; filename="document.pdf" [Binary file data]
Cannot GET /media/nonexistent-file.pdf
For backward compatibility, old API endpoints are still supported but deprecated. They will redirect to new endpoints.
Legacy routes are deprecated and may be removed in future versions. Please update your applications to use the new /api/ endpoints.
| Legacy Route | New Route | Status |
|---|---|---|
| /logout | /api/logout | Deprecated |
| /state | /api/state | Deprecated |
| /contact | /api/contacts | Deprecated |
| /getchatactive | /api/chats | Deprecated |
| /send-message | /api/send-message | Deprecated |
| /send-media64 | /api/send-media | Deprecated |
Here are some practical examples of using the API with cURL commands:
curl -X POST http://localhost:7000/api/send-message \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"number": "081234567890",
"message": "Hello from API!"
}'
curl -X POST http://localhost:7000/api/send-media \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"number": "081234567890",
"base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
"mimetype": "image/png",
"filename": "test.png",
"caption": "Test image via API"
}'
curl -X GET http://localhost:7000/api/contacts \ -H "x-api-key: your_api_key_here"
curl -X POST http://localhost:7000/api/chat-messages \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"number": "081234567890",
"limit": 20
}'
curl -X POST http://localhost:7000/api/send-group-message \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"name": "My WhatsApp Group",
"message": "Hello group members!"
}'
x-api-key header for authenticationContent-Type: application/json for POST requestsThe API uses conventional HTTP response codes to indicate the success or failure of an API request.
| Status Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 400 | Bad Request | The request was invalid |
| 401 | Unauthorized | Authentication required |
| 404 | Not Found | Resource not found |
| 500 | Internal Server Error | Server error occurred |
{
"success": false,
"data": null,
"message": "Error description",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 400
}
When input validation fails, the API returns a 422 status code with detailed error information:
{
"success": false,
"data": [
{
"field": "number",
"message": "Phone number is required"
},
{
"field": "message",
"message": "Message content is required"
}
],
"message": "Validation failed",
"timestamp": "2025-09-16T10:30:00.000Z",
"statusCode": 422
}
For support or questions about this API, please check:
This documentation is for the QR ChatBot API v2.1.0. Make sure your application is running on the correct port and that WhatsApp Web is properly authenticated.