Replace a named service period (admin, or manage_services)
/api/service-periodsWrites a whole period at once: "the period called name now runs on exactly these days, with these settings". No active period for a weekday means an empty availability grid that day, so this is the endpoint a venue's bookable times live or die by.
PUT, and wholesale, on purpose. A day of a period is not an entity an operator names; the PERIOD is, and it is identified by its name. There is nothing here for a per-row create to be idempotent about, and the old POST (one weekday per call) is what made a restaurant serving lunch and dinner all week fourteen separate writes.
One statement, therefore one transaction. The whole replacement happens inside book_replace_service_period_group() (migration 0029) rather than as a PostgREST delete followed by an insert. That is not tidiness: computeReservationSlots returns nothing for a day with no periods, so a delete that landed without its insert would take the venue's booking page offline until someone re-saved, not merely degrade it. On any error nothing is written and nothing is lost.
Gated to admin, or a staff login granted manage_services (migration 0082), hospitality's equivalent of the appointments services routes, and gated the same way: an empty days array deletes the group, so this one call is as destructive as it is creative.
Authorization
sessionCookie The dashboard's Supabase Auth session cookie, set at sign-in. Large sessions are split across
numbered chunks (…auth-token.0, .1), so treat this as a cookie family rather than one name.
Every request re-validates it against the Auth server (getUser()), never by decoding the cookie
locally: a JWT nothing has checked is not a credential. Tenancy is then read from the verified
app_metadata.company_id claim and enforced by row-level security; it is never read from request
input, on any route, ever.
role (admin / staff) is deliberately not in RLS. It gates specific actions in route code,
the operations marked admin below, so hiding a button in the UI is cosmetic only, and a route's
own check is the enforcement.
In: cookie
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X PUT "https://example.com/api/service-periods" \ -H "Content-Type: application/json" \ -d '{ "name": "string" }'{ "ok": true, "name": "string", "days": 0}Remove an area photo DELETE
Deletes the stored object and nulls `image_url`. Storage removal is best-effort and its failure does not fail the request.
Create a reservation (staff side) POST
A sitting taken at the host stand or over the phone. Always inserted as `confirmed`, never `hold`; a hold is a guest's half-finished checkout with an expiry and has no meaning for something staff enter deliberately. `turnMinutes` is a free field here, unlike an appointment's duration: a reservation has no service to snapshot a length from, which is exactly why 0011 gave it its own tables. `ends_at` is derived from it. `tableId` may be null; a venue that caps covers without assigning tables works as-is.