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 CodeMeaningResponse Type
200OK – The request was successfulResource object
400Bad Request – The request was invalidError or Errors
401Unauthorized – Authentication failedError
403Forbidden – Request is understood but refusedError
404Not Found – The requested resource could not be foundError
500Internal Server Error – Unexpected server errorError