Sorting
Order list results with sort_by; prefix a hyphen to reverse.
Add the sort_by query parameter to return list results in a defined order.
?sort_by=<attribute>
Sorting can be applied to attributes such as:
| Attribute | Default order | Description |
|---|---|---|
label | Alphabetical | Label of the entity |
name | Alphabetical | Name of the entity |
createdAt | Oldest first | When the entity was created |
lastTriggered | Oldest first | When an event last triggered |
Reverse the orderEvery attribute has a default order that you can invert by prefixing a hyphen — e.g.
-createdAt(newest first) or-label(Z→A).
Example
List your cold-chain trackers alphabetically by label (showing only the label, via Dynamic Fields):
curl -X GET 'https://api.surfact.com/api/v2.0/devices/?sort_by=label&fields=label' \
-H 'X-Auth-Token: your_token_here'{
"count": 5,
"next": null,
"previous": null,
"results": [
{ "label": "pharma-fridge-a" },
{ "label": "pharma-fridge-b" },
{ "label": "reefer-trailer-01" },
{ "label": "reefer-trailer-02" },
{ "label": "vaccine-box-09" }
]
}Newest devices first — useful for spotting recently provisioned trackers:
curl -X GET 'https://api.surfact.com/api/v2.0/devices/?sort_by=-createdAt' \
-H 'X-Auth-Token: your_token_here'Updated 7 days ago
Did this page help you?