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

# Pagination, Sorting & Filtering

> How to paginate, sort, and filter results from list endpoints.

## Pagination

All list endpoints support cursor-based pagination using page number and page size parameters.

| Parameter      | Default | Max   | Description      |
| -------------- | ------- | ----- | ---------------- |
| `page[number]` | `1`     | —     | Page number      |
| `page[size]`   | `20`    | `100` | Results per page |

**Example request:**

```bash theme={null}
curl "https://api.mageloyalty.com/v1/customers?page[number]=2&page[size]=50" \
  -H "Authorization: your-api-key"
```

**Pagination metadata** is included in every list response under the `meta` key:

```json theme={null}
{
  "data": [...],
  "meta": {
    "total": 245,
    "page": 2,
    "per_page": 50,
    "total_pages": 5
  }
}
```

## Sorting

Most list endpoints accept a `sort` parameter. Prefix the field name with `-` for descending order.

```bash theme={null}
# Sort by most recent first (descending)
?sort=-created_at

# Sort by name A-Z (ascending)
?sort=name
```

Each endpoint documents its own set of sortable fields. The default sort for all list endpoints is `-created_at` (newest first).

## Filtering

Some endpoints support filtering via `filter[field]` query parameters.

```bash theme={null}
# Filter customers by email
?filter[email]=jane

# Filter rewards by active status
?filter[is_active]=true

# Filter earning history by status
?filter[status]=approved
```

Filter values are endpoint-specific — see individual endpoint documentation for available filters.
