WhatsApp Automation API
Comprehensive documentation for the WhatsApp Automation API
Authentication
The API uses session-based authentication. When a user logs in, a session is created and stored on the server. The session ID is automatically managed via cookies.
Note: The session cookie is automatically managed by the browser and included with each request.
Register a New User
POST
/api/auth/register
Request Body:
{
"name": "John Doe",
"phone": "+1234567890",
"email": "[email protected]",
"username": "johndoe",
"password": "securePassword123",
"gst": "GST12345"
}
Response:
HTTP/1.1 200 OK
Set-Cookie: connect.sid=s%3A...; Path=/; HttpOnly
Content-Type: application/json
{
"message": "User registered successfully"
}
Login
POST
/api/auth/login
Request Body:
{
"username": "johndoe",
"password": "securePassword123"
}
Response:
HTTP/1.1 200 OK
Set-Cookie: connect.sid=s%3A...; Path=/; HttpOnly
Content-Type: application/json
{
"message": "Login successful",
"user": {
"name": "John Doe",
"username": "johndoe",
"email": "[email protected]"
}
}
Logout
POST
/api/auth/logout
Response:
HTTP/1.1 200 OK
Set-Cookie: connect.sid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json
{
"message": "Logged out successfully"
}
User Management
Get User Profile
GET
/api/users/me
Headers:
Cookie: connect.sid=<session_id>
Note: The session cookie is automatically managed by the browser and included with each request.
Response:
{
"id": "user_id",
"name": "John Doe",
"email": "[email protected]",
"username": "johndoe",
"phone": "+1234567890",
"gst": "GST12345"
}
WhatsApp Client
Generate QR Code
GET
/api/whatsapp/createqr
Headers:
Cookie: connect.sid=<session_id>
Response:
{
"qrCodeUrl": "https://api.qrserver.com/v1/create-qr-code/?data=..."
}
Get WhatsApp Status
GET
/api/whatsapp/status
Headers:
Cookie: connect.sid=<session_id>
Response:
{
"status": "authenticated",
"phoneNumber": "+1234567890",
"name": "John's WhatsApp"
}
Get WhatsApp Groups
GET
/api/whatsapp/groups
Headers:
Cookie: connect.sid=<session_id>
Response:
[
{
"id": "group_id_1",
"name": "Family Group",
"participants": ["+1234567890", "+1987654321"]
},
{
"id": "group_id_2",
"name": "Work Team",
"participants": ["+1234567890", "+15556667777"]
}
]
Message Management
Send Message
POST
/api/messages/send
Headers:
Cookie: connect.sid=<session_id>
Content-Type: multipart/form-data
Form Data:
phoneId(required) - Recipient's phone number with country codemessage(required) - Message textmediaFile(optional) - Media file to sendscheduledTime(optional) - ISO 8601 format for scheduled messages
Response:
{
"success": true,
"messageId": "msg_12345",
"scheduledFor": "2025-05-16T10:00:00.000Z"
}
Schedule Message
POST
/api/messages/schedule
Headers:
Cookie: connect.sid=<session_id>
Content-Type: application/json
Request Body:
{
"phoneId": "+1234567890",
"message": "Hello, this is a scheduled message!",
"scheduledTime": "2025-05-16T10:00:00.000Z",
"aiModifications": {
"useSynonyms": true,
"addEmojis": true,
"shuffleSentences": false
}
}
Response:
{
"success": true,
"messageId": "sched_12345",
"scheduledFor": "2025-05-16T10:00:00.000Z"
}
Get Message Queue
GET
/api/messages/queue?page=1&limit=10
Headers:
Cookie: connect.sid=<session_id>
Query Parameters:
page(optional) - Page number (default: 1)limit(optional) - Items per page (default: 10)
Response:
{
"messages": [
{
"id": "msg_12345",
"to": "+1234567890",
"message": "Hello!",
"status": "sent",
"scheduledFor": "2025-05-16T10:00:00.000Z",
"sentAt": "2025-05-16T10:00:05.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"pages": 1
}
}