Idempotency Keys for a Marketplace Checkout Endpoint

Last updated: November 29, 2026

Quick Overview

Make a Marketplace checkout endpoint safe to retry: a client that resends the same request after a timeout must not be charged twice, and reusing a key with a different body must be rejected.

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

0

0

0 solved


Make a Marketplace checkout endpoint safe to retry: a client that resends the same request after a timeout must not be charged twice, and reusing a key with a different body must be rejected.

Facebook Marketplace checkout runs over mobile networks where requests time out after the server already did the work, so clients retry. Interviewers at Meta use this to test API design judgment around retries, concurrency between duplicate requests, and what exactly gets stored and replayed.

What the Interviewer Expects
  • Has clients send a unique idempotency key per logical purchase, scoped to the caller
  • Stores an in-progress record before charging so concurrent duplicates are detected
  • Replays the stored response for completed requests rather than re-executing
  • Fingerprints the request body and rejects key reuse with different parameters
  • Defines what happens on failure and sets a retention TTL for keys
  • Passes the key downstream to the payment processor for end-to-end safety
Key Topics to Cover
idempotency
API design
retries
request fingerprinting
exactly-once effects
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
  • What HTTP status codes would you return for in-progress and conflict cases?
  • How does this work when the key store is a replicated database instead of a local dict?
  • If the charge times out at the processor, should you release the key or keep it pending?
  • How long should keys be retained, and what happens to a retry after expiry?
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
  • checkout(buyer_id, idem_key, body) charges at most once per (buyer, key).
  • A retry with the same key and body returns the original response.
  • Same key, different body: error (409 or 422).
  • A du...
High-Level Design

The record table is keyed by (buyer_id, idem_key) so one buyer cannot collide with another's keys. Each record holds a state (in_progress or done), a SHA-256 fingerprint of the canonical JSON bo...


Submit Your Answer
Markdown supported