Cancel order lines
Cancel order lines you can't fulfill and record the reason for each line.
Sometimes you can't fulfill an order line: the item is out of stock, it was listed at the wrong price, or the customer asked to cancel. Cancel those lines so that Walmart can notify the customer. You can cancel a whole line or only part of its quantity, and you must give a reason for each line.
Before you begin
- Get an access token with the
orders:writescope. See Authentication. - Retrieve the order and note the
lineNumberof each line to cancel. See Retrieve orders.
Cancellation reasons
cancellationReason | Use it when |
|---|---|
CUSTOMER_REQUESTED | The customer asked to cancel. |
OUT_OF_STOCK | You don't have the item in stock. |
PRICE_ERROR | The item was listed at the wrong price. |
SELLER_INITIATED | You are cancelling for another reason. |
Step 1: Cancel the order lines
Call Cancel order lines. For each line, send its lineNumber and a cancellationReason. Send cancelQuantity to cancel part of a line.
POST /v4/orders/1234567891234/cancel
Authorization: Bearer <access_token>
Content-Type: application/json{
"orderLines": [
{
"lineNumber": "1",
"cancelQuantity": { "amount": 1, "unit": "EACH" },
"cancellationReason": "OUT_OF_STOCK"
},
{
"lineNumber": "3",
"cancellationReason": "CUSTOMER_REQUESTED"
}
]
}| Field | Required | Description |
|---|---|---|
orderLines[].lineNumber | Yes | Line identifier within the purchase order. |
orderLines[].cancellationReason | Yes | One of the reasons in the table above. |
orderLines[].cancelQuantity | No | Quantity to cancel, with amount and unit. |
Step 2: Check the response
The response returns the purchase order ID and the time Walmart recorded the cancellation.
{
"purchaseOrderId": "1234567891234",
"cancelledAt": "2026-11-30T16:20:00Z"
}Get the order again to confirm that the cancelled lines have lineStatus set to Cancelled.
GET /v4/orders/1234567891234/items
Authorization: Bearer <access_token>Errors and edge cases
400: a required field is missing orcancellationReasonisn't one of the listed values. Checkerrors[].pointerfor the field at fault.404: no order exists for the purchase order ID.429: you exceeded the rate limit. Back off and retry.503: cancellation can be temporarily unavailable. Retry after the number of seconds in theRetry-Afterheader.- To return money to a customer for a line, issue a refund. See Refund order lines.
