# Create and record in one call

`POST /businesses/{bid}/expenses/record`

Requires the `expenses` scope.

A complete receipt in hand and no draft to keep: the same `input` the record step takes, recorded in one round-trip. Idempotent on the key.

## Path parameters

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

## Headers

| Name | Type | | Description |
|---|---|---|---|
| `Idempotency-Key` | string |  | Your own stable id for this call. A retry returns the same row with `deduped: true` instead of creating a duplicate. Interchangeable with `externalRef` in the body. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `input` | object | **required** | Same fields as creating an expense. |

## Response

`201`: `{ "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 POST "$BASE/businesses/$BID/expenses/record" \
  -H "X-Api-Key: $KEY"
```
### Node

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