4xx or 5xx status code includes a JSON body that gives you a machine-readable error code and a human-readable message — so your integration can respond intelligently without parsing free-form text.
Error Response Format
Every error response follows this consistent shape:Always
"error" for failed requests.A stable, snake_case identifier for the error type. Use this field in your application logic — the
message field is for humans and may change.A plain-English description of what went wrong, suitable for logging or displaying to internal users.
HTTP Status Codes
| Status | Meaning |
|---|---|
200 OK | The request succeeded. |
201 Created | A resource was successfully created (e.g., a new Sender ID was registered). |
400 Bad Request | The request is malformed or contains invalid parameters. |
401 Unauthorized | The Authorization header is missing or contains an invalid API key. |
403 Forbidden | The API key is valid but does not have permission to perform this action. |
404 Not Found | The requested resource does not exist. |
422 Unprocessable Entity | The request is well-formed but failed validation (e.g., insufficient credits). |
429 Too Many Requests | You have exceeded the rate limit. Slow down and retry. |
500 Internal Server Error | An unexpected error occurred on Hany’s servers. Contact support if it persists. |
Common Error Codes
| Error Code | HTTP Status | Description |
|---|---|---|
unauthorized | 401 | API key is missing or invalid. Check your Authorization header. |
forbidden | 403 | Your API key does not have permission to perform this action. |
invalid_recipient | 400 | The recipient phone number is not in valid E.164 format (e.g., +233XXXXXXXXX). |
invalid_sender_id | 400 | The specified Sender ID is not registered on your account or has not been approved. |
insufficient_credits | 422 | Your account does not have enough credits to send this message or campaign. |
rate_limit_exceeded | 429 | You are sending requests too quickly. Implement backoff and retry. |
message_too_long | 400 | The message body exceeds the maximum allowed character length. |
server_error | 500 | An internal error occurred. Retry the request or contact support@hany.tools. |
Handling Errors
Check the HTTP status code first, then inspecterror.code to take the appropriate action in your integration: