# List the archive

`GET /businesses/{bid}/legacy-documents`

Requires the `documents` scope.

Newest first by issue date. `total` is the count over the same filters.

## Path parameters

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

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `from` | string |  |  |
| `to` | string |  |  |
| `source` | string |  |  |
| `q` | string |  | Matches the number or the party name. |
| `take` | integer |  |  Default `50`. |
| `skip` | integer |  |  Default `0`. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `documents` | array of LegacyDocument | **required** |  |
| `total` | integer |  |  |

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/legacy-documents?from=&to=&source=" \
  -H "X-Api-Key: $KEY"
```
### Node

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