# POST /api/v1/invoices

> Create invoice

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

## 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.
  - `catalog_item_id` (string) — UUID of a Products & Services catalog item (Books). Mutually exclusive with a real variant_id. When set, description and unit_price default from the catalog item; provide unit_price to override the catalog price for this invoice.
  - `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. Negative only on a custom item, for a discount or credit (e.g. -12000 for a $120.00 discount); variant and catalog lines must be 0 or more, and the invoice's lines may not add up to less than 0.
  - `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.
  - `note` (string) — Optional free-text note for this line item, shown alongside the description (e.g. internal context or a customer-facing clarification). Not used in pricing calculations.
  - `deferred` (boolean) — Tag this line's revenue as deferred. Drives the default amount suggested when a deferral is created for the invoice (see `suggested_deferred_amount_cents` on the deferral-status response) - it does not defer anything by itself and has no effect once a deferral already exists.
- `due_date` (string · required) — Payment due date in YYYY-MM-DD format.
- `issue_date` (string) — Optional 'Date of issue' in YYYY-MM-DD format — the date the invoice is dated and reported under. Backdates the invoice: it becomes the invoice's date in the app, the date its finalization journal entry posts on, and the issue date on the PDF and receipt in place of the system-generated one. Also accepted as 'invoice_date', which is what the update endpoint calls it.
- `invoice_number` (string) — Optional invoice number to use instead of the next one from the business's auto-numbering — e.g. the number this invoice already carries in the system it is being migrated from. Must be unique within the business.
- `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.
- `payment_term_id` (string) — Optional UUID of the payment term this invoice was issued under (Net 30, Due on Receipt ...). It is recorded for reference and reporting; `due_date` is still the date the invoice is actually due, so a due date you set yourself always wins over the term.
- `tax_exempt` (boolean) — True to charge no sales tax on this invoice even though the business has a default tax rate. Sales tax is worked out when the invoice is finalized.
- `recurring` (InvoiceRecurringConfig) — If provided, creates a recurring template for this invoice.
- `historical` (boolean) — Record an invoice that was already issued somewhere else, for backfilling books, rather than issuing a new one. The invoice is written locally as a draft and never reaches Stripe, so it cannot be sent to or charged to the customer, and no Stripe account is required. It also lifts the rule that a due date must be in the future — a historical invoice normally came due in the past. Pair it with `issue_date` and `invoice_number` to preserve the date and number the invoice carried in the old system.

## Example request

```json
{
  "customer_id": "019ab37c-c057-7000-8000-000000000001",
  "description": "January services",
  "due_date": "2024-02-15",
  "line_items": [
    {
      "quantity": 3,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    },
    {
      "amount": 2500,
      "description": "Rush delivery fee",
      "variant_id": "custom"
    }
  ]
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_InvoiceResponse_`

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

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

### 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/invoices' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "customer_id": "019ab37c-c057-7000-8000-000000000001",
  "description": "January services",
  "due_date": "2024-02-15",
  "line_items": [
    {
      "quantity": 3,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    },
    {
      "amount": 2500,
      "description": "Rush delivery fee",
      "variant_id": "custom"
    }
  ]
}'
```

### 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": "019ab37c-c057-7000-8000-000000000001",
  "description": "January services",
  "due_date": "2024-02-15",
  "line_items": [
    {
      "quantity": 3,
      "variant_id": "019ab37c-0a71-7000-8000-000000000001"
    },
    {
      "amount": 2500,
      "description": "Rush delivery fee",
      "variant_id": "custom"
    }
  ]
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'customer_id': '019ab37c-c057-7000-8000-000000000001',
 'description': 'January services',
 'due_date': '2024-02-15',
 'line_items': [{'quantity': 3,
                 'variant_id': '019ab37c-0a71-7000-8000-000000000001'},
                {'amount': 2500,
                 'description': 'Rush delivery fee',
                 'variant_id': 'custom'}]}

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 (markdown bundle: https://www.ondayzero.com/docs/reference/invoices.md, OpenAPI: https://www.ondayzero.com/docs/reference/invoices/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
