# Bookings (/docs/scheduling/bookings)

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
const eventTypeId = "evtype_01kd2m9a0b1c2d3e4f5g6h7j8m";
// ---cut---
const { data: booking, error } = await coss.scheduling.bookings.create({
  event_type: eventTypeId,
  start: "2027-01-04T15:00:00Z",
  attendee: { uid: "patient_77", name: "Sam Lee", email: "sam@example.com", time_zone: "UTC" },
});
if (error?.code === "slot_unavailable") {
  // Someone else got there first: show the slots again.
}
```

The SDK retries safely: every attempt carries the same `Idempotency-Key`, so a lost response can't
book twice. A refused request keeps no key.

## Describing an event type [#describing-an-event-type]

Give an event type a `description` of up to 2,000 characters of plain text. It's shown on hosted booking pages,
where `https://` links are clickable, and never in emails or calendar events.

Links, and anything shaped like a domain, must be on your organization's
[verified domains](/docs/email/domains) or their subdomains, or saving answers `content_refused`. In live environments
the text is also screened for phishing and spam, like the title.
## Why isn't a time available? [#why-isnt-a-time-available]

`coss.scheduling.slots.explain` says whether one start can be booked right now and, if not, why, for each
host who could take it. It's decided the same way a booking is, including their calendars.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
const eventTypeId = "evtype_01kd2m9a0b1c2d3e4f5g6h7j8m";
// ---cut---
const { data } = await coss.scheduling.slots.explain(eventTypeId, {
  start: "2027-01-04T15:00:00.000Z",
});
console.log(data?.available, data?.reason); // false "host_busy"
```

| `reason` | What it means |
|---|---|
| `not_on_grid` | It isn't one of the event type's start times. |
| `too_soon` | It's inside the minimum notice. |
| `outside_booking_window` | It's outside how far ahead people can book. |
| `out_of_office` | The host is [away](/docs/scheduling/out-of-office). Why isn't said. |
| `outside_coverage` | They're only covering for someone at other times. |
| `calendar_unverified` | The host's calendar can't be read right now. `calendar_reason` says why. |
| `outside_availability` | It's outside the host's working hours. |
| `host_busy` | Something on the host's calendar overlaps it, with buffers. |
| `already_claimed` | Another booking or hold overlaps it, with buffers. |
| `limit_reached` | A booking limit for that day or week is used up. |
| `session_full` | A group session at that time has no seats left. |
| `event_type_inactive` | The event type isn't active. |
| `no_hosts` | No active host can take this event type. |

It tells you when a host is busy, so use it for support and debugging rather than showing it to attendees. To
ask why a whole range is empty, without naming a start, use `coss scheduling diagnose` or the MCP server's
`diagnose_scheduling_slots`.

## Taking payment first [#taking-payment-first]

Hold the slot, charge the customer, then confirm. Live holds need Pro, Scale and Enterprise. A hold isn't charged and tells nobody. Its slot stays
yours until it expires, though a plan's usage limit can still refuse the confirmation.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
const eventTypeId = "evtype_01kd2m9a0b1c2d3e4f5g6h7j8m";
// ---cut---
const { data: hold } = await coss.scheduling.holds.create({
  event_type: eventTypeId,
  start: "2027-01-04T15:00:00Z",
  attendee: { uid: "patient_77", name: "Sam Lee", email: "sam@example.com", time_zone: "UTC" },
});
// hold?.hold_expires_at: ten minutes by default (the event type's hold_ttl_seconds).

// ...take the payment, then:
await coss.scheduling.holds.confirm(hold!.id);
```

After a hold expires, confirming answers `hold_expired`, or books anyway with `if_still_free` if nobody
else took the slot. `coss.scheduling.holds.release` gives a slot back early.

## Approval [#approval]

An event type with `requires_approval` makes each booking `pending_approval`. The time stays blocked
until `approve`, `decline`, or the deadline (`approval_ttl_minutes`), which declines it. Nothing's
charged or added to a calendar until it's approved.

## Questions [#questions]

An event type can ask `questions`, answered in `answers`. Answers are encrypted, and only come back
when you retrieve one booking: never in lists, webhooks, logs, emails or calendars. See
[Privacy](/docs/scheduling/privacy) before asking anything sensitive.

## Guests [#guests]

An attendee can bring other people. Set `max_guests` on the event type (up to 10; the default is 0, and a `group`
event type takes none, since each person books a seat), then pass them when booking. The hosted booker offers it too.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
// ---cut---
await coss.scheduling.bookings.create({
  event_type: "evtype_01kd2m9a0b1c2d3e4f5g6h7j8m",
  start: "2027-01-04T15:00:00.000Z",
  attendee: { name: "Sam Lee", email: "sam@example.com", time_zone: "America/New_York" },
  guests: [{ email: "jo@example.com", name: "Jo Park" }],
});
```

Guests come after the attendee in `attendees`, with the `role` `guest`. With attendee emails on, they get the same
confirmation, calendar invite, reminder and changes, in the attendee's time zone, but no link to change the booking,
and they hear nothing until it's confirmed. Answers belong to the attendee, and guests aren't counted as seats or
extra bookings.

Guests didn't ask to hear from anyone, so in live environments they're emailed only from your own
[`email_from`](/docs/scheduling/notifications), never coss.com's address. Without a verified one they're still on the
booking and its calendar event, and telling them is up to you.

## Limiting bookings per person [#limiting-bookings-per-person]

Set `max_active_bookings_per_attendee` on an event type to cap how many upcoming bookings of it one person can have
at a time. Booking past it answers `attendee_limit_reached`, without saying what they've booked.

People are known by `uid` or email, and bookings matching either count. Someone booking with neither isn't limited.
Holds, bookings awaiting approval and every occurrence of a series count, and a series that wouldn't fit is refused
whole. Guests don't count, and rescheduling an upcoming booking doesn't use up another. Confirming a hold or approving
a request that's expired, or moving a past booking into the future, has to fit like a new booking.

On a booking page where people type their own details, that answer tells whoever's typing that the address is at the
limit for this event type. If that matters, fill in the attendee when you create the session.

## Rescheduling and cancelling [#rescheduling-and-cancelling]

`reschedule` keeps the booking's id, and its old time stays booked unless the new one's free. Your API
key can always do both. Attendees using a [manage link](/docs/scheduling/embedding) are held to the event
type's `cancel_notice_minutes` and `reschedule_notice_minutes`.

## Recurring series [#recurring-series]

A series books up to 52 occurrences at the attendee's local time, so a weekly 10:00 stays 10:00 across a
clock change. Each is an ordinary booking that can move on its own, and a pool keeps one host throughout.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
const eventTypeId = "evtype_01kd2m9a0b1c2d3e4f5g6h7j8m";
// ---cut---
const params = {
  event_type: eventTypeId,
  start: "2027-01-04T15:00:00Z",
  attendee: { uid: "patient_77", time_zone: "America/New_York" },
  recurrence: { frequency: "weekly" as const, count: 12 },
  on_conflict: "skip" as const,
};

const { data: preview } = await coss.scheduling.series.preview(params);
const { data: series } = await coss.scheduling.series.create(params);
// series?.conflicts lists any occurrence that wasn't free.
```

With `on_conflict: "reject"`, the default, one taken occurrence books nothing.

## Booking history [#booking-history]

`coss.scheduling.bookings.events` lists what's happened to a booking, oldest first, and who did it.

```ts twoslash
import { Coss } from "coss";
const coss = new Coss();
const bookingId = "booking_01kd2m9a0b1c2d3e4f5g6h7j8m";
// ---cut---
const { data } = await coss.scheduling.bookings.events(bookingId);
for (const event of data?.data ?? []) {
  console.log(event.occurred_at, event.type, event.actor.kind);
}
```

A cancelled booking also has `cancelled_by`. Pass an optional `reason` when cancelling, as the hosted manage page
lets attendees do, and retrieving that one booking returns it as `cancellation_reason`. It's encrypted, and never
appears in the history, webhooks, logs or emails. It's erased with the attendee's details.

## Webhooks [#webhooks]

Bookings send `scheduling.booking.confirmed`, `.pending_approval`, `.rescheduled`, `.cancelled`,
`.declined`, `.no_show`, `.external_conflict`, `.calendar_write_failed`, `.location_ready`, `.started`,
`.ended` and `.reminder`. They carry ids, times and statuses only. Retrieve the booking for anything about the
person. `.started` and `.ended` fire at the booking's own times, and `.reminder` at
[any time you choose](/docs/scheduling/reminders#webhooks-at-any-moment).

## No-shows [#no-shows]

Once a booking has started, `coss.scheduling.bookings.markNoShow(id)` records that the attendee didn't come. It
sends `scheduling.booking.no_show`, stops follow-ups and sends any
[reminder timed from it](/docs/scheduling/reminders#after-a-no-show-or-a-cancellation). It can't be undone, and
marking it again changes nothing.
