> ## Documentation Index
> Fetch the complete documentation index at: https://www.marqeta.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sorting and Pagination

> The sorting and pagination URL query parameters enable you to control how a request to Marqeta's Core API returns the contents of arrays of resources.

The Core API supports sorting and pagination for endpoints that return arrays of resources. The sorting mechanism places the resources in order; the pagination mechanism then returns a specific range of those ordered resources. You control sorting and pagination through URL query parameters.

A `GET` request to the `/users` endpoint returns an array of users. By default, the sorting mechanism places the most recently modified users at the top of the sort order (`sort_by=-lastModifiedTime`) and the pagination mechanism then returns the first five users (`count=5&start_index=0`). The following URL shows this default setting in an explicit form:

```bash Bash lines wrap theme={null}
/users?count=5&start_index=0&sort_by=-lastModifiedTime
```

The next five users in the sort order could then be returned with this URL (`start_index` is now set to `5`):

```bash Bash lines wrap theme={null}
/users?count=5&start_index=5&sort_by=-lastModifiedTime
```

<h2 id="_query_parameter_details">
  Query parameter details
</h2>

The following table provides details on the URL query parameters that control the sorting and pagination of returned arrays.

| Query Parameter | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Values                                                                                                                                            |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| sort\_by        | Fields by which to sort. Use any field in the resource model, or one of the system fields `lastModifiedTime` or `createdTime`. Prefix the field name with a hyphen (`-`) to sort in descending order. Omit the hyphen to sort in ascending order.<br /><br />**NOTE:** You must sort using system field names such as `lastModifiedTime` and `createdTime`, and not by the field names appearing in response bodies such as `last_modified_time` or `created_time`. | **Allowable Values:**`lastModifiedTime`, `createdTime`, or any field in the resource model<br /><br />**Default Value:**<br />`‑lastModifiedTime` |
| count           | Specifies the number of resources to return.                                                                                                                                                                                                                                                                                                                                                                                                                        | **Allowable Values:** 1–100<br /><br />**Default Value:**<br />5                                                                                  |
| start\_index    | Specifies the sort order index from which to begin returning data.                                                                                                                                                                                                                                                                                                                                                                                                  | **Allowable Values:** Any integer<br /><br />**Default Value:**<br />0 (the first row)                                                            |

<h2 id="_response_field_details">
  Response field details
</h2>

| Name         | Type             | Description                                                                                                       |
| ------------ | ---------------- | ----------------------------------------------------------------------------------------------------------------- |
| count        | integer          | The number of resources returned.<br /><br />**Allowable Values:** 1–100                                          |
| start\_index | integer          | The sort order index of the first resource in the returned array.<br /><br />**Allowable Values:** Any integer    |
| end\_index   | integer          | The sort order index of the last resource in the returned array.<br /><br />**Allowable Values:** Any integer     |
| is\_more     | boolean          | A value of `true` indicates that more unreturned resources exist.<br /><br />**Allowable Values:**`true`, `false` |
| data         | array of objects | Contains the returned resources.                                                                                  |

<h3 id="_sample_response_body">
  Sample response body
</h3>

```json JSON lines wrap theme={null}
{
  "count": 10,
  "start_index": 0,
  "end_index": 9,
  "is_more": true,
  "data": [
    ...
  ]
}
```


## Related topics

- [Direct Deposit](/docs/diva-api/direct-deposit.md)
- [ACH Origination](/docs/diva-api/ach-origination.md)
- [Credit Payments](/docs/diva-api/credit-payments.md)
- [Credit Cards](/docs/diva-api/credit-cards.md)
- [Credit Journal Entries](/docs/diva-api/credit-journal-entries.md)
