# POST /api/v1/invoices/batch

> Batch create invoices

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

## Description

Create invoices for multiple customers in one action, optionally sweeping delayed charges.

## Authentication

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

## Request body

Schema: `BatchInvoiceRequest`

- `items` (array · BatchInvoiceItem · required) → `BatchInvoiceItem` — List of invoices to create
  - `customer_id` (string · required) — Customer ID
  - `line_items` (array · BatchInvoiceLineItem · required) — Line items
  - `due_date` (string · required) — Due date YYYY-MM-DD
  - `description` (string) — Invoice description
- `include_delayed_charges` (boolean) — If true, sweep pending delayed charges for each customer into their invoice
- `finalize` (boolean) — Auto-finalize invoices after creation

## Responses

### 201 — Successful Response

### 400 — Bad Request - Invalid input

### 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/invoices/batch' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "items": []
}'
```

### JavaScript

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

### Python

```python
import httpx

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

payload = {
  "items": []
}

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

## See also

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