Computing availability
A slot grid comes from three inputs: the host’s weekly schedule, the link’s own booking rules, and the busy intervals that should block a slot. Rules cover duration, buffers, notice, and the booking horizon. The pure engine that combines them,computeSlots, walks each calendar day the query window touches, in the schedule’s own timezone. For each day it resolves the open hours — the weekly grid, or a date override. It then steps candidate starts every slotIntervalMinutes and keeps the ones that clear both the open hours and the padded busy time (convex/domains/availability/domain/computeSlots.lib.ts:226-360). Date overrides — a blocked day, or custom hours for one date — are resolved by resolveScheduleToOpenHours before the engine ever sees them (convex/domains/availabilitySchedules/domain/resolveScheduleToOpenHours.lib.ts:111-147).
Buffers are applied by padding each busy block, rather than shrinking the candidate slot. A busy interval’s leading edge grows by the new meeting’s bufferAfter. Its trailing edge grows by bufferBefore. The padding direction is therefore the reverse of what the field names suggest (computeSlots.lib.ts:288-298). Minimum notice, booking horizon, and the per-day cap are resolved against product defaults at one single point, linkToSlotRules. An absent minBookingNoticeMinutes on a link means the 120-minute default, not zero (convex/domains/availability/domain/publicMonth.lib.ts:213-233). The default horizon is 28 days.
Calendar busy time comes from a per-user, per-UTC-day cache called freeBusyCache. It refreshes by fanning a Nylas free/busy call out over the host’s own non-shared grants and merging the results (convex/domains/availability/actions/refreshBusy.ts:33-53). A cache row is fresh for 60 seconds. It is proactively renewed once it turns 30 seconds old, so the public booking page’s poll cadence never outruns it (convex/domains/availability/domain/freeBusyCache.model.lib.ts:57-92). A grant that fails to report, or one that never connected, marks the row degraded rather than treating that calendar as empty (refreshBusy.ts:120-125, 180-185). The public page’s first paint calls getPublicMonthFresh. It refreshes only when a touched bucket is missing or due for renewal, then reads through the same query the client polls (convex/domains/availability/actions/getPublicMonthFresh.ts:19-42, 106-116).
Claiming a slot
Both the public “book this slot” mutation and the reschedule mutation route through one shared core,claimSlotCore. A claim is therefore validated and inserted exactly one way (convex/domains/bookings/domain/claimSlot.core.lib.ts:1-19). It validates the untrusted name and email before any read or write. It then resolves the link, organizer, and calendar grant, and replays an existing booking when the caller reuses an idempotency key (claimSlot.core.lib.ts:114-240).
The requested slot is then re-verified against live availability inside the same transaction. The host’s active bookings across every link in the affected window, plus the cached busy intervals, are read and fed back through computeSlots (claimSlot.core.lib.ts:242-424). This read is the concurrency gate. Two simultaneous claims for the same slot both read the host’s booking range, but only the first to commit succeeds. The second observes the now-taken slot and fails with CONFLICT (claimSlot.core.lib.ts:322-334, mutations/claimSlot.ts:32-37). The gate also fails closed. If any UTC-day bucket the slot’s buffered footprint touches is missing or stale, the claim is rejected rather than confirmed over unverified coverage (claimSlot.core.lib.ts:363-394). Only after the slot clears every check does the core upsert a contact and insert a pending booking with a fresh manageToken (claimSlot.core.lib.ts:426-483).
From there the claim mutation branches on the link’s requireConfirmation setting. A confirmation-required link leaves the booking pending and emails the host an approve/decline request. Every other link immediately schedules confirmBooking to create the calendar event (convex/domains/bookings/mutations/claimSlot.ts:82-92). This decision is captured once, on the booking row’s confirmationRequiredAtClaim field, so a later change to the link’s setting never alters an already-claimed booking.
Confirming the slot
confirmBooking moves the booking pending|failed → confirming. It then calls Nylas events.create on the link’s grant, listing the invitee, guests, and host as participants with notify_participants set (convex/domains/bookings/actions/confirmBooking.ts:106-156, 1021-1061). The calendar event’s description is built from the booking’s own details, plus separate reschedule and cancel manage links. The invite is therefore never a bare title (confirmBooking.ts:259-284).
Because Nylas exposes no idempotency key, the action first claims a PII-free, bookingId-scoped lock in the shared action-cache component. A concurrent or retried invocation that loses that claim skips events.create entirely (confirmBooking.ts:44-51, 959-1019). Once an eventId is durably attached to the booking, a later retry never re-creates the event. It re-fetches the existing one and resumes from there instead. A crash between creation and confirmation therefore cannot double-book the calendar (confirmBooking.ts:891-951). A calendar write failure retries with 2- and 10-second backoff, for up to two retries. The third failure marks the booking failed, releases the slot, and notifies the host. It also deletes any transferred event, so failed never orphans a live one (confirmBooking.ts:36-38, 173-226, 296-312).
If the booking is cancelled or declined while events.create is still in flight, the just-created event belongs to nobody. confirmBooking detects this on the next read and destroys the orphaned event, instead of attaching it (confirmBooking.ts:1071-1093).
Once the booking is durably confirmed, a best-effort tail runs step by step. Each step degrades independently, without re-running steps that already succeeded (confirmBooking.ts:606-741):
- A
BOOKING_CREATEDinteraction. - An opportunity capture keyed by
booking:{bookingId}. - A Recall notetaker bot, scheduled only when the link’s
automaticallyInviteKlipyis on (see Meeting notetaker). - Confirmation emails to both sides.
- Reminder planning.
- The
booking.createdevent. - A PostHog track.
The confirmation-required approval path
Approving a pending booking transitions itpending → confirming, records who decided and when, and schedules confirmBooking (convex/domains/bookings/mutations/approve.ts:101-125). Declining transitions it straight to the terminal declined status. If the booking carries a transferred calendar event, from a rescheduled confirmation-required booking re-entering approval, decline also deletes it so nothing is orphaned (convex/domains/bookings/mutations/decline.ts:98-124). A decline is emitted onto the bus as booking.cancelled — there is no separate booking.declined lifecycle event.
A host can also decide from the pending-approval email without opening Klipy. That link carries an HMAC-SHA-256-signed token: bookingId, action, and an expiry capped at the booking’s own start time. It is verified with a constant-time comparison (convex/domains/bookings/_shared/approvalLink.lib.ts:111-188). The action that verifies it re-dispatches through the exact same authenticated approve/decline mutations a host uses in-app. The token only proves which decision was requested. It can never bypass the ownership check those mutations already enforce against the clicking, signed-in user (convex/domains/bookings/actions/applySignedDecision.ts:16-30).
Rescheduling a confirmation-required booking defers the calendar handoff: the original row and its live event stay untouched while the replacement waits as pending. Only once the replacement is both approved and its calendar update succeeds does finalizeDeferredReschedule run. That one transaction cancels the source, clears its eventId, and transitions the replacement to confirmed with the same event id (convex/domains/bookings/mutations/rescheduleBooking.ts:93-163). An instant (non-confirmation) reschedule instead transfers the event and cancels the source synchronously, inside the reschedule mutation itself, before the calendar is even updated (rescheduleBooking.ts:322-355).
Reminders and calendar drift
Every host-configured attendee-reminder offset becomes its own scheduled job.planAttendeeReminders drops invalid or already-past offsets, de-duplicates repeats, and sorts what remains earliest-first (convex/domains/bookings/_shared/attendeeReminderPolicy.lib.ts:87-119). A host reminder, when enabled, reuses the earliest attendee offset, or falls back to a 30-minute default when none are configured (convex/domains/bookings/_shared/reminders.lib.ts:31-61). Scheduling the jobs and recording them both happen inside one mutation. A reschedule or a settings edit therefore replaces the prior set atomically, instead of appending duplicate jobs (reminders.lib.ts:26-29).
When a host edits the calendar event’s time directly in Google or Outlook, the resulting event.updated webhook reaches reconcileBookingsWithCalendarEventTimes. It patches the booking’s startTime/endTime and schedules replanRemindersAndNotify (convex/domains/bookings/primitives/reconcileBookingsWithCalendarEventTimes.ts:146-167). That action re-plans every reminder against the new time, emits booking.rescheduled, and sends the “rescheduled” email to both sides (convex/domains/bookings/actions/replanRemindersAndNotify.ts:34-83). This is the only path that sends that email as by: "host", since an in-app reschedule already carries its own status-aware notification. A legacy booked-era booking (pre-dating the native lifecycle) instead keeps a single reminder job at a fixed 30 minutes before start, rescheduled the same way.
Cancelling and rescheduling
Both mutations are reachable two ways: by the host from an authenticated session, or by the invitee holding the booking’smanageToken. Each resolves which one is acting before doing anything else. An authenticated session that owns the booking is always the host, regardless of any token also supplied. Otherwise, a byte-exact token match identifies the invitee (convex/domains/bookings/_shared/bookingActor.lib.ts:39-71). The host bypasses every link policy. The invitee is bound by allowCancel/allowReschedule and the link’s minimum-notice window — enforced server-side, regardless of what the client sends (convex/domains/bookings/domain/policy.lib.ts:86-180).
Cancelling transitions the booking to cancelled, tears down its reminder jobs, and — only if a calendar event exists — schedules a delete against it (convex/domains/bookings/mutations/cancelBooking.ts:105-131). Rescheduling claims the new slot first, through the same claimSlotCore used by a fresh claim, excluding the original booking from its own conflict check. If the new slot is already taken, this fails before the original booking is touched at all (convex/domains/bookings/mutations/rescheduleBooking.ts:261-284). The replacement row gets its own fresh manageToken — the invitee’s old manage link no longer authorizes it (rescheduleBooking.ts:296-309).
The actual Nylas write for a cancel or a reschedule is best-effort and self-contained. syncCalendarEvent retries once; a failure past that is reported at degraded impact, then left alone rather than retried indefinitely. A delete that stays degraded after its retry can leave the calendar event orphaned, since there is no durable retry queue behind it yet (convex/domains/bookings/actions/syncCalendarEvent.ts:22, 176-183).
Expiring unanswered requests
An hourly cron sweeps everypending booking whose start time has already passed into expired, in batches of up to 100 rows per run (convex/domains/bookings/actions/expirePendingBookings.ts:12-36). This catches a booking whose host never approved or declined it in time. A row that raced out of pending between the read and the transition — a concurrent approval, for instance — is skipped. It never aborts the rest of the batch. An expiring booking that carries a transferred calendar event has that event deleted, the same as a cancel or a decline.
Booking lifecycle events and webhook payloads
Four events reach Klipy’s internal event bus:booking.created, booking.pending, booking.cancelled, and booking.rescheduled. Each is scheduled fire-and-forget with a PII-safe payload of ids, status, and times (convex/domains/bookings/_shared/bookingEvents.lib.ts:60-106). Only three of those map to an external Svix subscriber event: booking.created, booking.rescheduled, and booking.cancelled. booking.pending has no external mapping and never leaves the internal bus (convex/components/svix/domain/svixEvent.model.ts:13-15, convex/infrastructure/webhooks/svix/eventTypeMapping.ts:1-15).
Each external event is normally enriched with the booking’s title, times, organizer, attendee, and guests before it reaches a subscriber (convex/infrastructure/webhooks/svix/enrichers/bookingCreated.ts:36-49). That enrichment looks the booking up by its externalId field (primitives/get.ts:16-24) — a deprecated field from the retired Nylas Scheduler integration. A native booking created through claimSlotCore never sets externalId on its row at all (primitives/create.ts). The bus payload’s externalId: booking._id (bookingEvents.lib.ts:86) is a value passed to the enricher — not something written back to that row. The lookup therefore finds nothing. Every external booking.* webhook today falls back to the minimal payload, { id: bookingId }, instead of the enriched shape the enricher was built to return.
Limits worth knowing
What Klipy stores and sends
Availability reads the host’s own weekly schedule and date overrides. It also reads free/busy data from the host’s own non-shared Nylas grants, fetched in windows of up to 35 days (convex/domains/availability/actions/refreshBusy.ts:16). A claim writes the booker’s name, email, notes, and any custom-field answers to a contact record and the booking row. The calendar event created from it lists the invitee, guests, and host as participants on the host’s primary calendar. The invitee’s manage token and the host’s signed approval-link token are both generated fresh per booking and never reused across bookings. External booking.* webhooks currently carry only the booking id, per the payload gap described above, until a subscriber resolves the rest through the API.
Related guides
Bookings overview
What booking links do and what the pre-meeting brief shows.
How do I create and manage a booking link?
Creating a link, setting its hours, and approving or rescheduling bookings.