# Every document of a period as one zip

`GET /businesses/{bid}/exports/documents`

Requires the `export` scope.

The period as an accountant files it: each issued document as its own signed PDF, the העתק (a copy, never the origin, which is delivered once), in `הכנסות/YYYY-MM/`, named `<type> <number> - <date> - <customer>.pdf`; the expense receipts in `הוצאות/YYYY-MM/`; the previous software's archived documents in `מהמערכת הקודמת/YYYY-MM/`; and `אינדקס מסמכים.xlsx`, one row per document with its amounts, links and status, each row linking to its file inside the zip. Cancelled documents, credit notes and proformas are included and marked. A document whose PDF is not rendered yet is listed in the index without a file, and `X-BillOS-Missing-Files` counts them. Built on request, never stored, and not counted as a print. Names inside the zip are Hebrew, marked UTF-8. At most 400 days and 3,000 files per zip: split a longer period.

## Path parameters

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

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `from` | string | **required** | By document date. |
| `to` | string | **required** |  |
| `expenses` | boolean |  | Include the expense receipts and their sheet. Default `true`. |
| `legacy` | boolean |  | Include the archived documents of the previous software. Default `true`. |

## Response

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

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

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

```node
const res = await fetch(`${BASE}/businesses/${BID}/exports/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}/exports/documents",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```