Design a Retry-Safe Reservation API With Idempotency Keys

Last updated: November 29, 2026

Quick Overview

Mobile clients on flaky networks retry POST /reservations when a response times out, which can create duplicate reservations or double charges. Design the API contract and server logic for idempotency keys, and implement the core store.

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

0

0

0 solved


Mobile clients on flaky networks retry POST /reservations when a response times out, which can create duplicate reservations or double charges. Design the API contract and server logic for idempotency keys, and implement the core store.

Airbnb guests often book from airports and trains with poor connectivity, and payments make retries dangerous. The interviewer is checking API design judgment: who generates the key, what gets stored, how conflicts and in-flight duplicates behave, and how long keys live.

What the Interviewer Expects
  • Have the client generate a unique key per user intent and send it as a header
  • Store the key with a request fingerprint and the final response
  • Replay the stored response for identical retries
  • Reject reuse of a key with a different body
  • Handle concurrent duplicates that arrive while the first is still processing
  • Define expiry and what happens on transient failures
Key Topics to Cover
API design
idempotency
retries
HTTP semantics
payments
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 so they survive a server restart and work across regions?
  • How do downstream calls to the payment processor stay idempotent too?
  • Should a 500 response be cached and replayed?
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 /reservations takes an Idempotency-Key header (UUID generated once when the guest taps Reserve and reused for every retry of that tap). Guarantees: at most one reservation and one charge per ke...

High-Level Design

Server flow: atomically insert (key, user_id, fingerprint, status=in_progress). If the insert succeeds, run the booking and save the response. If the key exists with status done, replay. If it is in p...


Submit Your Answer
Markdown supported