Error Response Format
All API errors follow a consistent JSON structure:Error Response Fields
| Field | Type | Description |
|---|---|---|
status | integer | HTTP status code (400, 401, 404, 500, etc.) |
code | string | Application-specific error code for programmatic handling |
message | string | Human-readable error message |
results | object/null | Additional error context or null if not applicable |
HTTP Status Codes
The API uses standard HTTP status codes to indicate success or failure:2xx Success
- 200 OK - Request succeeded
- Used for most successful GET, POST operations
- Response body contains the requested data
4xx Client Errors
-
400 Bad Request - Invalid request parameters or malformed request body
- Missing required fields
- Invalid field values
- Validation errors
-
401 Unauthorized - Authentication required or invalid credentials
- Missing or invalid
Authorizationheader - See Authentication guide
- Missing or invalid
-
404 Not Found - Requested resource doesn’t exist
- Device ID not found
- Message ID not found
- Chat not found
5xx Server Errors
-
500 Internal Server Error - Server-side error occurred
- Unexpected errors
- WhatsApp protocol errors
- Database errors
-
503 Service Unavailable - Service temporarily unavailable
- Device manager not initialized
- WhatsApp connection issues
Common Error Codes
Authentication Errors
401 Unauthorized
- Missing
Authorizationheader when Basic Auth is enabled - Invalid username/password combination
- Malformed Authorization header
Device Errors
DEVICE_ID_REQUIRED
- Multiple devices registered but no device ID provided
- Request to device-scoped endpoint without specifying device
X-Device-Id header:
DEVICE_NOT_FOUND
- Specified device ID doesn’t exist
- Device was removed
- Typo in device ID
- List all devices:
GET /devices - Create the device:
POST /devices - Use the correct device ID from step 1
DEVICE_MANAGER_UNAVAILABLE
- Server is still starting up
- Internal initialization failure
Validation Errors
BAD_REQUEST - Missing Required Field
- Required field not provided in request body
- Empty string for required field
BAD_REQUEST - Invalid Format
- Phone number not in JID format
- Invalid characters in field value
Connection Errors
INTERNAL_SERVER_ERROR - Not Logged In
- Device not connected to WhatsApp
- Session expired
- Device logged out
INTERNAL_SERVER_ERROR - Connection Lost
- Network connectivity issues
- WhatsApp servers unreachable
- Device was disconnected
Resource Not Found Errors
NOT_FOUND - Chat Not Found
- Chat JID doesn’t exist
- No conversation with specified contact
- Typo in chat JID
NOT_FOUND - Message Not Found
- Invalid message ID
- Message was deleted
- Message not in local database
/chat/{chat_jid}/messages response.
Error Handling Best Practices
1. Always Check Status Code
Check the HTTP status code first, then examine the error details:2. Use Error Codes for Logic
Use thecode field for programmatic error handling:
3. Implement Retry Logic
For transient errors (5xx), implement exponential backoff:4. Log Errors with Context
Include request context in error logs:5. Handle Rate Limiting
Debugging Tips
Enable Debug Mode
Run the server with debug logging:Check Device Status
Before making requests, verify device connectivity:Validate Request Payload
Use tools likejq to validate JSON payloads:
Common Troubleshooting Scenarios
Scenario 1: “you are not logged in”
Problem: GettingINTERNAL_SERVER_ERROR with message “you are not logged in”
Solution Steps:
- Check device status:
GET /devices/{device_id}/status - If not logged in, initiate login:
GET /devices/{device_id}/login - Scan QR code or use pairing code
- Verify login:
GET /devices/{device_id}/status
Scenario 2: Device keeps disconnecting
Problem: Device status shows disconnected frequently Solution Steps:- Check network connectivity
- Verify FFmpeg and libwebp are installed
- Check for WhatsApp account restrictions
- Review server logs with
--debug=true - Try reconnecting:
POST /devices/{device_id}/reconnect
Scenario 3: “field cannot be blank” errors
Problem: Validation errors when sending messages Solution Steps:- Review required fields in OpenAPI spec
- Ensure all required fields are present
- Check field formats (especially phone numbers)
- Verify Content-Type header:
application/json
Scenario 4: 404 errors on endpoints
Problem: Endpoints returning 404 Not Found Solution Steps:- Verify the correct base URL and path
- Check if using base path:
APP_BASE_PATH=/gowa - Ensure the endpoint exists in the API version you’re using
- Verify HTTP method (GET vs POST)
Error Response Examples
Example 1: Missing Required Field
Request:Example 2: Invalid Phone Format
Request:Example 3: Device Not Logged In
Request:Next Steps
API Overview
Review API fundamentals
Device Scoping
Understand device management
Endpoints
Explore available endpoints
OpenAPI Spec
View full API specification
