Idempotency Keys for a Card Payment Posting API

Last updated: November 29, 2026

Quick Overview

Design and implement an idempotent POST endpoint for posting a card payment so that client retries after timeouts never post the same payment twice, and reused keys with different bodies are rejected.

Capital One
Software Engineering Fundamentals
Software Engineer
Capital One
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design and implement an idempotent POST endpoint for posting a card payment so that client retries after timeouts never post the same payment twice, and reused keys with different bodies are rejected.

Customers paying their Capital One card from the mobile app on flaky networks will retry, and so will upstream services. The interviewer checks that you understand why POST is not naturally idempotent, how idempotency keys work, and how to handle concurrent duplicates and failures.

What the Interviewer Expects
  • Explain why retries cause duplicate payments
  • Store a record per key with a request fingerprint and the saved response
  • Replay the stored response for a true retry
  • Reject a key reused with a different body
  • Handle concurrent requests with the same key and failures mid-processing
  • Expire keys after a retention window
Key Topics to Cover
idempotency
API design
retries
exactly-once effects
concurrency
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 you store keys in a multi-instance deployment?
  • Should a 4xx validation error be cached for the key?
  • How do idempotency keys interact with a downstream processor that is not idempotent?
  • How would you test the concurrent duplicate case?
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
  • POST /payments with header Idempotency-Key and a body (account, amount).
  • Same key plus same body returns the original result and does not post again.
  • Same key with a different body is a clie...
High-Level Design

The client generates a unique key per logical payment (a UUID) and reuses it on every retry. The server keeps a table keyed by idempotency key holding a fingerprint of the body, a status (`in_progress...


Submit Your Answer
Markdown supported