Replace all the lines of a document

PUT/api/{parent}/{id}/items

Idempotent bulk set. Every existing line of the document is removed and the supplied set is written in its place, then the document totals are recalculated. The whole payload is validated before anything is written and the write runs in a transaction, so a single bad line leaves the document untouched. An empty array is rejected with a 400 rather than clearing the document; remove lines one by one with the DELETE endpoint.

Headers

FieldTypeDescription
authtoken String Authentication token, generated from admin area

Parameters

FieldTypeDescription
parent String Document type owning the lines
id Number Parent document unique ID
items Object[] Mandatory non empty list of lines, in the same shape the GET returns
items.title String Mandatory line title. A description is accepted instead.
items.description String optional Optional line description
items.quantity Number Mandatory quantity, numeric
items.rate Number Mandatory unit rate, numeric
items.unit_type String optional Optional unit type, maximum 20 characters
items.sort Number optional Optional display order. Defaults to the array position.
items.item_id Number optional Optional items library ID
items.taxable Number optional Invoices only. 1 (default) or 0.
curl -X PUT "https://yoursite.com/api/1/123/items" \
  -H "authtoken: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "items": "...", "items.title": "...", "items.quantity": "...", "items.rate": "..." }'

Success-Response:

HTTP/1.1 200 OK
{
  "status": 200,
  "messages": {"success": "The record has been saved."},
  "saved": 2,
  "items": [
    {"id": 12, "title": "Design work", "description": "", "quantity": 2, "unit_type": "hours", "rate": 100, "total": 200, "sort": 0, "item_id": 0, "taxable": 1}
  ]
}
MethodPUT
Path/api/{parent}/{id}/items
GroupLine Items
Sincev1.0.0
Defined inRestApi/Controllers/LineItemsController.php