
## Список документов

`GET /v1/note/documents`

Возвращает плоский список доступных документов с продолжением. Для полного обхода большой базы знаний используйте этот метод: дерево документов одной базы не является страницей.

## Параметры

| Параметр | Тип | Обяз. | Описание |
|----------|-----|:-----:|---------|
| `limit` (query) | integer | нет | Размер страницы, от 1 до 200 |
| `afterCursor` (query) | string | нет | JSON объекта `meta.nextCursor` из предыдущего ответа, закодированный для URL. Поля: `stream`, `collectionId`, `id` |

Передавайте курсор без изменения полей. `collectionId` может быть `null`. Завершайте обход только при `meta.nextCursor: null`: пустой `data` при ненулевом курсоре означает, что нужно запросить следующую страницу.

## Примеры

### curl — личный ключ

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

### curl — OAuth-приложение

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

### JavaScript — личный ключ

```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.tech/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-приложение

```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.tech/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)
```

## Поля ответа

| Поле | Тип | Описание |
|------|-----|---------|
| `success` | boolean | Всегда `true` при успехе |
| `data` | array | Документы текущей страницы; массив может быть пустым при наличии продолжения |
| `data[].id` | number | Идентификатор документа |
| `meta.nextCursor` | object или null | Курсор `{ stream, collectionId, id }` следующей страницы или `null` в конце |

## Пример ответа

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

## Ошибки

| HTTP | Код | Описание |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `limit` вне 1…200 или повреждённый `afterCursor` |
| 403 | `SCOPE_DENIED` | Ключу не хватает скоупа `note` |
| 401 | `TOKEN_MISSING` | У API-ключа не настроены токены |

Полный список общих ошибок API — [Ошибки](/docs/errors).

## Смотрите также

- [Поиск документов](/docs/note/documents/search)
- [Дерево документов](/docs/note/collections/tree)
- [Документы](/docs/note/documents)
