# POST /api/v1/invoices/match

> Trigger payment matching

- **Tag:** invoices
- **Operation ID:** `trigger_matching_api_v1_invoices_match_post`

## Description

Run the payment matching engine to find likely bank transactions for open invoices. When auto_match is true, high-confidence matches (>= 0.85) are auto-linked; otherwise all matches are surfaced as suggestions.

## Authentication

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

## Responses

### 201 — Successful Response

Schema: `MatchTriggerResponse`

- `suggestions_created` (integer · required) — Number of new suggestions persisted.
- `auto_linked` (integer · required) — Number of high-confidence matches auto-linked.
- `total_candidates` (integer · required) — Total candidates evaluated by the engine.

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 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/invoices/match' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d ''
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/invoices/match', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {}

response = httpx.post("https://api.ondayzero.com/api/v1/invoices/match", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/invoices/trigger-matching
- OpenAPI slice: https://www.ondayzero.com/docs/reference/invoices/trigger-matching/openapi.json
- Other endpoints in **invoices**: https://www.ondayzero.com/docs/reference/invoices
