---
title: "Open, close, or toggle waitlist-only over a date range"
method: POST
path: "/api/v1/availability-rules"
tags: ["Capacity"]
---

# Open, close, or toggle waitlist-only over a date range

`POST /api/v1/availability-rules`

## Request

- Base URL: `https://www.gerezi.com`
- URL: `https://www.gerezi.com/api/v1/availability-rules`
- Auth: HTTP bearer

Backs the MCP `set_weekly_availability` and `set_waitlist_mode` tools. For each date in [date_from, date_to] whose weekday is in `weekdays` (omit `weekdays` for every day):

• `action:"close"` ensures a CLOSED AvailabilityRule (Schedule Exception) covers the date for the scope (restaurant-wide when `service_period_id` is omitted, else per-period). Existing bookings are surfaced in the response, NEVER cancelled.

• `action:"open"` carves overlapping CLOSED AvailabilityRules (and, at restaurant scope, ClosurePeriods) so they no longer cover the target dates; when a restaurant-wide rule is carved for a single-period open, the other periods are re-closed on those dates. Optional `cap` sets a floor-clamped per-date CapacityOverride. A date whose period doesn't run that weekday is reported `could_not_open` (never silently skipped). Does NOT lift WAITLIST_ONLY rules — those dates come back `could_not_open` with `closed_reason_kind:"WAITLIST_ONLY"`; use `waitlist_off`.

• `action:"waitlist_on"` / `"waitlist_off"` toggle the WAITLIST_ONLY mode (guests can only join the waitlist; staff can still book via POST /bookings with `force_closed:true`). Same idempotency/carve semantics as close/open; turning off one period inside a restaurant-wide window keeps the other periods gated.

Every result row is read back through the shared date-gate so the response reflects the true post-state. Idempotent, reversible (DELETE /api/v1/availability-rules/:id), audit-logged. Window capped at 180 days. Scope: `bookings:write`.

## Request body

- object
  - `restaurant_id` string: Required for org-level keys.
  - `weekdays` integer[]: 1=Mon … 7=Sun. Omit for every day in the window.
  - `date_from` string, required
  - `date_to` string, required
  - `action` 'open' | 'close' | 'waitlist_on' | 'waitlist_off', required
  - `service_period_id` string: Omit to act on all active periods (restaurant-wide).
  - `cap` integer: action=open only. Per-date capacity override, floor-clamped.
  - `reason` string

## Response `200`

Per-date result rows + summary (opened/closed/waitlisted/lifted/unchanged/could_not/affected_bookings)

---

[API](https://skmtc.dev/gerezi/apis/gerezi-restaurant-api.md) · [All operations](https://skmtc.dev/gerezi/apis/gerezi-restaurant-api/llms.txt) · [OpenAPI document](https://skmtc.dev/gerezi/apis/gerezi-restaurant-api/revisions/323b530e81cb?raw)
