Import Historical Sales Orders
import_historical_sales_ordersImport HISTORICAL sales orders (already fulfilled in a previous system). They feed demand velocity, forecasting, and reporting but never touch current inventory: no reservations, no pick lists, no notifications. Orders are written as completed+paid, dated from each order's orderDate (required). By default the import also seeds the catalog: items (by SKU/UPC), customers (by email/name), and UOMs referenced by the history are created when missing, so a fresh tenant can be populated from its order history alone. Idempotent: orders whose customerPurchaseOrder or orderNumber already exist are skipped, so retrying or chunking a large history is safe. Import no more than the latest 36 months: sales history establishes total item velocity, while customer fields preserve attribution and do not create separate forecasts. For reliable inline calls, prefer batches of 100 orders or fewer (500 is the hard ceiling), and pass the first result's importSessionId into later chunks. Operator (unpinned) credentials on 3PL tenants pass clientId to name the client the history belongs to. Requires the governed two-step protocol: call with preview=true to validate and receive a parse report (order count, would-create counts, sample) plus a single-use previewReceipt, then repeat the identical call with that previewReceipt and a fresh idempotencyKey to commit — a bare call is refused with PREVIEW_RECEIPT_REQUIRED. LARGE HISTORIES: for more than ~100 orders when a raw CSV/XLSX export is available, use create_import_session instead: the customer uploads the file directly and the server maps/validates/commits it without the rows ever entering your context. Every commit returns an importSessionId (rollback lineage): rollback_import_session undoes the whole import by that id, and passing the id back into later chunked calls keeps one history under one session so a single rollback undoes all of it.
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": {
"orders": "<orders>"
},
"name": "import_historical_sales_orders"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orders | Yes | The historical orders to import (prefer 100 or fewer per inline call; hard max 500). | |
| preview | No | Step 1 of the required two-step write: set true to validate and receive a structured preview plus a single-use previewReceipt. Nothing is imported until the commit call. | |
| storeId | No | Optional STORE id (GUID); the tenant's default store when omitted. Get store ids from list_warehouses (each warehouse row lists its stores with their storeId) — a warehouse id is not a store id, even though a warehouse's companion store shares its name. | |
| clientId | No | Operator (unpinned) credentials on 3PL tenants: the target client id (GUID) the imported history belongs to — get ids from list_clients. Client-pinned credentials omit this; the credential decides. | |
| 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. | |
| importSessionId | No | Optional: the importSessionId returned by an earlier chunk of this SAME history — joins this chunk to that session so ONE rollback_import_session call undoes the whole import. Omit on the first chunk; a new session is created and its id returned. | |
| createMissingEntities | No | Create items, customers, and UOMs that the orders reference but the tenant doesn't have yet (default true). When false, unknown SKUs become item-less text lines that are invisible to velocity/forecasting. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| errors | No | ||
| failed | No | ||
| preview | No | ||
| skipped | No | ||
| imported | No | ||
| warnings | No | ||
| expiresAt | No | ||
| uomsCreated | No | ||
| actionItemId | No | ||
| confirmation | No | ||
| itemsCreated | No | ||
| correlationId | No | ||
| approvalResult | No | ||
| idempotencyKey | No | ||
| previewReceipt | No | ||
| backtestSummary | No | ||
| importSessionId | No | ||
| customersCreated | No | ||
| idempotentReplay | No | ||
| importedOrderIds | No | ||
| backtestMedianMape | No | ||
| backtestPooledWape | No | ||
| projectionsPending | No |