# POST /api/v1/invoices

> Create invoice

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

## Description

Create a new invoice for a customer. Optionally include 'recurring' config to also create a recurring template.

## Authentication

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

## Request body

Schema: `InvoiceCreateRequest`

- `customer_id` (string · required) — UUID of the customer to invoice.
- `currency` (string) — Currency for the invoice (USD, CAD, AUD, EUR, or GBP). Defaults to business default.
- `line_items` (array · LineItemRequest · required) → `LineItemRequest` — Line items (at least one required). Can be variant-linked or custom.
  - `variant_id` (string) — UUID of product variant. Omit or use 'custom' for manual line items.
  - `quantity` (integer) — Quantity ordered. Defaults to 1 for custom items.
  - `description` (string) — Line item description (required for custom items).
  - `unit_price` (integer) — Price per unit in cents. Required for custom items. For variant-linked items this is an OPTIONAL override - if omitted, the current catalog price is used; if provided, the catalog price is ignored for this invoice. The override is snapshotted onto the invoice line item.
  - `amount` (integer) — Total amount in cents. Deprecated for custom items - use unit_price instead. For backward compatibility, if unit_price is not set, amount is treated as unit_price.
  - `location_id` (string) — Optional warehouse UUID to deduct this line from. Overrides the invoice's `fulfillment_location_id` and the business default. Ignored for custom (non-variant) lines.
- `due_date` (string · required) — Payment due date in YYYY-MM-DD format.
- `issue_date` (string) — Optional 'Date of issue' to display on the invoice in YYYY-MM-DD format. Use this to backdate an invoice. When set, it replaces the system-generated issue date on the invoice PDF and receipt.
- `description` (string) — Optional invoice description or notes.
- `fulfillment_location_id` (string) — Default warehouse UUID for inventory deductions when the invoice is delivered. Per-line `location_id` overrides this.
- `project_id` (string) — Optional UUID of a project (job) to link this invoice to. When the invoice is finalized, its revenue and COGS are attributed to this project for profitability reporting.
- `recurring` (InvoiceRecurringConfig) — If provided, creates a recurring template for this invoice.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_InvoiceResponse_`

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

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

### JavaScript

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

### Python

```python
import httpx

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

payload = {
  "customer_id": "string",
  "line_items": [],
  "due_date": "string"
}

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

## See also

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