API Specification
Error Handling
Understand API error responses and status codes
Overview
All APIs return a standard response format for both success and error cases. Errors help identify issues such as invalid input, authentication failure, or server problems.
Error Response Format
JSON Response
{
"status": false,
"message": "Error message here"
}
Every error response includes:
| Field | Description |
|---|---|
status | Indicates success or failure (false for errors) |
message | Description of the error |
Common Errors
| Error Message | Description |
|---|---|
Invalid API Key | API key is missing or incorrect |
Unauthorized access | User does not have permission |
Missing parameters | Required fields are not provided |
Invalid request | Incorrect or malformed input |
No data found | No results available for request |
Booking not found | Invalid booking ID |
Seat not available | Selected seat already booked |
Booking failed | Unable to process booking request |
Cancellation failed | Unable to cancel booking |
Server error | Internal system error |
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad Request |
401 | Unauthorized |
404 | Not Found |
500 | Internal Server Error |
Validation Errors
JSON Response
{
"status": false,
"message": "Validation failed",
"errors": {
"OriginId": "Origin is required",
"DateOfJourney": "Invalid date format"
}
}
Validation errors may include additional errors object with field-level details.
Best Practices
- ✔ Always check status before processing response
- ✔ Handle error messages gracefully in UI
- ✔ Validate input before sending API request
- ✔ Retry request for temporary server errors