Design an Idempotent Order Placement Endpoint for Mobile Checkout
Last updated: November 29, 2026
Quick Overview
Mobile clients on flaky networks retry order submissions, which can create duplicate orders and double charges. Design the API contract and server logic for an idempotent place-order endpoint, including how retries, conflicting requests and in-flight duplicates are handled.
Walmart Labs
November 29, 20260
0
0 solved
Mobile clients on flaky networks retry order submissions, which can create duplicate orders and double charges. Design the API contract and server logic for an idempotent place-order endpoint, including how retries, conflicting requests and in-flight duplicates are handled.
The Walmart app places a huge number of orders over cellular connections, where a timeout does not tell the client whether the order went through. The Walmart Labs interviewer checks a clear API contract with idempotency keys, correct status codes, and a server implementation that is safe under concurrent retries.
What the Interviewer Expects
- Require a client-generated Idempotency-Key header
- Scope keys per customer and store a request fingerprint
- Replay the stored response for a true retry
- Reject key reuse with a different body
- Handle a retry that arrives while the original is still running
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How long should idempotency records be kept, and where?
- How do you make the order write and the idempotency record atomic across a database and a payment provider?
- Should GET or DELETE endpoints also accept idempotency keys?
- How would you version this API without breaking older app releases?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
POST /v1/orders with body {cart_id, total_cents, pickup_store} and header Idempotency-Key: <uuid>. Contract: the same key with the same body returns the original response, the same status and th...
High-Level Design
Persist an idempotency record keyed by (user_id, key) holding a state (in_progress or done), a SHA-256 fingerprint of the canonical JSON body, and the final status and response. The record is cr...