Skip to main content

Order Cancel

Type: Mutation

Overview

The orderCancel mutation cancels (archives) a pending, unpaid order. Use it from ecommerce integrations when the customer abandons checkout or switches to another payment method, so the Sevi order does not stay open until the automatic abandon-timeout sweep archives it.

Rules

  • Only the order's own vendor (the wallet behind your API token) can cancel an order.
  • Only orders with status PENDING and payment status PENDING can be cancelled. Paid or shipped orders are rejected.
  • Cancelling an already archived order is a no-op and returns the order unchanged.
  • Any in-flight payment intent for the order is cancelled as well (best effort).

Request

mutation OrderCancel($orderId: String!) {
orderCancel(orderId: $orderId) {
order {
id
referenceNumber
status
paymentStatus
}
}
}

Response

{
"data": {
"orderCancel": {
"order": {
"id": "01234567-abcd-...",
"referenceNumber": "D123456",
"status": "ARCHIVED",
"paymentStatus": "PENDING"
}
}
}
}

Errors

MessageCause
Order with id ... not foundUnknown order id
UnauthorizedThe order belongs to a different vendor
Only pending, unpaid orders can be cancelled.Order already paid, shipped or delivered
Order advanced while cancelling; not cancelled.A payment confirmation raced the cancellation