WhatsApp API Collections
This directory contains organized HTTP collections for testing the WhatsApp API across different operational modes.
📁 Folder Structure
api-collections/
├── global/
│ └── global-endpoints.http # Mode information and global endpoints
├── single-instance/
│ └── legacy-endpoints.http # Legacy single-instance endpoints
├── multi-instance/
│ └── multi-endpoints.http # Multi-instance management endpoints
├── postman_collection.json # Postman collection for GUI testing
├── http-client.env.json # Environment variables for HTTP clients
├── integration-tests.http # Complete workflow testing
└── README.md # This file
🎯 Operational Modes
The API supports three operational modes configured via the WHATSAPP_MODE environment variable:
1. Single Instance Mode (WHATSAPP_MODE=single)
- Endpoints Available: Global + Single Instance (Legacy)
- Use Case: Simple single WhatsApp instance operation
- Test Files:
global/+single-instance/
2. Multi-Instance Mode (WHATSAPP_MODE=multi) - Default
- Endpoints Available: Global + Multi-Instance (including plugin management)
- Use Case: Managing multiple WhatsApp instances with per-instance plugin configuration
- Test Files:
global/+multi-instance/
3. Hybrid Mode (WHATSAPP_MODE=both)
- Endpoints Available: All endpoints
- Use Case: Full flexibility with both legacy and multi-instance support
- Test Files: All collections
🚀 Quick Start
1. Check Current Mode
Start by checking which mode is currently active:
http
GET http://localhost:3000/api/v1/mode
2. Test Based on Mode
For Single Instance Mode:
- Use
global/global-endpoints.http - Use
single-instance/legacy-endpoints.http
For Multi-Instance Mode:
- Use
global/global-endpoints.http - Use
multi-instance/multi-endpoints.http
For Hybrid Mode:
- Use all collections
- Run
integration-tests.httpfor complete workflow testing
📝 Using the Collections
Visual Studio Code / IntelliJ IDEA
- Install the REST Client extension
- Open any
.httpfile - Click "Send Request" above each HTTP request
- Variables from
http-client.env.jsonwill be automatically loaded
Postman
- Import the
postman_collection.jsonfile into Postman - The collection includes:
- 🌐 Global Endpoints (available in all modes)
- 🔀 Single Instance (Legacy) endpoints
- 🏢 Multi-Instance Management endpoints (including 🔌 Plugin Management)
- Set up the environment variables (
base_url,phone_number, etc.) - The collection automatically organizes requests by operational mode
Thunder Client
- Import the requests manually or use the Postman collection
- Set up environment variables as needed
🔧 Environment Variables
The http-client.env.json file contains environment-specific variables:
json
{
"development": {
"base_url": "http://localhost:3000",
"phone_number": "628123456789",
"test_phone": "628111222333",
"test_group_id": "[email protected]"
}
}
Available Variables:
{{base_url}}- API base URL{{phone_number}}- Primary instance phone number{{test_phone}}- Test recipient phone number{{test_group_id}}- Test WhatsApp group ID{{webhook_id}}- Webhook ID for webhook management endpoints
📋 Testing Workflows
Basic Testing Flow:
- Check Mode: Run global endpoint to verify current mode
- Health Check: Test ping/status endpoints
- Core Functionality: Test messaging endpoints
- Error Handling: Test invalid requests
- Cleanup: Remove test data
Integration Testing:
Run the integration-tests.http file which includes:
- Mode verification
- Complete single-instance workflow
- Complete multi-instance workflow
- Error handling tests
- Cleanup procedures
🛠️ Customization
Adding New Tests:
- Choose the appropriate folder based on the endpoint's mode availability
- Follow the existing format and naming conventions
- Add proper comments and error test cases
- Update environment variables if needed
Switching Modes:
- Update
WHATSAPP_MODEin your.envfile - Restart the application
- Verify the mode change using the global endpoint
- Use the appropriate collection files for testing
🎨 Collection Features
- Clear Organization: Endpoints grouped by functionality and mode
- Comprehensive Coverage: All endpoints with examples and error cases
- Environment Support: Variables for easy configuration
- Integration Testing: Complete workflow validation
- Error Testing: Comprehensive error scenario coverage
📚 Additional Resources
- Postman Collection:
./postman_collection.json - Application Configuration:
../.env - Mode Configuration:
../src/config/mode.config.js