# Void a proforma (חשבון עסקה)

`POST /businesses/{bid}/documents/{id}/void`

Requires the `documents` scope.

A חשבון עסקה (300) is not a tax document and has no credit note, so a wrong or cancelled one is voided instead. The row, its snapshot and its PDFs are untouched and it stays in the exports; from now on it reads as cancelled and is no longer owed. Refused on any other type (`doc_type_not_allowed`: a tax document is corrected by a credit note), on one already voided (`409 conflict`), and on one a receipt was settled against (cancel the receipt first).

## Path parameters

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

## Body (optional)

| Field | Type | | Description |
|---|---|---|---|
| `reason` | string |  | Why. Kept on the document and in the audit log, up to 300 characters. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean |  |  |
| `documentId` | string |  |  |
| `voidedAt` | string |  |  |

Errors: `400`, `401`, `403`, `404`, `409`, `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/documents/$DOC_ID/void" \
  -H "X-Api-Key: $KEY"
```
### Node

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