# POST /api/v1/inventory/accounts-payable/{bill_id}/three-way-match

> Recompute the three-way match for a bill

- **Tag:** inventory:accounts_payable
- **Operation ID:** `recompute_three_way_match_api_v1_inventory_accounts_payable__bill_id__three_way_match_post`

## Description

Forces a fresh PO -> Receipt -> Invoice comparison for the bill and writes the outcome onto `bill.match_status` and the variance columns. Idempotent.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `bill_id` (path, string, required)
- `qty_tolerance` (query, integer, optional) — Unit tolerance before a qty drift is flagged.
- `price_tolerance_cents` (query, integer, optional) — Cents tolerance before a price drift is flagged.
- `price_tolerance_pct` (query, number, optional) — Percent-of-PO-total tolerance (combined with cents floor).

## Responses

### 201 — Successful Response

Schema: `ThreeWayMatchResponse`

- `match_status` (string · required)
- `variance_qty` (integer)
- `variance_amount_cents` (integer)
- `reason` (string)
- `lines` (array · ThreeWayMatchLineDrift) → `ThreeWayMatchLineDrift`
  - `variant_id` (string · required)
  - `ordered_qty` (integer · required)
  - `received_qty` (integer · required)
  - `variance` (integer · required)

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/inventory/accounts-payable/{bill_id}/three-way-match' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/inventory/accounts-payable/{bill_id}/three-way-match', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
  },
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

response = httpx.post("https://api.ondayzero.com/api/v1/inventory/accounts-payable/{bill_id}/three-way-match", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/inventory-accounts-payable/recompute-three-way-match
- OpenAPI slice: https://www.ondayzero.com/docs/reference/inventory-accounts-payable/recompute-three-way-match/openapi.json
- Other endpoints in **inventory:accounts_payable**: https://www.ondayzero.com/docs/reference/inventory-accounts-payable
