Cancel Order
Cancels every cancellable item on an order. This is the same action as the Cancel button on the admin order-view screen, with the same eligibility gates as REST.
GraphQL returns a summary; REST returns the full detail
The GraphQL mutation returns a slim order summary (orderId, incrementId, status, statusLabel, grandTotal, success, message). The REST endpoint (POST /api/admin/orders/{id}/cancel) returns the full updated order-detail payload. Use REST, or re-query adminOrderDetail, when you need the complete order after cancelling.
Prerequisites
The example targets an order with cancellable items. If your order has no items with qty_to_cancel > 0 (already canceled / fully shipped / closed / fraud) the mutation returns an errors[] entry like "There is nothing to cancel on this order." — pick an order in pending or processing state.
Operation
| Operation | Type | Purpose |
|---|---|---|
createAdminCancelOrder | Mutation | Cancel an order |
Errors
Each failure returns the errors[] array with one of these messages:
| Condition | Lang key | Message |
|---|---|---|
Order is closed | bagistoapi::app.admin.order.actions.cancel.closed | Closed orders cannot be canceled. |
Order is fraud | bagistoapi::app.admin.order.actions.cancel.fraud | Fraud orders cannot be canceled. |
No item has qty_to_cancel > 0 | bagistoapi::app.admin.order.actions.cancel.nothing-to-cancel | There is nothing to cancel on this order. |
Admin role lacks sales.orders.cancel | bagistoapi::app.admin.order.actions.cancel.no-permission | You do not have permission to cancel orders. |

