一个使用 Express.js 和 Baileys 库构建的强大的 WhatsApp API 后端。支持多会话管理、实时 WebSocket 事件、群组管理等功能。
一个使用 Express.js 和 Baileys 库构建的强大的 WhatsApp API 后端。支持多会话管理、实时 WebSocket 事件、群组管理等功能。
A powerful WhatsApp API backend built with Express.js and Baileys library. Supports multi-session management, real-time WebSocket events, group management, and media handling.
SumoPod — Container & Application Management
SumoPod offers seamless container and application purchasing solutions for businesses of all sizes.Container Marketplace — Explore and purchase from an extensive container library, all verified and ready for instant deployment.
One-Click Deployment — Deploy containers to your infrastructure with one click, eliminating complex configuration processes.
Automatic Updates — Keep your containers and applications up to date with automatic version updates and security patches.
✨ Chatery WhatsApp API is available on SumoPod — Deploy with one click, without complex configuration. Includes auto-updates and monitoring. → Get it nowFor complete and detailed documentation, please visit:
| Documentation | Link |
|---|---|
| Primary Docs | https://docs.chatery.app |
| Mirror Docs | https://chatery-whatsapp-documentation.appwrite.network |
The documentation includes complete API reference, examples, troubleshooting guides, and more.
# Clone the repository
git clone https://github.com/farinchan/chatery_whatsapp.git
cd chatery_whatsapp
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Start the server
npm start
# Or development mode with auto-reload
npm run dev# Clone the repository
git clone https://github.com/farinchan/chatery_whatsapp.git
cd chatery_whatsapp
# Create environment file
cp .env.example .env
# Build and run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose down| Command | Description |
|---|---|
docker-compose up -d |
Start container in background |
docker-compose down |
Stop and remove container |
docker-compose logs -f |
View live logs |
docker-compose restart |
Restart container |
docker-compose build --no-cache |
Rebuild image |
The following data is persisted across container restarts:
| Volume | Path | Description |
|---|---|---|
chatery_sessions |
/app/sessions |
WhatsApp session data |
chatery_media |
/app/public/media |
Received media files |
chatery_store |
/app/store |
Message history store |
Create a .env file in the root directory:
PORT=3000
CORS_ORIGIN=*
# Dashboard Authentication
DASHBOARD_USERNAME=admin
DASHBOARD_PASSWORD=securepassword123
# API Key Authentication (optional - leave empty or 'your_api_key_here' to disable)
API_KEY=your_secret_api_key_hereNote: Personal chat IDs use
@c.usformat (e.g.,[email protected]). Group IDs use@g.usformat. Phone numbers are automatically normalized (0 → 62).
All WhatsApp API endpoints are protected with API key authentication. Include the X-Api-Key header in your requests.
Set a strong API key in your .env file:
API_KEY=your_super_secret_key_12345Include the header in all API requests:
curl -X GET http://localhost:3000/api/whatsapp/sessions \
-H "X-Api-Key: your_super_secret_key_12345"To disable API key authentication, leave API_KEY empty or set it to your_api_key_here in .env:
API_KEY=
# or
API_KEY=your_api_key_here| Status | Message | Description |
|---|---|---|
| 401 | Missing X-Api-Key header | API key not provided in request |
| 403 | Invalid API key | API key doesn't match |
When logging into the dashboard, you'll be prompted to enter your API key (optional). This allows the dashboard to make authenticated API calls.
Start the server
npm startCreate a session
curl -X POST http://localhost:3000/api/whatsapp/sessions/mysession/connect \
-H "X-Api-Key: your_api_key" \
-H "Content-Type: application/json"Get QR Code - Open in browser or scan
http://localhost:3000/api/whatsapp/sessions/mysession/qr/imageNote: QR image endpoint also requires API key. Use curl or include header.
Send a message
curl -X POST http://localhost:3000/api/whatsapp/chats/send-text \
-H "X-Api-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"sessionId": "mysession", "chatId": "628123456789", "message": "Hello!"}'Access the admin dashboard at http://localhost:3000/dashboard
Dashboard requires login with username and password configured in .env file.
| Field | Default Value |
|---|---|
| Username | admin |
| Password | admin123 |
| Feature | Description |
|---|---|
| Real-time Stats | Monitor total sessions, connected/disconnected status, and WebSocket clients |
| Session Management | Create, connect, reconnect, and delete WhatsApp sessions |
| QR Code Scanner | Scan QR codes directly from the dashboard |
| Live Events | Real-time WebSocket event viewer with filtering |
| Quick Send | Send messages quickly to any number |
| API Tester | Test all 40+ API endpoints with pre-filled templates |
| Bulk Messaging | Send messages to multiple recipients with job tracking |
| Webhook Manager | Add, remove, and configure webhooks per session |
| Logout | Secure logout button in header |
The dashboard provides a modern dark-themed interface:
Base URL: http://localhost:3000/api/whatsapp
GET /sessionsResponse:
{
"success": true,
"message": "Sessions retrieved",
"data": [
{
"sessionId": "mysession",
"status": "connected",
"isConnected": true,
"phoneNumber": "628123456789",
"name": "John Doe",
"webhooks": [
{
"url": "https://your-server.com/webhook",
"events": ["message", "message_ack"]
}
],
"metadata": {
"userId": "user123",
"plan": "premium"
}
}
]
}| Field | Type | Description |
|---|---|---|
sessionId |
string | Unique session identifier |
status |
string | Current status: disconnected, connecting, qr_ready, connected |
isConnected |
boolean | Whether session is currently connected |
phoneNumber |
string | Connected WhatsApp phone number |
name |
string | WhatsApp profile name |
webhooks |
array | Configured webhooks for this session |
metadata |
object | Custom metadata associated with this session |
POST /sessions/:sessionId/connectBody (Optional):
{
"metadata": {
"userId": "user123",
"plan": "premium",
"customField": "any value"
},
"webhooks": [
{ "url": "https://your-server.com/webhook", "events": ["all"] },
{ "url": "https://backup-server.com/webhook", "events": ["message"] }
]
}| Parameter | Type | Description |
|---|---|---|
metadata |
object | Optional. Custom metadata to store with session |
webhooks |
array | Optional. Array of webhook configs [{ url, events }] |
Response:
{
"success": true,
"message": "Session created",
"data": {
"sessionId": "mysession",
"status": "qr_ready",
"qrCode": "data:image/png;base64,...",
"metadata": { "userId": "user123" },
"webhooks": [
{ "url": "https://your-server.com/webhook", "events": ["all"] }
]
}
}PATCH /sessions/:sessionId/configBody:
{
"metadata": { "newField": "value" },
"webhooks": [
{ "url": "https://new-webhook.com/endpoint", "events": ["message", "connection.update"] }
]
}Response:
{
"success": true,
"message": "Session config updated",
"data": {
"sessionId": "mysession",
"metadata": { "userId": "user123", "newField": "value" },
"webhooks": [
{ "url": "https://new-webhook.com/endpoint", "events": ["message", "connection.update"] }
]
}
}POST /sessions/:sessionId/webhooksBody:
{
"url": "https://another-server.com/webhook",
"events": ["message", "connection.update"]
}DELETE /sessions/:sessionId/webhooksBody:
{
"url": "https://another-server.com/webhook"
}GET /sessions/:sessionId/statusGET /sessions/:sessionId/qrGET /sessions/:sessionId/qr/imageReturns a PNG image that can be displayed directly in browser or scanned.
DELETE /sessions/:sessionId** Typing Indicator**: All messaging endpoints support
typingTimeparameter (in milliseconds) to simulate typing before sending the message. This makes the bot appear more human-like.↩️ Reply to Message: All messaging endpoints support
replyToparameter to reply to a specific message. Pass the message ID to quote/reply to that message.
POST /chats/send-textBody:
{
"sessionId": "mysession"暂无开放 Issues,或尚未同步最近议题。