Skip to main content
SaaS Foundation API routes use a consistent response envelope. Check the success field to distinguish a successful response from an error response.

Success responses

A successful response includes success: true and a data field. The shape of data depends on the endpoint.

Detail response

Endpoints that return one resource respond with 200 OK.

List response

Endpoints that return an unpaginated collection respond with 200 OK. The data field is always an array, including when there are no results.

Paginated response

Paginated endpoints respond with 200 OK and include a top-level pagination object alongside the data array.

No-content response

Endpoints that complete successfully without returning data respond with 204 No Content. These responses have no JSON body.

Error responses

An error response includes success: false and an error object.
The API defines these standard error responses: Endpoints can provide a more specific message for authorization, permission, missing-resource, and conflict errors while retaining the standard error code.

Validation errors

Validation failures include a details array. Each item can identify a field with a dot-separated path and explain the problem with a message.

Handling responses

Use both the HTTP status and the success field when handling a response. A successful JSON response has success: true. An error has success: false and a stable error code that you can use for application logic. Display message or validation details when you need to give feedback to a person.