Skip to content

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

EndpointMethod
/api/admin/orders/{id}/cancelPOST

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:

ConditionLang keyMessage
Order is closedbagistoapi::app.admin.order.actions.cancel.closedClosed orders cannot be canceled.
Order is fraudbagistoapi::app.admin.order.actions.cancel.fraudFraud orders cannot be canceled.
No item has qty_to_cancel > 0bagistoapi::app.admin.order.actions.cancel.nothing-to-cancelThere is nothing to cancel on this order.
Admin role lacks sales.orders.cancelbagistoapi::app.admin.order.actions.cancel.no-permissionYou 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."
}

Released under the MIT License.