# POST /api/v1/reconciliations

> Create reconciliation

- **Tag:** reconciliations
- **Operation ID:** `create_reconciliation`

## Description

Create a new bank reconciliation (with S3 key).

Use this endpoint if you've already uploaded the statement to S3.
For direct file upload, use POST /reconciliations/upload instead.

**Request Body:**
- `ledger_id`: UUID of ledger to reconcile against (required)
- `statement_s3_key`: S3 key of uploaded bank statement (required)
- `start_date`: Statement period start date in ISO 8601 format (required)
- `end_date`: Statement period end date in ISO 8601 format (required)
- `statement_filename`: Original filename (optional)
- `opening_balance`: Opening balance in cents (optional)
- `closing_balance`: Closing balance in cents (optional)
- `auto_start`: Auto-start processing workflow (optional, defaults to true)

**Note:** The workflow will:
1. Parse the bank statement (PDF, CSV, Excel supported)
2. Fetch ledger transactions for the period
3. Run AI matching to suggest matches
4. Store results for review

**Returns:** Created reconciliation with status and task ID.

## Authentication

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

## Request body

Schema: `ReconciliationCreateRequest`

- `ledger_id` (string · required) — ID of ledger to reconcile against
- `source_type` (string) — Reconciliation source: 'plaid' (synced transactions) or 'manual' (uploaded statement)
- `statement_s3_key` (string) — S3 key of uploaded bank statement (required for manual source)
- `start_date` (string · date-time · required) — Statement period start date
- `end_date` (string · date-time · required) — Statement period end date
- `statement_filename` (string) — Original filename
- `opening_balance` (integer) — Opening balance in cents
- `closing_balance` (integer) — Closing balance in cents
- `auto_start` (boolean) — Auto-start processing workflow

## Example request

```json
{
  "closing_balance": 1487500,
  "end_date": "2026-01-31T23:59:59Z",
  "ledger_id": "0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f10",
  "opening_balance": 1250000,
  "source_type": "plaid",
  "start_date": "2026-01-01T00:00:00Z"
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_CreateReconciliationResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (CreateReconciliationResponse)

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/reconciliations' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "closing_balance": 1487500,
  "end_date": "2026-01-31T23:59:59Z",
  "ledger_id": "0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f10",
  "opening_balance": 1250000,
  "source_type": "plaid",
  "start_date": "2026-01-01T00:00:00Z"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/reconciliations', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "closing_balance": 1487500,
  "end_date": "2026-01-31T23:59:59Z",
  "ledger_id": "0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f10",
  "opening_balance": 1250000,
  "source_type": "plaid",
  "start_date": "2026-01-01T00:00:00Z"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'closing_balance': 1487500,
 'end_date': '2026-01-31T23:59:59Z',
 'ledger_id': '0192a4f0-1b2c-7d3e-8f4a-5b6c7d8e9f10',
 'opening_balance': 1250000,
 'source_type': 'plaid',
 'start_date': '2026-01-01T00:00:00Z'}

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

## See also

- HTML version: https://www.ondayzero.com/docs/reference/reconciliations/create-reconciliation
- OpenAPI slice: https://www.ondayzero.com/docs/reference/reconciliations/create-reconciliation/openapi.json
- Other endpoints in **reconciliations**: https://www.ondayzero.com/docs/reference/reconciliations (markdown bundle: https://www.ondayzero.com/docs/reference/reconciliations.md, OpenAPI: https://www.ondayzero.com/docs/reference/reconciliations/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
