# Pagination

List endpoints (such as workspaces, models, and workflows) are **cursor-paginated**.

## Request

| Parameter | Default | Notes                                                                         |
| --------- | ------- | ----------------------------------------------------------------------------- |
| limit     | 20      | Page size. Minimum 1, maximum 100.                                            |
| cursor    | —       | Opaque cursor from the previous page’s next\_cursor. Omit for the first page. |

```bash
curl "https://api.app.layer.ai/api/v1/workspaces/$WORKSPACE_ID/models?limit=50" \
  -H "Authorization: Bearer $LAYER_TOKEN"
```

## Response envelope

Paginated responses wrap the items alongside a `pagination` object:

```json
{
  "models": [ /* … up to `limit` items … */ ],
  "pagination": {
    "next_cursor": "eyJvZmZzZXQiOjUwfQ",
    "has_more_results": true,
    "total_count": 214
  }
}
```

| Field              | Meaning                                                       |
| ------------------ | ------------------------------------------------------------- |
| next\_cursor       | Pass as cursor to fetch the next page. null on the last page. |
| has\_more\_results | true if another page exists.                                  |
| total\_count       | Total number of matching items.                               |

## Iterating

Keep requesting with the previous `next_cursor` until `has_more_results` is `false`:

```bash
cursor=""
while : ; do
  resp=$(curl -s "https://api.app.layer.ai/api/v1/workspaces/$WORKSPACE_ID/models?limit=100&cursor=$cursor" \
    -H "Authorization: Bearer $LAYER_TOKEN")
  # …process resp.models…
  cursor=$(echo "$resp" | jq -r '.pagination.next_cursor // empty')
  [ -z "$cursor" ] && break
done
```

Note

Treat the cursor as **opaque** — don’t parse or construct it. An invalid cursor returns [422 INVALID\_INPUTS](/docs/errors).
