How can I prevent double-bookings?

Read as Markdown

A double-booking can occur if a slot that was free when you checked availability has already been taken by the time you create the event - for example, while the user is deciding which slot to select.

The most direct way to reduce the race condition window is to call the Availability API twice - once to generate the slots shown to the user, and again immediately before creating the event once the user has made their selection.

For the second call, narrow the query_periods to the specific time the user selected, so you are only checking whether that one slot is still available rather than regenerating the full set of slots. If the slot is no longer available on this second query, the booking can be rejected before an event is created.

If you have any follow-up questions, please feel free to contact us at support@cronofy.com.