Make the Wallet Send Endpoint Safe to Retry
Last updated: November 29, 2026
Quick Overview
A client calls POST /wallet/{id}/send, the network times out, and the client retries. Design and implement idempotency so a retried request never creates a second withdrawal, while a genuinely different request is never confused with the first.
BitGo
November 29, 20260
0
0 solved
A client calls POST /wallet/{id}/send, the network times out, and the client retries. Design and implement idempotency so a retried request never creates a second withdrawal, while a genuinely different request is never confused with the first.
Exchanges and fintechs integrate with BitGo's REST API and retry aggressively, and a duplicate on-chain withdrawal cannot be reversed. Interviewers use this to see whether a candidate treats idempotency as a first-class part of API design rather than an afterthought.
What the Interviewer Expects
- Uses a client-supplied idempotency key scoped to the wallet (or API token)
- Stores a fingerprint of the request body and rejects key reuse with different parameters
- Handles the in-progress window when a retry arrives before the first call finishes
- Explains what happens when the downstream call fails partway
- Moves the record to durable storage with a unique constraint in production
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?
- What if the process crashes after broadcasting but before saving the result?
- How do you make this work across many API pods?
- Would you return 409 or 200 for an in-progress duplicate?
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
Same key plus same body returns the original result and causes no new side effect. Same key with a different body is an error. Different keys are independent. Concurrent duplicates must not both execu...
High-Level Design
Key the record by (wallet_id, idempotency_key). Save a SHA-256 of the canonical JSON body. The first request inserts an in_progress row (in Postgres, an INSERT ... ON CONFLICT DO NOTHING on a un...