# List documents

`GET /businesses/{bid}/documents`

Requires the `documents` scope.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `status` | string |  |  One of: `draft`, `issued`. |
| `docType` | integer |  |  One of: `305`, `320`, `330`, `400`. |
| `from` | string |  | Inclusive, on document date. |
| `to` | string |  | Inclusive. |
| `take` | integer |  |  Default `200`. |
| `before` | string |  | Time cursor: rows created strictly before this instant, newest first. To page, start with now and pass the last row's `createdAt`. |
| `externalRefPrefix` | string |  | Only documents whose `externalRef` starts with this (every document filed under one of your own references, e.g. a job). |
| `q` | string |  | Free-text search: party name, exact document number (digits), or a line description. |
| `partyId` | string |  | Only documents filed against this party. |
| `skip` | integer |  | Offset paging: rows to skip before `take`. Combine with `counts=1` for totals. Default `0`. |
| `counts` | string |  | Adds `counts: { total, byStatus }` over the same filters (minus `status`), so pages and count boxes agree. One of: `1`. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `documents` | array of Document | **required** |  |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error": …, "reason": … }`. Branch on `reason`.

## Examples

### cURL

```bash
curl -X GET "$BASE/businesses/$BID/documents?status=&docType=&from=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/documents`, {
  method: 'GET',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.get(
    f"{BASE}/businesses/{BID}/documents",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```