# POST /api/v1/invoices/bulk

> Bulk create invoices

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

## Description

Create multiple invoices from CSV data in a single request.

## Authentication

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

## Request body

Schema: `InvoiceBulkRequest`

- `s3_key` (string) — S3 key of the uploaded CSV file containing invoice data.
- `finalize` (boolean) — If true, immediately finalize all created invoices.
- `allow_duplicates` (boolean) — By default a row that matches an invoice a previous import already created (same customer, due date, total, description and line items) is skipped and reported under `duplicates`, so uploading the same file twice is safe. Set true to import those rows anyway — they are created without a fingerprint and will not be deduplicated against on future uploads.
- `historical` (boolean) — The file holds invoices that were already issued elsewhere — a books migration rather than new billing. Every row is written locally and none reach Stripe, even if the business has an account connected, so nothing can be sent to or charged to a customer. Past due dates are accepted, which they otherwise are not. Use the `invoice_date` and `invoice_number` columns to keep each invoice's original date and number.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_InvoiceBulkCreateResponse_`

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

### 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/bulk' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "s3_key": "string",
  "finalize": false,
  "allow_duplicates": false,
  "historical": false
}'
```

### JavaScript

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

### Python

```python
import httpx

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

payload = {
  "s3_key": "string",
  "finalize": false,
  "allow_duplicates": false,
  "historical": false
}

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

## See also

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