
## List documents

`GET /v1/note/documents`

Returns a flat list of accessible documents with continuation. Use this method to traverse a large knowledge base: the document tree of one knowledge base is not a page.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `limit` (query) | integer | no | Page size, from 1 to 200 |
| `afterCursor` (query) | string | no | The previous response's `meta.nextCursor` object as URL-encoded JSON. Fields: `stream`, `collectionId`, `id` |

Pass the cursor fields unchanged. `collectionId` may be `null`. Stop only when `meta.nextCursor` is `null`: empty `data` with a non-null cursor means you must request the next page.

## Examples

### curl — personal key

```bash
curl -G https://vibecode.bitrix24.com/v1/note/documents \
  --data-urlencode "limit=20" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -G https://vibecode.bitrix24.com/v1/note/documents \
  --data-urlencode "limit=20" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
let cursor = null
do {
  const params = new URLSearchParams({ limit: '20' })
  if (cursor) params.set('afterCursor', JSON.stringify(cursor))
  const res = await fetch(`https://vibecode.bitrix24.com/v1/note/documents?${params}`, {
    headers: { 'X-Api-Key': 'YOUR_API_KEY' },
  })
  if (!res.ok) throw new Error(`HTTP ${res.status}`)
  const { data, meta } = await res.json()
  for (const document of data) console.log(document.id)
  cursor = meta.nextCursor
} while (cursor !== null)
```

### JavaScript — OAuth application

```javascript
let cursor = null
do {
  const params = new URLSearchParams({ limit: '20' })
  if (cursor) params.set('afterCursor', JSON.stringify(cursor))
  const res = await fetch(`https://vibecode.bitrix24.com/v1/note/documents?${params}`, {
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
    },
  })
  if (!res.ok) throw new Error(`HTTP ${res.status}`)
  const { data, meta } = await res.json()
  for (const document of data) console.log(document.id)
  cursor = meta.nextCursor
} while (cursor !== null)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Documents on this page; the array may be empty while continuation is available |
| `data[].id` | number | Document identifier |
| `meta.nextCursor` | object or null | Next-page cursor `{ stream, collectionId, id }`, or `null` at the end |

## Response example

```json
{
  "success": true,
  "data": [{ "id": 40 }],
  "meta": { "nextCursor": { "stream": "collections", "collectionId": 3, "id": 40 } }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `limit` outside 1…200 or malformed `afterCursor` |
| 403 | `SCOPE_DENIED` | The key lacks the `note` scope |
| 401 | `TOKEN_MISSING` | The API key has no tokens configured |

Full list of common API errors — [Errors](/docs/errors).

## See also

- [Search documents](/docs/note/documents/search)
- [Document tree](/docs/note/collections/tree)
- [Documents](/docs/note/documents)
