Change commands and retries
Which price applies when retrying an already accepted order?
Scale alone does not ensure consistent retry behaviour. This proposed API binds the role, business object, change payload and expected state to each new intent. An idempotency key identifies the same intent after a response is lost.
Starting point Calculate order totals as integer cents.
Assumptions for the example case
A fictional example design with one customer, one currency and one warehouse; a binding price offer; complete local stock and credit reservations; and one complete delivery. Figures and quality goals are illustrative test assumptions. Multiple currencies, tax calculation, partial delivery and credit insurance are outside the scope.
Retries and new intent
Order envelope and stored response
Reusing a key with identical content returns the confirmation; eleven boxes under the same key produce a conflict.
Proposed domain API contracts
- POST
/wholesale-ordersCommit stock and credit together.
- Input
- Customer purchasing, K-101, P-101, W-101, quantity 10 boxes, expected offer version and key. The server calculates 20000 cents.
- Result
- A-101 with joint stock and credit reservations, or complete rejection; no partial commitment.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- POST
/wholesale-orders/{id}/fulfillmentHand a confirmed order over for fulfilment.
- Input
- Order support, A-101, expected version and key.
- Result
- 202 with a durable fulfilment request; amount and quantity come from the confirmed commitment.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- POST
/wholesale-orders/{id}/cancelCancel before fulfilment starts.
- Input
- Authorised purchasing or order support, A-101, version, reason and key.
- Result
- Cancellation releases both reservations together. An existing open fulfilment request causes a conflict and investigation.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- POST
/delivery-evidenceRecord delivery and its receivable reference.
- Input
- Authenticated inventory management, unique delivery record, fulfilment reference, A-101, 10 boxes, 20000 cents, EUR and invoice reference.
- Result
- Consume stock once and atomically replace the credit reservation with a receivable; discrepancies remain unresolved.
- Retry behaviour
- An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
- GET
/wholesale-orders/{id}Read commitment and fulfilment state.
- Input
- Role authorised for the object, A-101.
- Result
- Offer, stock reservation, credit reservation, receivable and outstanding external evidence.
- Retry behaviour
- Repeating a read creates no business effect; the returned current state may change between requests.
Preserve the offer
Bind the order to P-101 and the quantity.
The price changes during a retry.
Retry does not adopt a new price version.
- Alternative considered
- Reading the current price on every retry changes the original intent.
- Trade-off
- Expired offers need new confirmation.
- Reassess
- Dynamic prices are explicitly introduced.
Terms in this step
- Preserve the offer
- Retry does not adopt a new price version.
Try it yourself
P-101 expires and A-101 is retried identically. Distinguish the original result from a new order.
A hint for your attempt
Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.
Compare with a possible solution
- First part of the solution
- An identical retry of an accepted order returns its stored confirmation against P-101.
- Second part of the solution
- A new order after offer expiry requires a valid offer; it cannot silently reuse the old price.
Apply to your project
Which corresponding assumption would you test first in your project? Consider this trigger: Dynamic prices are explicitly introduced.