Errors
The RafikiSMS API uses standard HTTP status codes. Error responses include a JSON body with details about what went wrong.
Error Response Format
{
"status": "error",
"message": "Error message description",
"errors": {
"field_name": ["Error message for this field"]
}
}HTTP Status Codes
| Status Code | Description |
|---|---|
400 | Bad Request --- Invalid parameters or malformed request |
401 | Unauthorized --- Missing or invalid API key / token |
403 | Forbidden --- Insufficient permissions |
404 | Not Found --- Resource does not exist |
422 | Unprocessable Entity --- Validation errors |
429 | Too Many Requests --- Rate limit exceeded |
500 | Internal Server Error --- Server error occurred |
Validation Errors (422)
When validation fails, the response includes an errors object with field-specific messages:
{
"status": "error",
"message": "Validation failed",
"errors": {
"phone": ["The phone field is required."],
"message": ["The message must not exceed 160 characters."]
}
}Always check the HTTP status code and handle errors gracefully. Implement retry logic with exponential backoff for transient errors (5xx) and rate limits (429).