Skip to main content
Glama

Create Sales Order

create_sales_order

Create a LIVE customer SALES ORDER through the same lifecycle the Sales Orders page uses: it gets a document number, price-book pricing, tax and totals, and (when submitted) reserves stock and appears in picking. Use this for a real, open order to fulfil; use import_historical_sales_orders only for already-completed history and push_external_sales_orders only for orders fulfilled at an External warehouse. Give the store (storeId from list_warehouses' stores[].storeId — or warehouseId when that warehouse has exactly one store), the customer (customerId, customerEmail, or customerName — an unmatched name is kept as free text like the UI allows), and the lines (each itemSku, itemUpc or itemId plus a quantity; unitPrice optional — omit it to price from the price book). submit=false (default) leaves an editable draft (status "created", no reservations); submit=true issues it, which reserves stock and lands it in "pending" for picking — or in "waitingApproval" when the tenant's sales-approval flow is on. A draft is not checked against stock, so a future order (set requestedShipDate) can be recorded before the stock exists: a shortfall is returned as a warning. Submitting refuses quantities above available stock for items that do not allow backorders, exactly as the UI's Issue does. A client-pinned token only resolves its own client's items and stamps the order to that client; an operator token on a 3PL tenant must pass clientId. Max 500 lines per call.

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": {
      "lines": "<lines>"
    },
    "name": "create_sales_order"
  }
}

Input Schema

NameRequiredDescriptionDefault
noteNoOptional customer-facing note.
linesYesThe lines to sell (max 500). Each names an item and a quantity.
submitNofalse (default) = leave an editable draft (status "created", no stock reserved). true = also submit it: reserves stock and moves it to "pending" for picking, or to "waitingApproval" when the tenant's sales-approval flow is on.
previewNoStep 1 of the required two-step write: set true to validate and receive a structured preview plus a single-use previewReceipt. Nothing is created until the commit call.
storeIdNoStore id (GUID) the order belongs to — from list_warehouses' stores[].storeId (NOT the warehouse id). Provide storeId or warehouseId.
clientIdNoOptional 3PL client id (GUID) to stamp the order to. Required for an operator (unpinned) token on a 3PL tenant; refused when it differs from a pinned token's client.
orderDateNoOptional order (demand) date, ISO 8601. Omit to date the order now. A bare date is that calendar day in the tenant's time zone.
customerIdNoCustomer id (GUID). Provide one of customerId, customerEmail, customerName.
warehouseIdNoWarehouse id (GUID) to fulfil from — accepted instead of storeId when the warehouse has exactly one store.
customerNameNoCustomer name — resolved to the customer record with that exact name; when none matches it is recorded as free text on the order (no customer record is created).
internalNoteNoOptional internal note (never shown to the customer).
customerEmailNoCustomer email — resolved to the customer record with that email (exact match).
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.
requestedShipDateNoOptional date the customer asked the order to ship, YYYY-MM-DD on the tenant's calendar (a wholesale or pre-book date). While the order is open its units count as demand on that date in the stock projection and reorder timing.
scheduledPickupAtNoOptional scheduled pickup/delivery date-time (ISO 8601).
customerPurchaseOrderNoOptional customer purchase-order reference recorded on the order.

Output Schema

NameRequiredDescriptionDefault
okNo
numberNo
statusNo
previewNo
storeIdNo
clientIdNo
warningsNo
expiresAtNo
lineCountNo
submittedNo
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.8/5.0
Behavior5/5

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

Goes well beyond the supplied annotations (readOnlyHint=false, destructiveHint=false, idempotentHint=false) by disclosing what submit actually does (reserves stock, moves to "pending" or "waitingApproval"), that drafts are not stock-checked and return shortfalls as warnings, that issue-time refusals mirror the UI, and the 500-line cap. Token-scoping consequences (pinned client vs operator token needing clientId on a 3PL tenant) are non-obvious behavior an agent could not infer from the annotations.

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 sibling exclusions, then moves to required inputs and then behavioral branches — a sensible order. It is a single long paragraph, though, and a few clauses (e.g., restating unitPrice pricing and the customerName free-text rule) repeat 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?

An output schema exists and the input schema is fully documented, so the description needn't cover return values. For a 17-parameter mutation on a 3PL/tenant-scoped system, the description covers the material risks: draft vs submit semantics, stock reservation, approval routing, token scoping, and volume limits.

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 schema already documents all 17 parameters and the baseline would be 3. The description still adds real routing value: it identifies storeId as coming from list_warehouses' stores[] rather than the warehouse id, frames the customer trio as alternatives including the free-text fallback for unmatched names, and states that omitting unitPrice prices from the price book.

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?

Opens with a specific verb+resource ("Create a LIVE customer SALES ORDER") and immediately scopes it to the same lifecycle the Sales Orders page uses. It explicitly names and rules out the two nearest siblings, import_historical_sales_orders and push_external_sales_orders, so an agent can discriminate without opening any schema.

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

Usage Guidelines5/5

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

Gives explicit when-to-use ("a real, open order to fulfil") and when-not (historical imports, External-warehouse pushes), plus inline decision rules for submit=false vs submit=true and draft-vs-issue stock checking. It also states the prerequisite source for storeId (list_warehouses' stores[].storeId) rather than leaving the agent to guess.

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