# Introducing sorting for the List Enrollments API

> You can now sort and control how enrollment records are ordered in List Enrollments API responses using the sortBy query parameter.

Published Jan 28, 2026

Product: ERAs and transaction enrollment

You can now control how enrollment records are ordered in [List Enrollments API](https://www.stedi.com/docs/healthcare/api-reference/get-enrollment-list-enrollments) responses using the [`sortBy`](https://www.stedi.com/docs/healthcare/api-reference/get-enrollment-list-enrollments#query.sortBy) query parameter.

Previously, List Enrollments API results were always ordered by [`createdAt`](https://www.stedi.com/docs/healthcare/api-reference/get-enrollment-list-enrollments#response.items.createdAt) in descending order. That remains the default.

With the new `sortBy` query parameter, you can now also sort by other fields and set a stable fallback when values are the same. For example, you can sort by `statusLastUpdatedAt` and fall back to `id` to ensure consistent, deterministic ordering:

```jsx
https://enrollments.us.stedi.com/2024-09-01/enrollments?sortBy=statusLastUpdatedAt:desc&sortBy=id:asc
```

## How the sorting works

Each `sortBy` value uses the `property:direction` format. If you provide multiple `sortBy` values, results are sorted in the order they appear.

When you provide a single `sortBy` value, Stedi automatically adds `id` as a secondary sort in the same direction. For example, if you provide `?sortBy=updatedAt:desc`, Stedi automatically adds `id:desc` to the query to ensure deterministic results.

To see available `sortBy` properties, check out our [API reference documentation](https://www.stedi.com/docs/healthcare/api-reference/get-enrollment-list-enrollments#query.sortBy).
