Skip to main content

Response format and status codes

Response format and status codes

Base success response (200, 201, 202)

Base collection response (200)

The pre-built resource responses (ResourceListResponse, ResourceViewResponse, …) emit this shape without the message key. The data envelope and the pagination object come from the framework, not your controller code. Pagination values that are null are left out rather than sent as null.
Empty response must be an empty array:

Base error response (400-500)

Rules:
  • error.key is mandatory and machine-readable
  • error.message is human-readable and should be localized
Apivalk’s own error responses (UnauthorizedApivalkResponse, NotFoundApivalkResponse, TooManyRequestsApivalkResponse, …) send error as a plain string, for example {"error": "Too many requests"}, not this object. Its 422 response follows the validation format below.

Base deleted response (204)

HTTP 204 responses have no body.

Base validation error response (422)

Rules:
  • parameter should use snake_case and match the request field name where possible
  • message should be localized
  • key should be stable and machine-readable

Base OPTIONS response

OPTIONS responses should rely on headers, not a body. Example headers:

HTTP status codes

Rate limiting

All REST APIs should expose standardized rate-limit information via HTTP response headers. Headers: Example:
Rate limit exceeded example: