API Reference
The Royal Glow API is a set of Next.js route handlers under/api. All
endpoints share one JSON envelope, human-readable RESTful paths, and stable
error codes — so both browsers and AI agents can call them predictably.
Base URLs: customer endpoints are on
https://theroyalglow.in
(local: http://localhost:3000); admin endpoint groups (Admin — Bookings,
Customers & CRM, the admin halves of Leads / Memberships / Loyalty & Offers,
and Background Jobs) are a separate app on https://admin.theroyalglow.in
(local: http://localhost:3001) and carry no /api/admin/ segment — the
subdomain is the namespace. Most endpoints require a Better Auth session
cookie and note their minimum role. This reference is hand-authored from
the actual route handlers and the shared Zod schemas in packages/types; when
a route’s schema changes, update the corresponding page.Base & envelope
- Success
- Error
meta is optional and carries pagination (page, totalPages, totalCount).Authentication
How roles and sessions work
How roles and sessions work
Most endpoints require a Better Auth session cookie. Each endpoint notes its
minimum role. Roles are hierarchical:
customer is the lowest, then
staff, receptionist, manager, owner, developer — a handler requiring
receptionist also admits everyone above it.Which endpoints are public (no auth)
Which endpoints are public (no auth)
GET /api/services, GET /api/services/[slug], GET /api/availability,
GET /api/offers, POST /api/leads, and GET /api/health need no session.Endpoint groups
Services & Availability
Catalogue, service detail, slot availability
Bookings (customer)
Create, view, cancel a booking
Admin — Bookings
Approve, assign, complete, no-show
Customers & CRM
Directory, profiles, notes, tags
Leads
Lead capture + admin pipeline
Memberships
Customer view + admin management
Loyalty & Offers
Gems and promotional offers
Notifications & Realtime
In-app, push, Ably token
Background Jobs
QStash-triggered job routes
Health
Liveness + dependency checks