Import Historical Purchase Orders
import_historical_purchase_ordersImport HISTORICAL purchase orders (already received in a previous system). receivedDate − orderDate becomes the OBSERVED LEAD TIME the reorder engine reads (POs from the last 12 months count; it needs at least 3 per item to beat the vendor default), so spread real dates rather than inventing them. Also seeds the purchasing graph: vendors are created by name (new ones get a default lead time from the batch average), unknown items are created costed from their PO line, ItemSupplier vendor-terms links (with MOQ) are created per (item, vendor) pair, and items without a default vendor get one. Never touches inventory — use set_inventory_levels for opening stock. Idempotent: POs whose number already exists are skipped, so retrying or chunking is safe. Max 500 orders per call. 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 (PO 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.
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_purchase_orders"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orders | Yes | The historical purchase orders to import (max 500 per call). | |
| 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. | |
| 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. | |
| warehouseId | No | Optional destination warehouse id (GUID); left unset on the imported POs when omitted (lead-time math does not use it). | |
| 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. | |
| supplierAliases | No | Optional vendor-name aliases to resolve spelling inconsistencies before import. Keys are variant names found in the data, values are the canonical name to use. Preview surfaces vendorCollisions — use them to build this map, then re-preview or commit with the aliases applied. | |
| createMissingItems | No | Create items that the POs reference but the tenant doesn't have yet (default true). Vendors and vendor links are always seeded. |
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 | ||
| failureDetails | No | ||
| idempotencyKey | No | ||
| previewReceipt | No | ||
| idempotentReplay | No | ||
| suppliersCreated | No | ||
| projectionsPending | No | ||
| defaultSuppliersSet | No | ||
| importedPurchaseOrderIds | No | ||
| itemSupplierLinksCreated | No | ||
| itemsWithSeveralSuppliers | No |