upsert_sales_order
Create or update a sales order: partial updates preserve unmentioned fields and lines, merge item patches, delete listed lines; omit id to create. Legacy high-risk write; prefer set_sales_order.
Instructions
[LEGACY IMMEDIATE WRITE — HIGH RISK: BYPASSES INFLOW_ENABLE_SAFE_WRITES] Use set_sales_order instead. Create a new sales order or update an existing one. When id is provided, performs a partial update: unmentioned header fields and line items are preserved, item patches are merged into existing lines by id (or unambiguous productId), and lines listed in deleteLineIds are removed. Without id, creates a new order from the provided fields.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Sales order ID (required for updates) | |
| items | No | Order line items. For updates, each item patches an existing line when it has a matching `id` (salesOrderLineId) or unambiguous `productId`; items without a match are appended as new lines. Unmentioned existing lines are preserved. | |
| remarks | No | Order remarks/notes | |
| orderDate | No | Order date (ISO format) | |
| timestamp | No | Timestamp for concurrency control | |
| customerId | No | Customer ID (required for creates; preserved from the existing order on updates) | |
| locationId | No | Location/warehouse ID | |
| orderNumber | No | Order number | |
| currencyCode | No | Currency code (e.g., USD) | |
| customFields | No | Custom field values | |
| requiredDate | No | Required/ship date (ISO format) | |
| deleteLineIds | No | salesOrderLineId values to remove from the order during an update. | |
| billingAddress | No | Billing address | |
| paymentTermsId | No | Payment terms ID | |
| taxingSchemeId | No | Taxing scheme ID | |
| nonCustomerCost | No | Non-customer cost. Accepts a plain number (e.g. 12.34) or the API money object { value: "12.34000", isPercent: false }. Normalised to the money object before sending, because the Cloud API rejects a bare number with HTTP 422. | |
| pricingSchemeId | No | Pricing scheme ID | |
| shippingAddress | No | Shipping address |