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. The response is the full updated order detail, so the client can refresh the screen without a follow-up GET.
Endpoint
| Endpoint | Method |
|---|---|
/api/admin/orders/{id}/cancel | POST |
The request body is empty — the order is identified by the URL.
Errors
The endpoint enforces the same 4 eligibility checks the admin panel uses. Each failure returns HTTP 422 with the matching message:
| 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. |
Sample 422 response
json
{
"type": "/errors/422",
"title": "Bad Request",
"status": 422,
"detail": "There is nothing to cancel on this order."
}
