REST API
Five public endpoints under /api/reserve/ for availability checks, booking creation, cancellation, and customer search.
The plugin mounts five endpoints under /api/reserve/. These are Payload custom endpoints — they respect the same access control as the rest of the API.
GET /api/reserve/availability
Returns available time slots for a resource and service on a given date. Slots are derived from the resource's active schedules for that date minus any overlapping reservations with blocking statuses.
Returns 400 if date is missing or not a valid date format.
Query parameters:
| Parameter | Required | Description |
|---|---|---|
resource | Yes | Resource ID |
service | Yes | Service ID |
date | Yes | Date in YYYY-MM-DD format |
guestCount | No | Number of guests (used for per-guest capacity filtering) |
Example request:
Response:
Example fetch:
GET /api/reserve/slots
Returns available slots with richer metadata. Accepts an optional guestCount parameter for capacity-aware filtering.
Query parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
resource | Yes | — | Resource ID |
service | Yes | — | Service ID |
date | Yes | — | Date in YYYY-MM-DD format |
guestCount | No | 1 | Number of guests (used for per-guest capacity mode) |
Example request:
Response:
Returns 400 with { "error": "..." } if required parameters are missing or the date is invalid.
POST /api/reserve/book
Creates a new reservation. All Payload collection hooks (conflict detection, end time calculation, status transition validation) run as normal. Runs any registered beforeBookingCreate plugin hooks before saving.
Request body: Same as payload.create data for the reservations collection.
Response: 201 with the created reservation document, or 400/409 if validation fails.
The idempotencyKey field prevents duplicate submissions — if a key has already been used, the request is rejected with a validation error.
Example fetch:
POST /api/reserve/cancel
Cancels a reservation. Requires an authenticated session (req.user). Only the reservation's customer or an admin/staff user can cancel — non-owners receive 403 Forbidden.
Request body:
Response: 200 with the updated reservation document.
Returns 401 if not authenticated, 403 if the authenticated user is not the reservation's customer or an admin, 400 if reservationId is missing. The validateCancellation hook enforces the minimum notice period configured in cancellationNoticePeriod.
Example fetch:
GET /api/reserve/customers
Searches customers by name or email. Used internally by the admin CustomerField component. Restricted to admin/staff users — customer-collection users receive 403 Forbidden.
Query parameters:
| Parameter | Required | Description |
|---|---|---|
q | Yes | Search string (matches name and email) |
Response: Array of matching customer documents. Returns 401 if not authenticated, 403 if the user belongs to the customers collection.