Skip to main content

Create Sales Invoice

POST 

/api/sales-invoices

Create a sales invoice for a sales order — as a draft, or issued straight away with issue: true (issuing also needs the sales_invoices.issue permission).

Required scope: orders:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Body

  • sales_order_id (integer, required)
  • source (required): shipments (bill the listed fulfillment_ids), lines (bill the listed lines), remaining (everything still billable), deposit (a deposit invoice billed up front; needs deposit_amount or deposit_percent)
  • fulfillment_ids[] (integers, required when source=shipments)
  • lines[]: product lines {sales_order_line_id, quantity} (quantity ≥ 0, ≤ what is billable) and fee lines {financial_line_id, amount} (≤ the fee's uninvoiced amount)
  • deposit_amount (number > 0, for source=deposit): the deposit in the order's currency, at most the order's uninvoiced total
  • deposit_percent (number, greater than 0 and at most 100, for source=deposit): the deposit as a percentage of the order's uninvoiced total; used instead of deposit_amount
  • invoice_date (Y-m-d, optional; must be in an open accounting period)
  • payment_term_id (optional; defaults to the order's term)
  • due_date (Y-m-d, optional manual override, not before invoice_date)
  • notes, terms_text (printed on the PDF, optional)
  • issue (boolean, default false)
  • invoice_ahead (boolean, default false): bill units a per-shipment order has not shipped yet; needs the sales_invoices.invoice_ahead permission

Over-billing is refused per line, e.g. "Quantity 40 exceeds 36 shipped and uninvoiced for ZS-HBK-RED." An empty invoice is refused with "Add at least one line with a quantity." Invoice numbers are assigned when the invoice is issued.

Deposits: a deposit invoice (kind deposit) carries one line, Deposit 30% on SO-10482 (or Deposit on SO-10482 for a fixed amount). Once it is issued, every later invoice on the order gets a negative Less deposit line that deducts it, until the deposit is used up. Deposits are available on orders invoiced per shipment or manually — not on per-order or consolidated orders (see supports_deposit on Get Sales Order Invoice Preview).

Requires the orders:write scope and the sales_invoices.create permission.

Request​

Responses​

Created

Response Headers
    Content-Type