Skip to main content

Error Handling

This guide explains how to handle errors when using WhatsAble APIs.

HTTP Status Codes

All WhatsAble APIs use standard HTTP status codes:
  • 200 OK: Request successful
  • 400 Bad Request: Invalid request parameters
  • 401 Unauthorized: Invalid or missing API key
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Resource not found
  • 429 Too Many Requests: Rate limit exceeded
  • 500 Internal Server Error: Server-side error

Error Response Format

All error responses follow this format:

Common Error Codes

Authentication Errors

  • invalid_api_key: API key is invalid or expired
  • missing_api_key: API key is missing from request

Request Errors

  • invalid_phone_number: Phone number format is incorrect
  • invalid_template: Template ID is invalid or not found
  • missing_required_field: Required field is missing
  • invalid_variables: Template variables are invalid

Rate Limit Errors

  • rate_limit_exceeded: Too many requests in a time period
  • quota_exceeded: Monthly quota exceeded

Best Practices

  1. Always Check Status Codes: Don’t assume success
  2. Implement Retry Logic: For 429 and 500 errors
  3. Log Errors: For debugging and monitoring
  4. Handle Timeouts: Set appropriate timeout values
  5. Validate Input: Before making API calls

Example Error Handling