Update Purchase Order Lines
update_purchase_order_linesEdit the lines of a DRAFT purchase order (status created) the way the Purchase Orders page's Save does: add lines (addLines — itemSku or itemId + quantity, optional unitCost; an omitted cost is priced from the vendor's price book, then the item's catalog cost, then its last purchase), change lines (updateLines — the line's id or its SKU, plus a new quantity and/or unitCost), and remove lines (removeLineIds — line ids, or SKUs on exactly one line). Lines you do not name stay as they are. Line ids come from get_purchase_order_receiving. An order that was already issued, is awaiting approval or is further along cannot be edited here. The preview lists the resulting lines, what is added, changed and removed, and the new total; its receipt is bound to the order's current state, so an edit landing in between rejects the commit. Saving gives every line a new id. Max 500 resulting lines.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"purchaseOrder": "<purchaseOrder>"
},
"name": "update_purchase_order_lines"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| preview | No | Step 1 of the required two-step write: set true to validate and receive the resulting lines plus a single-use previewReceipt. Nothing changes until the commit call. | |
| addLines | No | Lines to add (each itemSku or itemId + quantity, optional unitCost/expense). | |
| updateLines | No | Existing lines to change, by line id or SKU. | |
| purchaseOrder | Yes | Purchase order id (GUID) or document number (e.g. PO-1042). | |
| removeLineIds | No | Existing lines to remove: line ids (GUIDs) or SKUs on exactly one line. | |
| idempotencyKey | No | Caller-generated idempotency key; required with previewReceipt to commit. | |
| previewReceipt | No | Step 2 of the required two-step write: the receipt returned by the preview call. Supply together with a fresh idempotencyKey to commit; calls without it are refused. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| number | No | ||
| status | No | ||
| preview | No | ||
| warnings | No | ||
| expiresAt | No | ||
| lineCount | No | ||
| linesAdded | No | ||
| totalAmount | No | ||
| actionItemId | No | ||
| confirmation | No | ||
| linesChanged | No | ||
| linesRemoved | No | ||
| correlationId | No | ||
| totalQuantity | No | ||
| approvalResult | No | ||
| idempotencyKey | No | ||
| previewReceipt | No | ||
| purchaseOrderId | No | ||
| approvalRequired | No | ||
| approvalRuleName | No | ||
| idempotentReplay | No |