Update Sales Order
update_sales_orderEdit an OPEN sales order the same way the Sales Orders page's Save does: add lines (addLines — itemSku/itemUpc/itemId + quantity, optional unitPrice), change lines (updateLines — lineId from get_sales_order plus a new quantity and/or unitPrice), remove lines (removeLineIds), and change the customer (customerId / customerEmail / customerName), the customer PO reference, the requested ship date, or the notes. Every field is preserve-on-omit; pass an empty string to clear a note, PO reference or requested ship date. Orders awaiting approval, shipping/shipped, completed or canceled cannot be edited (the UI locks them too). Reservations, pick lists, pricing, tax and totals are re-synced by the canonical update. A draft (status "created") is not refused for short stock — the shortfall is a warning, and issuing the draft is refused until the stock is there. The preview returns the per-field old→new diff and the resulting line set, and its receipt is bound to the order's current version — an edit landing in between rejects the commit. A client-pinned token only sees its own client's orders and items. 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": {
"salesOrderId": "<salesOrderId>"
},
"name": "update_sales_order"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | New customer-facing note; empty string clears it. | |
| preview | No | Step 1 of the required two-step write: set true to validate and receive the old→new diff plus a single-use previewReceipt. Nothing changes until the commit call. | |
| addLines | No | Lines to add (each itemSku/itemUpc/itemId + quantity, optional unitPrice/uomId). | |
| clientId | No | Optional 3PL client id (GUID) to scope the lookup to; refused when it differs from a pinned token's client. | |
| customerId | No | Change the customer by id (GUID). Provide at most one of customerId, customerEmail, customerName. | |
| updateLines | No | Existing lines to change, addressed by lineId (from get_sales_order). | |
| customerName | No | Change the customer by exact name; an unmatched name is recorded as free text. | |
| internalNote | No | New internal note; empty string clears it. | |
| salesOrderId | Yes | The sales order id (GUID) to edit. | |
| customerEmail | No | Change the customer by email (exact match to a customer record). | |
| removeLineIds | No | Existing line ids (GUIDs, from get_sales_order) to remove. | |
| 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. | |
| requestedShipDate | No | New date the customer asked the order to ship, YYYY-MM-DD on the tenant's calendar; empty string clears it. | |
| customerPurchaseOrder | No | New customer purchase-order reference; empty string clears it. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| number | No | ||
| status | No | ||
| preview | No | ||
| storeId | No | ||
| clientId | No | ||
| warnings | No | ||
| expiresAt | No | ||
| lineCount | No | ||
| customerId | No | ||
| totalAmount | No | ||
| actionItemId | No | ||
| confirmation | No | ||
| customerName | No | ||
| salesOrderId | No | ||
| correlationId | No | ||
| approvalResult | No | ||
| idempotencyKey | No | ||
| previewReceipt | No | ||
| approvalRequired | No | ||
| approvalRuleName | No | ||
| idempotentReplay | No |