Introduction
Error handling
Understanding error responses in the Serverista API
The Serverista API uses standard HTTP status codes to indicate the success or failure of API requests. All endpoints return structured error responses in JSON format, making it easier for clients to handle and display errors consistently.
Error Response Structure
There are two primary types of error responses:
Single Error
Used for general errors such as authentication failures, permission issues, or server-side errors.
Example JSON response:
{
"error": "unauthorized"
}
Field Validation Errors
Used when one or more request fields fail validation. The response contains a map of field names to error messages.
{
"errors": {
"email": "invalid format",
"password": "must be at least 8 characters"
}
}
HTTP Status Codes
The Serverista API uses standard HTTP status codes to indicate the outcome of a request. Common codes include:
| Status Code | Meaning | Response Type |
|---|---|---|
| 200 | OK – The request was successful | Resource object |
| 400 | Bad Request – The request was invalid | Error or Errors |
| 401 | Unauthorized – Authentication failed | Error |
| 403 | Forbidden – Request is understood but refused | Error |
| 404 | Not Found – The requested resource could not be found | Error |
| 500 | Internal Server Error – Unexpected server error | Error |