# Guide: paginate Beplan API lists

Lists that can grow long are paged with a limit and an opaque cursor. Ask for the next page until hasMore is false.

## Cursor paging

A paged list takes two query parameters:

- `limit`: how many items, from 1 to the operation's maximum (100 for most, 500 for [`GET …/deals`](https://beplan.io/docs/api/deals/#deals.list)). Leave it out for the operation's default.
- `cursor`: leave it out for the first page; then pass the previous answer's `page.nextCursor`.

The answer has the items in `data` and the paging state in `page`:

```json
{
  "data": [{ "id": "…" }],
  "page": { "nextCursor": "b3Jk…", "hasMore": true }
}
```

Keep going while `page.hasMore` is `true`. Treat the cursor as opaque: don't parse it, build it or keep it for long; it is only meant for the next request with the same filters.

Example (The first page of images), `GET /organizations/{organizationId}/workspaces/{workspaceId}/media-library/items`:

```bash
curl -X GET "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/media-library/items?type=image&limit=25" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/media-library/items?type=image&limit=25", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/media-library/items?type=image&limit=25",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": [
    {
      "id": "0b6f5a52-7f4e-4c55-9d6f-2f0a6a1c3e11",
      "folderId": null,
      "filename": "launch-teaser.jpg",
      "altText": "Our new studio at sunrise",
      "mediaType": "image",
      "mimeType": "image/jpeg",
      "size": 482133,
      "width": 1080,
      "height": 1350,
      "aspectRatio": 0.8,
      "duration": null,
      "waveform": null,
      "createdAt": "2026-11-18T09:30:00.000Z",
      "formats": [],
      "usage": "unused",
      "processing": {
        "state": "ready",
        "error": null
      },
      "previewUrl": "https://storage.beplan.io/org-media/…/preview?X-Amz-Signature=…",
      "mediaUrl": "https://storage.beplan.io/org-media/…?X-Amz-Signature=…",
      "playback": null,
      "publishCopy": null
    }
  ],
  "page": {
    "nextCursor": null,
    "hasMore": false
  }
}
```

TypeScript:

```typescript
async function listAll<T>(url: string, token: string): Promise<T[]> {
  const items: T[] = [];
  let cursor: string | null = null;
  do {
    const page = new URL(url);
    page.searchParams.set("limit", "100");
    if (cursor) page.searchParams.set("cursor", cursor);
    const response = await fetch(page, { headers: { Authorization: `Bearer ${token}` } });
    if (!response.ok) throw new Error((await response.json()).error.code);
    const body = await response.json();
    items.push(...body.data);
    cursor = body.page.hasMore ? body.page.nextCursor : null;
  } while (cursor);
  return items;
}
```

Python:

```python
import requests


def list_all(url, token):
    items, cursor = [], None
    while True:
        params = {"limit": 100}
        if cursor:
            params["cursor"] = cursor
        response = requests.get(url, params=params, headers={"Authorization": f"Bearer {token}"})
        response.raise_for_status()
        body = response.json()
        items.extend(body["data"])
        if not body["page"]["hasMore"]:
            return items
        cursor = body["page"]["nextCursor"]
```

Every page is a request: mind the [rate limits](https://beplan.io/docs/guides/rate-limits/) when walking a long list.

## Which lists page

Only the lists that can grow long. Each operation's parameters in the reference show `limit` and `cursor` when it pages. Shorter lists (a workspace's social accounts, its formats, an organization's workspaces) answer everything in `data` with no `page`.

---
HTML version: https://beplan.io/docs/guides/pagination/
