Skip to main content
Glama

Update Sales Order

update_sales_order
Destructive

Edit 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

NameRequiredDescriptionDefault
noteNoNew customer-facing note; empty string clears it.
previewNoStep 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.
addLinesNoLines to add (each itemSku/itemUpc/itemId + quantity, optional unitPrice/uomId).
clientIdNoOptional 3PL client id (GUID) to scope the lookup to; refused when it differs from a pinned token's client.
customerIdNoChange the customer by id (GUID). Provide at most one of customerId, customerEmail, customerName.
updateLinesNoExisting lines to change, addressed by lineId (from get_sales_order).
customerNameNoChange the customer by exact name; an unmatched name is recorded as free text.
internalNoteNoNew internal note; empty string clears it.
salesOrderIdYesThe sales order id (GUID) to edit.
customerEmailNoChange the customer by email (exact match to a customer record).
removeLineIdsNoExisting line ids (GUIDs, from get_sales_order) to remove.
idempotencyKeyNoCaller-generated idempotency key; required with previewReceipt to commit.
previewReceiptNoStep 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.
requestedShipDateNoNew date the customer asked the order to ship, YYYY-MM-DD on the tenant's calendar; empty string clears it.
customerPurchaseOrderNoNew customer purchase-order reference; empty string clears it.

Output Schema

NameRequiredDescriptionDefault
okNo
numberNo
statusNo
previewNo
storeIdNo
clientIdNo
warningsNo
expiresAtNo
lineCountNo
customerIdNo
totalAmountNo
actionItemIdNo
confirmationNo
customerNameNo
salesOrderIdNo
correlationIdNo
approvalResultNo
idempotencyKeyNo
previewReceiptNo
approvalRequiredNo
approvalRuleNameNo
idempotentReplayNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only flag destructiveHint=true and idempotentHint=false; the description goes well beyond by disclosing preserve-on-omit semantics, empty-string clearing, side effects (reservations, pick lists, pricing, tax and totals re-synced), draft short-stock warnings, version-bound preview receipts, client-token scoping, and the 500-line ceiling. What it does not spell out is the failure mode of a commit without a receipt beyond 'calls without it are refused' (which lives in the schema) and whether repeated commits without an idempotency key can double-apply.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and edit categories, then layered with constraints in a logical order; the alternative-value and clearing rules are stated once up front rather than scattered. It is dense to the point of being a single long block, and some clauses (empty string to clear notes/PO/ship date) restate what the schema already says.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 15-parameter mutation with an output schema, this covers the decision-critical facts: editable statuses, field-preservation rules, re-sync side effects, version/concurrency behavior, tenancy scoping, and the line-count cap. Return values are handled by the output schema, so nothing essential is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, and the description earns an extra point by stating cross-field rules and cross-tool provenance ('lineId from get_sales_order', 'itemSku/itemUpc/itemId + quantity'), plus the global preserve-on-omit and empty-string-clears conventions. Most per-field detail, however, is already duplicated in the schema property descriptions, so the added value is modest rather than decisive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Edit an OPEN sales order'), enumerates the exact edits offered (addLines, updateLines, removeLineIds, customer, PO, ship date, notes), and anchors behavior to the Sales Orders page Save so the agent knows the exact semantic model. It is clearly distinct from get_sales_order, which it cites as the source of lineId values.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-not conditions ('Orders awaiting approval, shipping/shipped, completed or canceled cannot be edited') and mutual-exclusion guidance ('Provide at most one of customerId, customerEmail, customerName' in the schema). It implies the preview→commit sequence but never plainly states in the description that a preview call is mandatory before the commit call, which is the single biggest routing gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources