Idempotency Keys for a Money Transfer API

Last updated: November 29, 2026

Quick Overview

Design and implement the server side of idempotency keys for a POST /transfers endpoint so that a mobile client retrying after a timeout never moves money twice, while still rejecting a key reused with a different request body.

SoFi
Software Engineering Fundamentals
Software Engineer
SoFi
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design and implement the server side of idempotency keys for a POST /transfers endpoint so that a mobile client retrying after a timeout never moves money twice, while still rejecting a key reused with a different request body.

Mobile networks drop responses, and SoFi's app retries money movement requests, so duplicate transfers are a real risk. The interviewer checks API design judgment: scoping keys per member, fingerprinting the body, handling in-flight duplicates, and what to store so replays return the original response.

What the Interviewer Expects
  • Scopes keys by member id so two members cannot collide
  • Stores a request fingerprint and rejects mismatched reuse with 422
  • Marks a key in progress and returns 409 to concurrent duplicates
  • Replays the stored status and response for completed requests
  • Clears the key when execution fails before committing, and sets a TTL
Key Topics to Cover
idempotency
API design
retries
request fingerprinting
HTTP status codes
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Where would the idempotency row live relative to the transfer record, and why does that matter?
  • What if the process crashes after moving money but before saving the response?
  • How should the client generate keys and how long should they be valid?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Clients send Idempotency-Key with each transfer. Same key and same body returns the original result without executing again. Same key with a different body is a client bug (422). A duplicate arrivin...

High-Level Design

Key the store on (member_id, key). On first sight insert an in_progress row with a SHA-256 of the canonical JSON body; a unique constraint makes that insert the concurrency gate across many API po...


Submit Your Answer
Markdown supported

Related Questions