# POST /api/v1/bills/payments/batch

> Split one transaction across multiple bills

- **Tag:** bills
- **Operation ID:** `create_bill_payments_batch`

## Description

Apply a single bank transaction to multiple bills and/or direct expense lines in one atomic request. Validates the total allocation against the transaction's remaining unallocated balance before creating any payments.

## Authentication

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

## Request body

Schema: `BillBatchPaymentRequest`

- `transaction_id` (string · required) — UUID of the bank transaction representing the payment.
- `allocations` (array · BillBatchPaymentAllocation) → `BillBatchPaymentAllocation` — Bill slices (0+). Each `bill_id` must be unique.
  - `bill_id` (string · required) — UUID of the bill receiving this slice of the transaction.
  - `amount` (integer · required) — Amount in cents to allocate to this bill. Must be > 0.
- `expense_lines` (array · BillBatchExpenseLine) → `BillBatchExpenseLine` — Optional expense lines for any remaining balance. Each line debits an expense ledger on the transaction's journal entry.
  - `ledger_id` (string · required) — UUID of the expense ledger account to debit.
  - `amount` (integer · required) — Amount in cents to categorize as expense. Must be > 0.
  - `description` (string) — Optional memo stored on the journal-entry line.
- `paid_on` (string · date-time) — Override payment date applied to every allocation. Defaults to the transaction datetime if omitted.
- `override_hold` (boolean) — Record the payment even though an allocated bill is on payment hold. Requires `override_reason`; both are written to the audit log.
- `override_reason` (string) — Why a held bill is being paid anyway (required with override_hold).

## Example request

```json
{
  "allocations": [
    {
      "amount": 50000,
      "bill_id": "019ab37c-b111-7000-8000-000000000001"
    },
    {
      "amount": 75000,
      "bill_id": "019ab37c-b111-7000-8000-000000000002"
    }
  ],
  "transaction_id": "019ab37c-7801-7000-8000-000000000001"
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_BillBatchPaymentResponse_`

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

### 400 — Bad Request - Invalid input

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.

### 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.

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

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/bills/payments/batch' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "allocations": [
    {
      "amount": 50000,
      "bill_id": "019ab37c-b111-7000-8000-000000000001"
    },
    {
      "amount": 75000,
      "bill_id": "019ab37c-b111-7000-8000-000000000002"
    }
  ],
  "transaction_id": "019ab37c-7801-7000-8000-000000000001"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/bills/payments/batch', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "allocations": [
    {
      "amount": 50000,
      "bill_id": "019ab37c-b111-7000-8000-000000000001"
    },
    {
      "amount": 75000,
      "bill_id": "019ab37c-b111-7000-8000-000000000002"
    }
  ],
  "transaction_id": "019ab37c-7801-7000-8000-000000000001"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'allocations': [{'amount': 50000,
                  'bill_id': '019ab37c-b111-7000-8000-000000000001'},
                 {'amount': 75000,
                  'bill_id': '019ab37c-b111-7000-8000-000000000002'}],
 'transaction_id': '019ab37c-7801-7000-8000-000000000001'}

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

## See also

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