# Mark an expense paid or waiting

`PUT /businesses/{bid}/expenses/{id}/payment`

Requires the `expenses` scope.

Follow-up of what is still owed to suppliers. Works on a draft and on a recorded expense alike, because it is kept beside the ledger row and changes nothing in it. `paid: true` takes `paidOn` (may be left out when the day is not known); `paid: false` takes an optional `dueOn`.

## Path parameters

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

## Body

| Field | Type | | Description |
|---|---|---|---|
| `paid` | boolean | **required** | True once paid; false while it waits. |
| `paidOn` | string |  | The day it was paid. |
| `dueOn` | string |  | The day it is due, while it waits. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `payment` | ExpensePayment | **required** | Whether the expense was paid, as the owner said it. Beside the ledger row, not part of it: free to change after the expense is recorded. Null on an expense nobody said anything about. |

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 PUT "$BASE/businesses/$BID/expenses/$DOC_ID/payment" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "paid": true
  }'
```
### Node

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

```python
import requests
res = requests.put(
    f"{BASE}/businesses/{BID}/expenses/{DOC_ID}/payment",
    headers={"X-Api-Key": KEY},
    json={
      "paid": True
    },
)
data = res.json()
```