API Design · Middle · Question 1 of 75
How would you model 'cancel an order' in a REST API?
- ✓Correct answer: As a state change (
PATCH /orders/42with{status: "cancelled"}) or a custom action (POST /orders/42:cancelor/orders/42/cancellation), documented consistently - 2As
GET /orders/42/cancel - 3As
DELETE /orders/42, removing the order permanently
Explanation
Cancelling usually keeps the order for history and may have business rules. A dedicated action makes those rules explicit; GET must never change state.