Walkthrough: Design a Booking API

Topics Covered

Clarify the Booking Domain and Model Resources

Step one: clarify the product and the consumers

Scope and non functional requirements

Step two: model the resources

Slots as computed, not stored

What the interviewer is checking

Use cases to test the model against

Providers, businesses and staff

Identifiers and references

Data the provider owns versus the guest owns

Design a booking API is a classic API design prompt because it hides one hard problem inside an otherwise ordinary CRUD surface: two people must never be given the same slot. Whether the product books dentist appointments, restaurant tables, hotel rooms, fitness classes or meeting rooms, the shape is the same. Guests search for availability, reserve something briefly while they decide and pay, confirm, and sometimes cancel or reschedule. Providers manage their schedules and want to know about every change. This lesson walks the six step framework end to end with an appointment booking platform as the running example, and spends its depth on availability, holds, concurrency and cancellation.

Section one clarifies and models. Section two designs availability search. Section three covers holds and booking creation. Section four is the deep dive on concurrency and double booking prevention. Section five covers cancellation, rescheduling, notifications and the wrap up.

Step one: clarify the product and the consumers

Start by asking what is being booked, because it changes the model. Appointments with a person have a duration and a provider. Hotel rooms are booked by night and are interchangeable within a room type. Restaurant tables depend on party size. Classes have a capacity greater than one. A good clarification picks one and names how the others differ. For this walkthrough, we book appointments with service providers such as dentists, hairdressers and physiotherapists, with a few multi seat classes to show capacity.

Then ask who calls the API. There are usually four consumers. The guest facing web and mobile apps search and book. The provider dashboard manages schedules, services and bookings. Third party integrations, such as a clinic's practice management system or a marketplace that lists many businesses, read and write bookings through a public API. Internal systems send notifications and handle payments. The public API is the one we design, used by our own apps and by partners.

Scope and non functional requirements

Agree scope out loud. In scope: providers, services, schedules, availability search, holds, bookings with optional deposits, cancellation and rescheduling, notifications and webhooks for partners. Out of scope but named: dynamic pricing, waitlists, reviews and recurring bookings beyond a brief mention.

The non functional requirements drive the deep dives. No double booking: a slot with capacity one must never have two confirmed bookings, even under concurrent requests and retries. Availability search must be fast, under a few hundred milliseconds, because guests browse many dates. Search may be slightly stale, but booking must be exact, which is the central tension of the design. Bookings must be durable and auditable, since a lost appointment is a real world failure. Time zones must be handled correctly, because a booking made from London for a clinic in New York must land at the right local time. Partners need reliable notifications of every change.

A quick estimate grounds the scale. Suppose two hundred thousand providers, each with eight to ten bookable hours a day. Bookings might be a few million a day with sharp peaks in the morning, and searches perhaps twenty to fifty times as many. The read to write ratio is high and concentrated on popular providers and dates, so caching search matters, while writes are moderate in volume but must be strictly correct per slot.

A booking moves through search, hold, confirm and notify, each a separate step in the API.

Step two: model the resources

The resources are providers, services, schedules, availability, holds, bookings and, for payments, deposits that reference the payments API from lesson ten.

A provider is a bookable entity such as a dentist or a room, belonging to a business with a location and a time zone. A service is something bookable with a duration, a price, a buffer before and after, and a capacity, such as a 30 minute check up with capacity one or a 60 minute yoga class with capacity twenty. A schedule describes when a provider works: recurring weekly hours plus exceptions for holidays and time off. Availability is a computed view, the set of open slots for a provider and service over a date range; it is not stored as a resource that clients create. A hold is a short lived reservation of a specific slot by a specific guest, with an expiry. A booking is the confirmed reservation, with a guest, provider, service, start and end time, status, price, policy snapshot and history.

Slots as computed, not stored

A key modelling decision is whether slots exist as rows. Storing every possible slot for every provider far into the future is wasteful and makes schedule changes painful: changing working hours would rewrite thousands of rows. The common approach is to compute availability from the schedule, minus bookings and live holds, at query time or into a cache. What is stored is the booking and the hold, each with a provider, a start and an end. The concurrency deep dive will refine this, because a computed slot is harder to lock than a row, and some designs introduce slot rows only for the narrow window where conflicts happen.

json
1{
2  "id": "bk_3Hq",
3  "object": "booking",
4  "status": "confirmed",
5  "provider_id": "prov_lee",
6  "service_id": "svc_checkup",
7  "start": "2026-12-04T10:30:00-05:00",
8  "end": "2026-12-04T11:00:00-05:00",
9  "time_zone": "America/New_York",
10  "guest": {"id": "gst_ana", "name": "Ana Silva"},
11  "price": {"amount": 12000, "currency": "usd"},
12  "cancellation_policy": {"free_until_hours": 24, "late_refund_percent": 50, "no_refund_hours": 2},
13  "version": 3,
14  "created_at": "2026-11-29T14:02:11Z"
15}

Times are stored as instants with an explicit zone identifier, not just an offset, so a booking survives daylight saving changes. Money uses minor units, as lesson ten explained. The cancellation policy is copied onto the booking, which section five will justify. The version supports optimistic concurrency and ordered webhooks.

What the interviewer is checking

In the opening the interviewer wants to see that you pick a concrete booking type, name the no double booking requirement first, separate searching from committing, model availability as computed rather than stored, and handle time zones explicitly. Candidates who jump to POST /bookings without a hold concept or a conflict strategy usually get pulled back to it ten minutes later.

Use cases to test the model against

Run the agreed use cases through the model before moving on. A guest finds the earliest check up with any dentist near work: availability search across providers. A guest picks Friday at 10:30 and enters details: a hold, then a confirm. A clinic requires a deposit for new patients: a deposit on the booking backed by a payment intent. A guest cancels two days ahead: a cancel transition with a refund from the policy snapshot. The dentist is ill on Friday: a schedule exception plus provider cancellations of affected bookings, with notifications. A practice management system mirrors every booking: partner webhooks and an events feed. A yoga studio sells twenty places per class: a service with capacity above one and a class instance resource. If each maps to resources you already named, the model is ready.

Providers, businesses and staff

A detail that often surfaces later is the relationship between a business and its providers. A clinic is a business with a location, a time zone and policies; dentists, hygienists and treatment rooms are providers inside it. Some services need two resources at once, such as a dentist and a specific room, which turns one claim into two claims that must both succeed in one transaction. Mention it as a variant and keep the main design to a single provider per booking, unless the interviewer wants to explore it.

Staff permissions belong to the business: owners manage policies and billing, front desk staff manage bookings for every provider, and individual providers see their own calendars. Modelling these as roles on the business, as lesson six described for authorization, keeps the public API simple.

Identifiers and references

Use opaque ids with type prefixes, such as prov_, svc_, hold_ and bk_, which make logs and support tickets readable and stop a booking id being used where a provider id is expected. Accept a partner supplied external reference on bookings, unique per partner, so partner systems can map their records to ours and replay safely; section four relies on it. Never expose sequential numeric ids, which leak volume and invite enumeration of other guests' bookings.

Data the provider owns versus the guest owns

Bookings sit between two parties, so be explicit about who can see and change what. The guest owns their contact details and can cancel within policy. The provider owns the schedule, can cancel any booking and can add private notes the guest never sees. Partners act on behalf of the business. That split shows up in the representation: the guest view of a booking omits internal notes and staff fields, while the provider view includes them, chosen by the credential rather than by separate endpoints.

Search can be stale, booking cannot

The central tension of every booking system is that availability search must be fast and can tolerate slight staleness, while the act of booking must be exact. Design two paths: a cached, approximate read path and a strictly consistent write path that has the final say.

Basis Lab
That was the last lesson. What next?

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course