Skip to main content
The SSP Backend API uses standard HTTP status codes to indicate the success or failure of requests.

HTTP Status Codes

Success Codes

200 OK
success
Request succeeded. The response body contains the requested data.
201 Created
success
Resource successfully created. The response body contains the new resource.

Client Error Codes

400 Bad Request
error
The request was invalid or contained malformed data. Check validation errors in the response.
401 Unauthorized
error
Authentication failed or JWT token is missing/invalid.
403 Forbidden
error
The authenticated user does not have permission to access this resource.
404 Not Found
error
The requested resource was not found.

Server Error Codes

500 Internal Server Error
error
An unexpected error occurred on the server.

Error Response Format

Error responses follow this structure:
{
  "statusCode": 400,
  "message": "Validation failed",
  "error": "Bad Request"
}

Validation Errors

When validation fails (400 Bad Request), the response includes detailed error messages:
{
  "statusCode": 400,
  "message": [
    "El nombre es obligatorio",
    "El tiempo asignado debe ser mayor a 0"
  ],
  "error": "Bad Request"
}

Authentication Errors

Missing Token

{
  "statusCode": 401,
  "message": "Unauthorized"
}

Invalid Token

{
  "statusCode": 401,
  "message": "Invalid token"
}

Authorization Errors

When a user lacks the required role:
{
  "statusCode": 403,
  "message": "Forbidden resource"
}

Not Found Errors

When a resource doesn’t exist:
{
  "statusCode": 404,
  "message": "Beneficiario not found"
}

Common Validation Rules

All string fields are validated for type and required fields must not be empty.
  • Minimum length: Some fields like contrasena require at least 6 characters
  • Enum values: Category and role fields must match predefined enum values
  • Numeric fields: Must be valid integers and meet minimum value requirements
  • Boolean fields: Must be valid boolean values (true/false)

Build docs developers (and LLMs) love