Errors
Error Handling
The API uses conventional HTTP response codes to indicate the success or failure of requests.
HTTP Status Codes
| Code | Description |
|---|---|
200 | Success - Request completed successfully |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Requested resource does not exist |
500 | Internal Server Error - Server error occurred |
Error Response Format
All error responses follow a consistent format:
Error Response Structurejson
{
"success": false,
"error": "Human-readable error message",
"code": "ERROR_CODE"
}Error Codes
| Code | Description |
|---|---|
UNAUTHORIZED | Invalid or missing API key |
INVALID_PARAMS | Query parameters validation failed |
INVALID_ID | Invalid UUID format for tariff ID |
NOT_FOUND | Requested tariff does not exist |
DATABASE_ERROR | Database query failed |
INTERNAL_ERROR | Unexpected server error |
Example
401 Unauthorized
Missing or invalid API keyjson
{
"success": false,
"error": "Unauthorized",
"code": "UNAUTHORIZED"
}400 Bad Request
Invalid request parametersjson
{
"success": false,
"error": "Invalid query parameters",
"code": "INVALID_PARAMS"
}404 Not Found
Resource not foundjson
{
"success": false,
"error": "Tariff not found",
"code": "NOT_FOUND"
}Best Practices
- 1.Always check the
successfield in the response to determine if the request was successful - 2.Use the
codefield for programmatic error handling in your application - 3.Display the
errormessage to users for human-readable feedback - 4.Implement exponential backoff for retrying failed requests, especially for 5xx errors