Skip to Content

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:write scope. See Authentication.
  • Retrieve the order and note the lineNumber of each line to cancel. See Retrieve orders.

Cancellation reasons

cancellationReasonUse it when
CUSTOMER_REQUESTEDThe customer asked to cancel.
OUT_OF_STOCKYou don't have the item in stock.
PRICE_ERRORThe item was listed at the wrong price.
SELLER_INITIATEDYou 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"
    }
  ]
}
FieldRequiredDescription
orderLines[].lineNumberYesLine identifier within the purchase order.
orderLines[].cancellationReasonYesOne of the reasons in the table above.
orderLines[].cancelQuantityNoQuantity 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 or cancellationReason isn't one of the listed values. Check errors[].pointer for 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 the Retry-After header.
  • To return money to a customer for a line, issue a refund. See Refund order lines.

On this page