Skip to content

Response Configuration

Standard routes build responses by mapping database columns to output properties.

TermDescription
Response propertyA field returned in the API response
SelectorA column reference that maps a database column to a response property
SourceFormatExample
Base table column{table}.{column}user.firstName
Joined table column{joinAlias}.{column}companyId_company.name
Custom expressionRaw SQL expressionTRUE, COUNT(*)

Example response configuration:

Response Properties:
- id → user.id
- firstName → user.firstName
- lastName → user.lastName
- companyName → companyId_company.name
- isActive → TRUE

This generates a response like:

{
"data": {
"id": 1,
"firstName": "John",
"lastName": "Doe",
"companyName": "Acme Corp",
"isActive": true
}
}

TypeDescriptionFormat
Wrapped responseStandard format that puts data inside a wrapper{ "data": { ... } }
Paged responseContains data array and total count for pagination{ "data": [...], "total": N }

Returns a single object wrapped in a data property:

{
"data": {
"id": 1,
"name": "John Doe",
"email": "john@example.com"
}
}

Returns an array of objects wrapped in a data property:

{
"data": [
{ "id": 1, "name": "John Doe" },
{ "id": 2, "name": "Jane Smith" }
]
}

Returns an array with a total count:

{
"data": [
{ "id": 1, "name": "John Doe" },
{ "id": 2, "name": "Jane Smith" }
],
"total": 150
}

DELETE routes return a boolean success indicator:

{
"data": true
}

Paged routes (PAGED and CUSTOM_PAGED) automatically handle pagination.

When you select PAGED type, these parameters are added automatically:

ParameterTypeDescriptionDefault
pagenumberCurrent page number (1-indexed)1
perPagenumberNumber of items per page10
filterstringDynamic where condition string
sortBystringColumn name to sort by
sortOrderstringSort direction (ASC or DESC)ASC
GET /api/v1/users?page=2&perPage=20&sortBy=createdOn&sortOrder=DESC
{
"data": [
{ "id": 21, "name": "User 21" },
{ "id": 22, "name": "User 22" },
...
{ "id": 40, "name": "User 40" }
],
"total": 150
}

The client can calculate:

  • Total pages: Math.ceil(total / perPage) = Math.ceil(150 / 20) = 8
  • Current page: 2
  • Has next page: page < totalPages
  • Has previous page: page > 1

The filter parameter allows clients to pass dynamic where conditions:

GET /api/v1/users?filter=status='active' AND role='admin'

This is useful for building flexible search interfaces without creating multiple endpoints.

Custom routes specify a response type instead of using selectors.

OptionDescription
booleanReturns a boolean value
stringReturns a string value
numberReturns a numeric value
CustomReturns a custom TypeScript interface you’ve defined

Define custom TypeScript interfaces for complex response structures:

export interface AuthResponse {
token: string;
tokenExp: string;
refreshToken: string;
refreshTokenExp: string;
}

Then select this type as your custom route’s response type.

Learn more about custom routes and types.


Route: GET /api/v1/user/:id

Response:

{
"data": {
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"companyName": "Acme Corp",
"role": "ADMIN",
"createdOn": "2024-01-15T10:30:00Z"
}
}

Route: GET /api/v1/users

Response:

{
"data": [
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com"
},
{
"id": 2,
"firstName": "Jane",
"lastName": "Smith",
"email": "jane@example.com"
}
]
}

Route: GET /api/v1/users/paged?page=1&perPage=10&sortBy=lastName&sortOrder=ASC

Response:

{
"data": [
{ "id": 5, "firstName": "Alice", "lastName": "Anderson" },
{ "id": 12, "firstName": "Bob", "lastName": "Brown" },
{ "id": 3, "firstName": "Charlie", "lastName": "Clark" }
],
"total": 47
}