# Pagination

> Page-based pagination with total counts on all list endpoints

All list and search endpoints return paginated results.

## Parameters

| Parameter | Type | Default | Max | Description |
|-----------|------|---------|-----|-------------|
| `page` | integer | 1 | — | Page number (1-indexed) |
| `size` | integer | 20 | 100 | Results per page |

For GET endpoints, pass as query params. For POST search endpoints, include in the request body.

## Response format

Every paginated response includes a `pagination` object:

```json
{
  "data": [
    { "id": "cll_abc123", "type": "call", "..." : "..." },
    { "id": "msg_def456", "type": "sms", "..." : "..." }
  ],
  "pagination": {
    "page": 1,
    "size": 20,
    "total_count": 156,
    "total_pages": 8,
    "has_more": true
  }
}
```

| Field | Description |
|-------|-------------|
| `page` | Current page number |
| `size` | Results per page |
| `total_count` | Total matching results across all pages |
| `total_pages` | Total number of pages |
| `has_more` | `true` if there are more pages after this one |

## Iterating through pages

```javascript
let page = 1;
let hasMore = true;

while (hasMore) {
  const response = await fetch(
    `https://api.withallo.com/v2/api/conversations?page=${page}&size=100`,
    { headers: { "Authorization": "Api-Key ak_live_your_key" } }
  );

  const { data, pagination } = await response.json();
  // Process data...

  hasMore = pagination.has_more;
  page++;
}
```
