# Upload a certificate or licence

`POST /businesses/{bid}/business-documents`

Requires the `businesses` scope.

The file bytes are the request body with their own `Content-Type`: `application/pdf`, `image/jpeg`, `image/png` or `image/webp`, up to 10MB. Fields you already know ride the query string and are never written over by the reading. The answer comes at once with `status: processing`; the file is read after it (poll the document). A byte-identical file returns the existing document with `duplicate: true` and 200. An account pending approval stores its files unread.

## Path parameters

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

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `filename` | string |  | Names the document until it is read. |
| `name` | string |  |  |
| `category` | string |  |  |
| `docNumber` | string |  |  |
| `issuer` | string |  |  |
| `issuedOn` | string |  |  |
| `validUntil` | string |  |  |

## Body

Raw bytes. Accepted content types: `application/pdf`, `image/jpeg`, `image/png`, `image/webp`.

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean |  |  |
| `document` | BusinessDocument |  | One of the business's own certificates, licences or approvals (תעודת עוסק מורשה, אישור ניכוי מס במקור, a licence, insurance). Read on upload: `status` is `processing` until the reading lands, and a field you set is never written over by it. Not a ledger record: no report or export reads one. |
| `duplicate` | boolean |  |  |

Errors: `400`, `401`, `403`, `404`, `413`, `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 POST "$BASE/businesses/$BID/business-documents?filename=&name=&category=" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: image/jpeg" \
  --data-binary @receipt.jpg
```
### Node

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

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