Sorting
Some list endpoints accept a sort query parameter object. It sorts the full result set before pagination cuts a page from it. The OpenAPI reference of each route lists the fields it can sort on.
Query parameters
| Parameter | Meaning | Default | Constraints |
|---|---|---|---|
sort[field] |
The field to sort on | The default of the route | One of the fields that the route declares |
sort[direction] |
The sort direction | asc |
asc or desc |
A field that the route does not declare returns a 400.
Example: the rows with the latest lastContactAt first.
GET /v1/example?sort[field]=lastContactAt&sort[direction]=desc
{
"sort": { "field": "lastContactAt", "direction": "desc" }
}
Ties, empty values and the default order
- Rows with the same value for the sort field are sorted by
id, ascending. For data that does not change, each page holds the same rows on each request. - Empty values (
null) come first withasc, and last withdesc. - Without
sort, the route uses its default order. The OpenAPI reference of each route shows it. - A sort on more than one field is not available.
Combining with filters and pagination
Send sort, filters and the pagination arguments in the same query string.
Example:
GET /v1/example?take=25&skip=50&sort[field]=name&filters[os][in][]=windows