# Update a draft expense

`PATCH /businesses/{bid}/expenses/{id}`

Requires the `expenses` scope.

## Path parameters

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

## Body

| Field | Type | | Description |
|---|---|---|---|
| `id` | string | **required** |  |
| `status` | string | **required** |  One of: `draft`, `recorded`. |
| `supplierName` | string |  |  |
| `supplierTaxId` | string |  |  |
| `documentDate` | string |  |  |
| `documentNumber` | string |  | The supplier's own document number. |
| `amountIncVat` | integer |  | GROSS, VAT included. Israeli prices include VAT. Integer agorot (₪1 = 100). |
| `vatAmount` | integer |  | The portion INSIDE the gross. Never add it to `amountIncVat`. Integer agorot (₪1 = 100). |
| `deductibleVatBp` | integer |  | How much of the VAT is deductible, in basis points. 10000 = all of it. |
| `currency` | string |  | Currency of `amountIncVat`, ISO 4217. Always ILS for what the ledger records. |
| `docAmount` | integer |  | For a document in another currency: its own gross, in that currency's minor unit (cents). Null for a shekel document. |
| `docCurrency` | string |  | ISO 4217 code of `docAmount`. Null for a shekel document. |
| `fxRate` | number |  | ILS per unit of `docCurrency` used to derive `amountIncVat`. Evidence, never recomputed. |
| `categoryKey` | string |  | Ledger category. |
| `fileId` | string |  | Attached receipt image or PDF. |
| `extracted` | OcrExtraction |  | What the vision model read off the receipt. Advisory: the operator confirms before recording. |
| `createdAt` | string |  |  |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `expense` | Expense | **required** | The purchase side of the ledger. A recorded expense is immutable; correct it with a storno. |

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

## Examples

### cURL

```bash
curl -X PATCH "$BASE/businesses/$BID/expenses/$DOC_ID" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "string",
    "status": "issued"
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/expenses/${DOC_ID}`, {
  method: 'PATCH',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "id": "string",
    "status": "issued"
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.patch(
    f"{BASE}/businesses/{BID}/expenses/{DOC_ID}",
    headers={"X-Api-Key": KEY},
    json={
      "id": "string",
      "status": "issued"
    },
)
data = res.json()
```