Use this file to discover all available pages before exploring further.
The admin orders API provides full visibility into every order placed across all customer accounts. Admins and staff can list, inspect, and advance orders through their lifecycle using the status update endpoint. Status transitions are enforced server-side via a strict state machine — invalid transitions are rejected with a descriptive 422 response. All status changes are recorded in an append-only statusHistory table for audit purposes, and cancellations automatically restore stock for affected products.
All endpoints in this section require the admin or staff role. Requests without a valid session return 401; requests with insufficient role return 403.
Returns all orders across all customers, ordered by createdAt descending (newest first). Supports an optional status filter. Each order in the response includes its nested items and payments arrays.Query Parameters
Fetches a single order with full relations: items, payments, and statusHistory. The statusHistory array is ordered by createdAt ascending, giving a chronological audit trail of every status transition and which admin triggered it.Response 200
Advances (or cancels) an order to a new status. The transition must be valid according to the server-side state machine. A history entry is automatically inserted recording the new status and the ID of the admin who made the change. On cancellation, stock is restored for all items with a linked product.Request Body
Target order status. Must be a valid next state for the current order status. One of: pending_payment, paid, preparing, shipped, delivered, cancelled.
Valid State Machine TransitionsThe following transitions are permitted. Any other combination returns 422 INVALID_TRANSITION.
From
Allowed to values
pending_payment
paid, cancelled
paid
preparing, cancelled
preparing
shipped, cancelled
shipped
delivered
delivered and cancelled are terminal states — no further transitions are permitted from them. Note that once an order is shipped, it can no longer be cancelled — only delivery is allowed from that state.
The requested transition is not permitted by the state machine. The from and to fields indicate what was attempted.
Stock restoration on cancellation: When an order is moved to cancelled, the server iterates all order items and increments stockQuantity on each linked product. This only applies to items where productId is not null — if a product was archived and its ID was set to null (via a set-null foreign key), that item’s quantity is silently skipped since the product no longer exists.
Optimistic concurrency: The status update uses a conditional UPDATE … WHERE status = :expectedStatus. If two admins attempt to update the same order simultaneously, the second request will find the row already changed and return 409 — "El pedido cambió de estado, reintentá". Refresh the order and retry with the updated current status.