> For the complete documentation index, see [llms.txt](https://docs.xorosoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xorosoft.com/developers-api/sales-order-management/cancel-sales-order-items.md).

# Cancel Sales Order Items

This API allows cancellation of unallocated quantities and optionally allocated wave quantities that have not yet been picked. The system processes cancellations by first cancelling unallocated quantities, and if required and enabled, cancelling allocated wave quantities.

| Name                | Data Type         | Description                                                                                                                                                                   |
| ------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OrderNumber`       | string, required  | Represents the Sales Order number for which the cancellation request is made.                                                                                                 |
| `AutoCancelWaveQty` | boolean           | Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities. |
| `CancelWaveQtyCode` | integer, required | Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities. |
| `Lines`             | array, required   | Represents the list of Sales Order lines where quantity cancellation is required.                                                                                             |
| `SoLineId`          | integer, required | Unique Sales Order Line ID.                                                                                                                                                   |
| `CancelQty`         | integer, required | Quantity to cancel for the specified Sales Order line.                                                                                                                        |

Cancellation Logic

Unallocated quantity is cancelled first

If additional quantity needs to be cancelled and AutoCancelWaveQty = true, the system cancels allocated wave quantities

The API also uses Delta Quantity logic when updating cancellations.

Delta Qty = API Cancel Qty -' Existing SO Line Cancel Qty

Only the delta quantity is processed during the update.

Validations

Over-cancellation is not allowed

CancelQty must be less than or equal to the remaining quantity to ship

If AutoCancelWaveQty = false, allocated quantities cannot be cancelled

If the requested quantity exceeds available unpicked quantity in a wave, the API returns an error

```json
{"openapi":"3.0.3","info":{"title":"Xorosoft ERP Public API","version":"2026.07"},"tags":[{"name":"Sales Order Management","description":"Use Sales Order Management APIs to create, retrieve, release, close, cancel, and inspect sales orders. These endpoints support order integrations from ecommerce, marketplace, EDI, B2B, and customer-service systems. Sales order payloads commonly include customer, store, shipping, billing, payment terms, order dates, line items, quantities, pricing, taxes, discounts, and third-party reference fields."}],"servers":[{"url":"https://res.xorosoft.io","description":"Xorosoft ERP API server"}],"security":[{"basic":[]}],"components":{"securitySchemes":{"basic":{"scheme":"basic","type":"http"}},"schemas":{"PostSalesorderCancelqtyRequest":{"type":"object","description":"Request body for Cancel Sales Order Items.","properties":{"OrderNumber":{"type":"string","description":"Represents the Sales Order number for which the cancellation request is made."},"AutoCancelWaveQty":{"type":"boolean","description":"Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities."},"CancelWaveQtyCode":{"type":"integer","description":"Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities."},"Lines":{"type":"array","description":"Represents the list of Sales Order lines where quantity cancellation is required.","items":{"type":"object","additionalProperties":true}},"SoLineId":{"type":"integer","description":"Unique Sales Order Line ID."},"CancelQty":{"type":"integer","description":"Quantity to cancel for the specified Sales Order line."}},"additionalProperties":true,"required":["OrderNumber","CancelWaveQtyCode","Lines","SoLineId","CancelQty"]}}},"paths":{"/api/xerp/salesorder/cancelqty":{"post":{"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"Data":{"items":{"properties":{"SoEstimateHeader":{"properties":{"CurrencyCode":{"type":"string"},"CustomerName":{"type":"string"},"OrderNumber":{"type":"string"},"StatusName":{"type":"string"},"TotalAmount":{"type":"number"},"TotalCancelQty":{"type":"number"}},"type":"object"},"SoEstimateItemLineArr":{"items":{"properties":{"CancelQty":{"type":"number"},"Id":{"type":"number"},"ItemNumber":{"type":"string"},"QtyAllocated":{"type":"number"},"QtyOrdered":{"type":"number"},"QtyRemainingToShip":{"type":"number"}},"type":"object"},"type":"array"}},"type":"object"},"type":"array"},"IsForwardRequest":{"type":"boolean"},"Message":{"type":"string"},"MessageTitle":{"type":"string","nullable":true},"Result":{"type":"boolean"}},"type":"object"}}},"description":"OK","headers":{}}},"tags":["Sales Order Management"],"description":"This API allows cancellation of unallocated quantities and optionally allocated wave quantities that have not yet been picked.\nThe system processes cancellations by first cancelling unallocated quantities, and if required and enabled, cancelling allocated wave quantities.\nName               |Data Type          |Description\n-------------------|-------------------|-------------------\n``OrderNumber``|string, required|Represents the Sales Order number for which the cancellation request is made.\n``AutoCancelWaveQty``|boolean|Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities.\n``CancelWaveQtyCode``|integer, required|Determines whether wave-allocated quantities can be cancelled. false cancels only unallocated quantities. true allows cancellation of allocated but unpicked wave quantities.\n``Lines``|array, required|Represents the list of Sales Order lines where quantity cancellation is required.\n``SoLineId``|integer, required|Unique Sales Order Line ID.\n``CancelQty``|integer, required|Quantity to cancel for the specified Sales Order line.\n\n<b>Cancellation Logic</b>\n\nUnallocated quantity is cancelled first\n\nIf additional quantity needs to be cancelled and AutoCancelWaveQty = true, the system cancels allocated wave quantities\n\nThe API also uses Delta Quantity logic when updating cancellations.\n\nDelta Qty = API Cancel Qty -' Existing SO Line Cancel Qty\n\nOnly the delta quantity is processed during the update.\n\n<b>Validations</b>\n\nOver-cancellation is not allowed\n\nCancelQty must be less than or equal to the remaining quantity to ship\n\nIf AutoCancelWaveQty = false, allocated quantities cannot be cancelled\n\nIf the requested quantity exceeds available unpicked quantity in a wave, the API returns an error","operationId":"post_salesorder_cancelqty","summary":"Cancel Sales Order Items","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostSalesorderCancelqtyRequest"}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.xorosoft.com/developers-api/sales-order-management/cancel-sales-order-items.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
