---
title: "Discussion on \"A Booking API That Cannot Promise the Same Slot Twice\" | Hashnode"
description: "Discussion on \"A Booking API That Cannot Promise the Same Slot Twice\". A booking system has two separate responsibilities: reserve a resource correctly, then communicate the reservation reliably. A beautiful calendar can fail both. If two customers see the same available"
url: "https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A Booking API That Cannot Promise the Same Slot Twice](https://gilnex.hashnode.dev/a-booking-api-that-cannot-promise-the-same-slot-twice?utm_source=hashnode&utm_medium=feed)

A booking system has two separate responsibilities: reserve a resource correctly, then communicate the reservation reliably. A beautiful calendar can fail both. If two customers see the same available

5d ago · 4 min read · gilnex.hashnode.dev  
Read the article

-   [#postgresql](https://hashnode.com/tag/postgresql)
-   [#api-design](https://hashnode.com/tag/api-design)
-   [#backend](https://hashnode.com/tag/backend)
-   [#scheduling](https://hashnode.com/tag/scheduling)

## Written by

[Taylor Walker](https://hashnode.com/@taylorwalker)

@taylorwalker

  
[View profile](https://hashnode.com/@taylorwalker)

## Responses 1

Markdown supported · ⌘↵ to post

[Ahmed Elbashier](https://hashnode.com/@ahmedelbashier)

[1d ago](https://hashnode.com/posts/a-booking-api-that-cannot-promise-the-same-slot-twice/6b08bdd61227f2d761c170d3/comment/6b0d5a74a6eeffc420a73ec1)

Putting the invariant in an exclusion constraint is the right call. For the half-open interval to work you want tstzrange(starts\_at, ends\_at, '\[)') in the constraint. How do you handle temporary holds that expire? I'd expect a partial constraint (WHERE state IN ('held','confirmed')) plus a sweeper, but I'm curious whether you'd rather let the hold lapse by timestamp.
