## List documents

`GET /v1/documents`

Returns a list of documents with support for filtering, sorting, field selection, and automatic pagination.

## Parameters

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `limit` | number | `50` | Number of records (up to 5000). When `limit > 50`, Vibecode automatically requests several pages |
| `offset` | number | `0` | Skip N records. When `offset > 0`, `limit ≤ 500` is recommended |
| `select` | string | — | Field selection: `?select=id,title,number` |
| `order` | object | — | Sorting: `?order[id]=desc` |
| `filter` | object | — | Filtering by `GET /v1/documents/fields` fields.<br>[Filtering syntax](/docs/filtering). Example: `?filter[templateId]=53` |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/documents?limit=10&order[id]=desc&filter[templateId]=53" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/documents?limit=10&order[id]=desc&filter[templateId]=53" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/documents?limit=10&order[id]=desc&filter[templateId]=53', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data, meta } = await res.json()
console.log(`Found ${meta.total} documents`)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/documents?limit=10&order[id]=desc&filter[templateId]=53', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data, meta } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of documents (all item fields — see [Document fields](/docs/entities/documents/fields)) |
| `meta.total` | number | Number of records matching the filter |
| `meta.hasMore` | boolean | Whether there are more records beyond `limit` |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 51,
      "title": "Supply contract 2026-001",
      "number": "2026-001",
      "templateId": 53,
      "provider": "Bitrix\\DocumentGenerator\\DataProvider\\Rest",
      "value": "ORDER-1024",
      "fileId": 241,
      "pdfId": 245,
      "imageId": 243,
      "createTime": "2026-03-18T17:27:48+00:00",
      "updateTime": "2026-03-18T17:27:48+00:00",
      "createdBy": 503,
      "updatedBy": null,
      "values": { "DocumentNumber": "2026-001" },
      "stampsEnabled": false,
      "downloadUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getfile&id=51",
      "pdfUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getpdf&id=51",
      "imageUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getimage&id=51",
      "downloadUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getfile.json?token=t0k3n",
      "pdfUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getpdf.json?token=t0k3n",
      "imageUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getimage.json?token=t0k3n"
    },
    {
      "id": 52,
      "title": "Supply contract 2026-002",
      "number": "2026-002",
      "templateId": 53,
      "provider": "Bitrix\\DocumentGenerator\\DataProvider\\Rest",
      "value": "ORDER-1025",
      "fileId": 248,
      "pdfId": 250,
      "imageId": 249,
      "createTime": "2026-03-19T10:12:03+00:00",
      "updateTime": "2026-03-19T10:12:03+00:00",
      "createdBy": 503,
      "updatedBy": null,
      "values": { "DocumentNumber": "2026-002" },
      "stampsEnabled": false,
      "downloadUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getfile&id=52",
      "pdfUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getpdf&id=52",
      "imageUrl": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=documentgenerator.api.document.getimage&id=52",
      "downloadUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getfile.json?token=t0k3n",
      "pdfUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getpdf.json?token=t0k3n",
      "imageUrlMachine": "https://example.bitrix24.com/rest/documentgenerator.api.document.getimage.json?token=t0k3n"
    }
  ],
  "meta": { "total": 2, "hasMore": false }
}
```

## Error response example

400 — filter on a nonexistent field:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'zzzNope' for entity 'documents'. Available: id, title, number, templateId, providerClassName, value, values, fields, createTime, updateTime, fileId, pdfId, imageId, stampsEnabled, provider, downloadUrl, pdfUrl, imageUrl, downloadUrlMachine, pdfUrlMachine, imageUrlMachine, createdBy, updatedBy, publicUrl"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `UNKNOWN_FILTER_FIELD` | Filter on a field the document does not have. Field list — `GET /v1/documents/fields` |
| 403 | `SCOPE_DENIED` | The key is missing the `documentgenerator` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |

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

## Known specifics

The `publicUrl` field is returned only by `GET /v1/documents/:id` and is not present in the list.

When `limit > 50`, Vibecode requests several pages and gathers all records into a single response. A single call returns at most 5000 records.

When `offset ≥ 2500`, use `limit ≤ 500` for request stability.

For complex filters with many conditions, parameters are passed in the request body — `POST /v1/documents/search`. That endpoint also supports windowed date search for large selections. See [Search documents](/docs/entities/documents/search).

## See also

- [Search documents](/docs/entities/documents/search)
- [Create document](/docs/entities/documents/create)
- [Filtering syntax](/docs/filtering)
- [Entity reference](/docs/entity-api)
- [Batch requests](/docs/batch)
- [Limits and optimization](/docs/optimization)
