Create the sales order for a service-order
Create the sales order for a service-order: one sale, billed to the service order's customer. The sale is an aggregate of the case rather than a copy of it, and it covers the items that are not yet billed to a live sales order — an item whose sales order has been cancelled returns to the sale. For each VAT code present among those items the sales order carries up to two aggregate lines, one for the items whose product is of type STOCK and one for every other item, each line present only when it has items behind it and priced at the sum of the items behind it. Each line lists the items behind it in serviceItems — the service number, name, SKU, quantity, serial number and what the case charges for each — and the receipts print them under the line with name, quantity, serial number and price: the PDF receipt, the invoice and the thermal till receipt. The items listed are what the case bills on that sales order now: when the sale is cancelled and the case is billed again, they move to the new sales order. The line's own price is what the customer pays, and a discount given on the line at the till is on the line, so the listed items add up to the line's price as the sale booked it, before any discount or change made to the line at the till. Hours registration takes no part in the sale. Each aggregate line is booked on the service sale product the platform links for its VAT code and kind: the goods product of a VAT code carries the line of its items whose product is of type STOCK, and the work-and-other product the line of its other items. A link is to a product, not to a SKU: a linked product's SKU and name are the tenant's own and may be anything. The platform fills the links that are missing, for every VAT code of the tenant's country, when the SERVICE_WORKSHOP extension is saved active — switched on, or saved while it is on; a save that switches it off fills nothing. A missing link is filled with the product under the SKU SERVICE-PARTS-{rate} or SERVICE-WORK-{rate}, and that product is created when there is none (see put-tenants-extensions-details for the SKU and the product). The line is booked like any line added at the till: the sale passes no VAT code, rate or name of its own, and the line takes the product's VAT code, that code's current rate and the product's name. The products the platform creates are named "Goods" and "Work and other" in the tenant's language whatever the rate. The sales order carries a note in the tenant's language that names the case: its service number, its service type and its title, and, when the coverage is INSURANCE_CLAIM and claimNumber is not empty, the claim number, so the insurer can match the invoice to its claim. It is the sales order's note, which the receipt and the invoice print. It is written when the sale is created and never rewritten, so a claim number entered on the case afterwards reaches the next sale a conversion creates, never one that already exists. The sale is billed to the service order's customer whatever the coverage. On an insurance claim the insurer, the claim number and the deductible the service order records are information: none of them changes who the sale is billed to or what it carries, and nothing is billed to the insurer. The conversion is refused with a conflict, writing nothing at all, when an item is billed under a VAT code that is not among the VAT codes of the tenant's country; when the service sale product link of an item's VAT code and kind is missing, which saving the SERVICE_WORKSHOP extension while it is on puts right by filling it; or when the linked product is not of type NO_STOCK with allowOrderSpecificCost true, or carries a VAT code other than the link's. It is refused with a 400 when every item on the case is already on a live sales order, there being nothing left to bill. The sales order is created CONFIRMED, in the one store the request body's description names, exactly as a sale confirmed at the till is: from then on it is an ordinary sale, whose one difference is its link to the service order it bills. The conversion is one transaction: a refusal writes nothing. The conversion is judged on one reading of the case, then takes the case's lock and reads it again before it writes. When what the conversion bills from changed in between — the customer; an item added or removed, an item's VAT code, product type, quantity, price, cost or sales order link, or a sales order an item is on cancelled — it is refused with a 409, writing nothing: convert again. This is judged after every refusal set out above, and before the refusals of the inter-store trade setup set out below, which are met only as the sale is confirmed. Because the sale is confirmed as the till confirms it, the tenant's inter-store trade setup can refuse the confirm — a payer that represents a store in another organization while trade across organizations is not allowed, the same store, another currency — and those refusals are answered as the sales module answers them, writing nothing. A 409 answers an insufficient quantity, a sale that is not coupled, a seller purchase order that is itself an inter-store purchase or cannot be reserved on, a buyer that has reserved or received goods, a buyer purchase order that is not open, a line priced 0 on a coupled sale, and a change to a coupled line a settled return has credited. A 400 answers a purchase order in a foreign currency, trade across organizations not allowed, inter-store trade not enabled, the same store on both sides, an invalid quantity, a product that does not match the purchase order line, a buyer purchase order that does not buy from the selling store and a sales order that does not belong to the store. A 404 answers a seller or a buyer purchase order line that is not found. This is a write on the case, so it belongs to the store that owns the service order: at any other store it is refused with a 403, where the case can be read but not worked on. A service order the tenant does not have answers 404.
Required permissions: SERVICE_ORDER
Access token recevied after user login with a deviceToken
Reference to a tenant.
^[A-Za-z0-9-_]+Reference to a Store.
^[A-Za-z0-9-_]+Reference to a service order
^[A-Za-z0-9-_]+The field sellerStoreUid is deprecated and no longer required. It decides the store the sales order is created in and is still honoured during the window; when it is omitted, the sales order is created in the store given in the path — the owning store — which is the only behavior once the field is removed after the announced deprecation window; see the deprecation log for the date. salesOrderUid is the uid the sale is created with. It is optional, and the platform generates a uid when it is left out.
^[A-Za-z0-9-_]*^[A-Za-z0-9-_]*Example response
The sales order a conversion of a service order created: the one sale, billed to the service order's customer, as post-serviceorders-orders sets out.
Conflict. An item on the case is billed under a VAT code that is not among the VAT codes of the tenant's country; the service sale product link of an item's VAT code and kind is missing; the linked product is not of type NO_STOCK with allowOrderSpecificCost true, or carries a VAT code other than the link's; the tenant's inter-store trade setup refuses the confirm of the sale with one of the refusals the sales module answers with a 409, as the description sets out; or the case changed between the reading the conversion was judged on and the lock it takes before writing, put right by converting again. Nothing is written.
POST /v2/tenants/{tenantUid}/stores/{storeUid}/serviceorders/{serviceOrderUid}/orders HTTP/1.1
Host: api.flowretail.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 24
{
"salesOrderUid": "text"
}{
"salesOrder": {
"createdAt": "2026-01-01T00:00:00.000Z",
"customerAddress": {
"address": "text",
"city": "text",
"companyName": "text",
"countryCode": "text",
"email": "text",
"firstname": "text",
"lastname": "text",
"mobile": "text",
"postalCode": "text",
"vatNumber": "text",
"displayName": "text"
},
"customerUid": "text",
"customerContact": {
"customerContactUid": "text",
"firstname": "text",
"lastname": "text",
"email": "text",
"mobile": "text",
"displayName": "text"
},
"deliveryState": "NOT_STARTED",
"externalIds": [
{
"key": "text",
"label": "text",
"value": "text",
"visibility": "INTERNAL"
}
],
"invoiceAddress": {
"address": "text",
"city": "text",
"companyName": "text",
"countryCode": "text",
"email": "text",
"mobile": "text",
"firstname": "text",
"lastname": "text",
"postalCode": "text",
"displayName": "text",
"customerAddressUid": "text"
},
"items": [
{
"actions": [
{
"comment": "text",
"createdAt": "2026-01-01T00:00:00.000Z",
"createdBy": "text",
"handlingActionUid": "text",
"handlingActionName": "text",
"handlingDescription": "text",
"handlingUid": "text",
"handlingName": "text",
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"lastModifiedBy": "text",
"orderHandlingActionUid": "text"
}
],
"allowedActions": [
"QUANTITY_SOLD"
],
"createdAt": "2026-01-01T00:00:00.000Z",
"discountReasonCode": "text",
"externalId": "text",
"externalOrderLinks": [
{
"orderId": "text",
"orderNumber": "text",
"orderItemId": "text",
"system": "text",
"type": "CREDIT"
}
],
"itemCost": 1,
"itemDiscountAmount": 1,
"itemDiscountPercentage": 1,
"itemGrossProfitAmount": 1,
"itemGrossProfitPercentage": 1,
"itemPrice": 1,
"itemVatAmount": 1,
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"ledgerNumber": "text",
"name": "text",
"note": "text",
"orderItemReference": "text",
"orderItemUid": "text",
"orderLinks": [
{
"orderUid": "text",
"orderItemUid": "text",
"orderNumber": "text",
"storeUid": "text",
"type": "CREDIT"
}
],
"originalItemPrice": 1,
"productUid": "text",
"productType": "STOCK",
"properties": [
{
"uid": "text",
"key": "text",
"value": "text"
}
],
"quantityCredited": 1,
"quantityDelivered": 1,
"quantityOrdered": 1,
"quantityReserved": 1,
"returnReasonCode": "text",
"returnReference": "text",
"serialnumber": "text",
"sku": "text",
"sortOrder": 1,
"tenantUserDisplayName": "text",
"tenantUserUid": "text",
"totalCost": 1,
"totalDiscountAmount": 1,
"totalGrossProfitAmount": 1,
"totalPrice": 1,
"totalVatAmount": 1,
"vatCodeUid": "text",
"warehouseUid": "text",
"warehouseName": "text",
"internalInfo": "text",
"productProperties": [
{
"productPropertyUid": "text",
"propertyName": "text",
"propertyOptionName": "text",
"propertyType": "TEXT",
"propertyText": "text",
"propertyUid": "text",
"propertyOptionUid": "text",
"required": true
}
],
"coverImage": {
"productMediaUid": "text",
"mainUrl": "text",
"thumbnailUrl": "text"
},
"deliveryUid": "text",
"compensationReasonCode": "text",
"orderReceiptUid": "text",
"allowDelivery": "YES",
"allowDeliveryFromDate": "2026-01-01T00:00:00.000Z",
"reservationType": "NONE",
"reservationDetails": {
"warehouse": {
"warehouseName": "text"
},
"purchaseOrder": {
"purchaseOrderUid": "text",
"purchaseOrderItemUid": "text",
"expectedDeliveryDate": "2026-01-01T00:00:00.000Z",
"purchaseOrderNumber": "text",
"quantityOrdered": 1,
"externalId": "text"
},
"receivement": {
"receivementUid": "text",
"receivementItemUid": "text",
"expectedArrival": "2026-01-01T00:00:00.000Z",
"expectedDispatch": "2026-01-01T00:00:00.000Z",
"quantity": 1,
"supplierOrderReference": "text",
"receivedAt": "2026-01-01T00:00:00.000Z"
},
"interStorePurchaseOrder": {
"storeUid": "text",
"storeName": "text",
"purchaseOrderUid": "text",
"purchaseOrderNumber": "text",
"purchaseOrderItemUid": "text"
},
"interStorePurchaseOrderReceivement": {
"receivementUid": "text",
"receivementItemUid": "text",
"expectedArrival": "2026-01-01T00:00:00.000Z",
"expectedDispatch": "2026-01-01T00:00:00.000Z",
"quantity": 1,
"supplierOrderReference": "text",
"receivedAt": "2026-01-01T00:00:00.000Z"
},
"purchaseRequest": {
"requestedAt": "2026-01-01T00:00:00.000Z",
"declinedAt": "2026-01-01T00:00:00.000Z"
}
},
"interStoreOrderReservationQuantity": 1,
"stockStatus": "IN_STOCK",
"quantityStock": 1,
"gtins": [
{
"gtin": "text",
"primary": true,
"type": "text"
}
],
"usesVatMarginScheme": true,
"serviceItems": [
{
"serviceOrderItemUid": "text",
"serviceOrderUid": "text",
"serviceNumber": "text",
"name": "text",
"sku": "text",
"quantity": 1,
"totalPrice": 1,
"serialNumber": "text"
}
]
}
],
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"interStorePurchaseOrder": {
"purchaseOrderUid": "text",
"purchaseNumber": "text",
"storeUid": "text",
"storeName": "text"
},
"note": "text",
"internalNote": "text",
"orderUid": "text",
"orderNumber": "text",
"orderDate": "2026-01-01T00:00:00.000Z",
"orderState": "OPEN",
"orderTotals": {
"costTotal": 1,
"grandTotal": 1,
"grossProfitAmount": 1,
"grossProfitPercentage": 1,
"specifiedVat": [
{
"vatAmount": 1,
"vatDescription": "text",
"vatRate": 1
}
],
"subtotal": 1,
"totalDiscount": 1,
"totalVat": 1
},
"orderhandlingState": "NOT_STARTED",
"orderhandlings": [
{
"active": true,
"createdAt": "2026-01-01T00:00:00.000Z",
"createdBy": "text",
"description": "text",
"handlingUid": "text",
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"lastModifiedBy": "text",
"name": "text",
"orderHandlingUid": "text",
"state": "NOT_STARTED"
}
],
"settleState": "NOT_STARTED",
"settledAt": "2026-01-01T00:00:00.000Z",
"settlementTotals": {
"change": 1,
"remaining": 1,
"remainingRounded": 1,
"totals": 1,
"remainingPrePayment": 1,
"remainingAuthorizedAmount": 1
},
"settlements": [
{
"amount": 1,
"createdAt": "2026-01-01T00:00:00.000Z",
"displayMessages": [
{
"key": "text",
"message": "text",
"timestamp": "2026-01-01T00:00:00.000Z"
}
],
"externalId": "text",
"externalPaymentReference": "text",
"idMethod": "NO_CVM_RULE_PERFORMED",
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"ledgerNumber": "text",
"ledgerType": "LEDGER",
"parameters": [
{
"key": "text",
"value": "text",
"name": "text",
"type": "TEXT"
}
],
"settledAt": "2026-01-01T00:00:00.000Z",
"settlementCode": "text",
"settlementUid": "text",
"settlementName": "text",
"state": "NOT_STARTED",
"status": "NEW",
"storeSettlementIssuer": {
"storeSettlementIssuerUid": "text",
"name": "text",
"code": "text"
},
"tenantUserDisplayName": "text",
"tenantUserUid": "text",
"storePaymentMethodUid": "text",
"currency": {
"amount": 1,
"code": "text",
"exchangeRate": 1
},
"additionalDetails": [
{
"key": "text",
"value": "text"
}
],
"creditCount": 1,
"creditAmount": 1,
"paymentCount": 1,
"paymentAmount": 1,
"tillUid": "text",
"tillName": "text",
"tillNumber": 1,
"storeUid": "text",
"storeName": "text",
"orderReceiptUid": "text",
"authorizedAmount": 1,
"capturedAmount": 1,
"refundedAmount": 1,
"receiptText": "text",
"transactions": [
{
"transactionType": "text",
"pspTransactionId": "text",
"transactionAmount": 1,
"orderReceiptUid": "text"
}
],
"allowedActions": [
"CANCEL"
]
}
],
"storeUid": "text",
"storeName": "text",
"systemOrigin": "text",
"tenantUserDisplayName": "text",
"tenantUserUid": "text",
"tillUid": "text",
"type": "OFFER",
"validUntil": "2026-01-01T00:00:00.000Z",
"vatFree": true,
"vatPrint": "SUM",
"voucherNumber": "text",
"deliveryDate": "2026-01-01",
"discounts": [
{
"orderDiscountUid": "text",
"discountCode": "text",
"type": "PERCENTAGE",
"amount": 1,
"name": "text",
"origin": "LOYALTY",
"validTo": "2026-01-01T00:00:00.000Z",
"maxUsage": 1,
"productSkus": [
"text"
],
"orderItemUids": [
"text"
],
"externalTransactionId": "text",
"scope": "WHOLE_ORDER",
"discountReasonCode": "text",
"discountReference": "text",
"createdAt": "2026-01-01T00:00:00.000Z",
"createdBy": "text",
"lastModifiedAt": "2026-01-01T00:00:00.000Z",
"lastModifiedBy": "text",
"campaignUid": "text"
}
],
"compensationReasonUid": "text",
"lastModifiedBy": "text",
"allowedActions": [],
"blockings": [
{
"orderBlockingUid": "text",
"type": "DELIVER_OUT",
"description": "text"
},
{
"createdBy": "text",
"createdAt": "2026-01-01T00:00:00.000Z",
"lastModifiedBy": "text",
"lastModifiedAt": "2026-01-01T00:00:00.000Z"
}
],
"deviations": [
{
"type": "DELIVERY_DATE_LATE",
"orderItemUids": [
"text"
],
"openedAt": "2026-01-01T00:00:00.000Z",
"description": "text",
"sourceDate": "2026-01-01",
"agreedDate": "2026-01-01",
"latestPickupDate": "2026-01-01",
"deliveryType": "SHIPPING"
}
],
"stockStatus": "IN_STOCK"
}
}Last updated
Was this helpful?

