Appointment Booking API · Step 5 of 7
Create bookings without race conditions
Implement booking creation inside a database transaction. Recheck availability while holding the appropriate constraint or lock, then commit or return a conflict.
Understand
Checking availability and inserting a booking must be atomic; a separate check alone can race.
Build
Validate service, time zone, opening hours, and required customer fields. Return 409 for an occupied slot and never return internal database details.
Check
Two simultaneous requests for one slot result in at most one booking; the other receives the documented conflict response.
Try it
Add an idempotency key or explain when it would protect clients that retry after a timeout.
