Add document line
add_document_lineAdd ONE new line to an EXISTING document (invoice, quote, bill and so on); to create the document itself use save_document, and to change a line already on it use update_document_item.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Line item id. Required on update_document_item; omit on add_document_line. | |
| cost | No | Unit cost (for margin / cost-of-sales), in :costcurrency. | |
| name | No | Line item name / title. | |
| sort | No | Display order of the line within the document (ascending). | |
| unit | No | Unit label for the quantity (e.g. "hours", "kg"). | |
| price | No | Unit price (per-unit selling price) in the document currency. | |
| amount | No | Line total (unit price × quantity), usually derived from :price × :quantity. Accepts a number or a numeric string. | |
| expense | No | Pass "$delete" to unlink the expense this line recovers; the line keeps its name, account and amount. Rebilling is add-only, so any other value is refused. | |
| product | No | Id of a catalog product to link this line to. | |
| variant | No | Id of a catalog product variant to link this line to. | |
| quantity | No | Number of units. Accepts a number or a numeric string. | |
| accountid | No | Per-line chart-of-accounts / expense-category id; bills split cost by category at accrual (see list_accounts). | |
| expenseid | No | Recover this expense's cost on a sales invoice, order or pro-forma (quinvoice or contract id). The expense is copied onto the line once: its name, its category account (the line credits that account, not Sales; an uncategorised expense books to the document's income account, Sales by default) and its amount. A VAT-registered business bills the net amount plus its own output VAT; otherwise the gross amount, untaxed. Later edits to the expense do not change the line. Recovering an expense that is already on a live document is allowed: the response's billedon lists the live documents that already recovered it before this add (this document too, when it is already on another of its lines), so the caller can warn. | |
| quinvoice | No | Id of the parent document (invoice, quote, bill, etc.) this line belongs to. | |
| responseid | No | Internal: correlation id used to return the updated entity to the frontend; omit. | |
| description | No | Line item description. | |
| costcurrency | No | ISO 4217 currency of :cost, when it differs from the document currency. | |
| baseupdatedat | No | Optimistic-concurrency token: the line's last-known updatedat (epoch number or ISO string). A stale value is rejected; omit to skip the check. |