Developer & REST API
This is the developer page — everything else in this guide is for the person running the space; this one is for the person writing code against it. Gather Grove Booking owns its own tables (wp_gg_*), and it exposes two ways to read and write that data safely: a public PHP service layer for code running inside WordPress (a sibling plugin, a snippet, a mu-plugin), and a REST API for the browser and outside callers. The golden rule for both: go through the published surface, never touch the tables directly — the services own the row locking, dedupe keys, and audit trail that keep bookings consistent.
Which surface to use
- Inside WordPress (another plugin, a functions snippet, a CLI command) — call the PHP service layer. It’s synchronous, it’s transactional, and it gives you the real return values.
- From the browser or an external system — call the REST API. The booking modal and Elementor widgets all run on it, so anything they can do, you can do.
Do not write to
wp_gg_*tables directly, and never resolve relationships by hand. The services exist precisely because a booking is a concurrency-sensitive, multi-table operation — seat counters are locked withSELECT … FOR UPDATE, balances are authoritative, and every mutation is logged. Bypassing them risks double-booked sessions and orphaned rows.
The public PHP service API
Four services under the namespace GatherGroveBookingServices are the supported, stable surface for cross-plugin code: BookingService, ClientService, BalanceService, and ClassService. These are the methods Gather Grove’s own Companion plugin calls, and their signatures are verified against the live source. The full reference lives in the repository at docs/PUBLIC_API.md.
Read these gotchas before you write a line
The four services were written at different times and do not share one uniform error convention. Getting this wrong is the most common mistake, so handle each service on its own terms.
- Branch on
status, notis_wp_error().BookingService::create_booking()andBalanceService::credit()/debit()report business outcomes through a structured array — check$result['status'](for example'success'vs'error'). They do not throw or return aWP_Errorfor a business failure. OnlyClassService::create_draft()returns aWP_Error, and that one you branch withis_wp_error(). - Never pass a WordPress user id where a
client_idis expected. Agg_clients.idis its own identifier and is not the same number as a WP user id. Always resolve the client first withClientService::get_or_create(), then pass that id. NeverINSERTintogg_clientsyourself. BookingServiceis instantiated; the other three are static. Write$svc = new BookingService();(no constructor args), but callClientService::get_or_create(…),BalanceService::credit(…), andClassService::query(…)statically.- Never expose
bypass_capacityon a public, REST, or ability surface. It is an instructor walk-in override that skips the seat check; it must only ever be set by trusted server-side admin code.
BookingService
Owns the concurrency-safe booking flow — the only supported way to create a booking. Instantiate it with new BookingService().
| Method | Returns | Notes |
|---|---|---|
create_booking( array $args ): array | array{ status, booking_id, message, data } | Creates a confirmed booking or waitlists the client. Branch on status; on failure the array also carries an error_code. Required $args: session_id; plus client_id (or guest_name/guest_email for a guest). payment_method => 'balance' triggers an in-transaction studio-credit debit. |
get_booking( int $booking_id ): ?object | row object or null | Single booking by id. |
get_bookings_for_session( int $session_id, string $status = 'confirmed' ): object[] | array of rows | All bookings on a session. |
get_bookings_for_client( int $client_id, string $status = '' ): object[] | array of rows | Empty $status returns all statuses. |
ClientService
Static methods. Owns the gg_clients dedupe key, so this is how you turn a WordPress user into a Booking client id.
| Method | Returns | Notes |
|---|---|---|
get_or_create( int $user_id, bool $is_guest = false ): int | int (the gg_clients.id), or 0 on failure | Resolve (or create) the client row for a WP user. Always resolve client ids this way. |
convert_guest( int $client_id ): bool | bool | Promote a guest client to a full client. |
is_email_verified( int $client_id ): bool | bool | Plus token helpers: generate_verification_token(), verify_email_with_token(). |
BalanceService
Static methods. Owns the studio-credit ledger; balance mutations happen only here. $amount is always a positive number — debit subtracts, credit adds.
| Method | Returns | Notes |
|---|---|---|
get_balance( int $client_id ): float | current balance (0.00 if none) | Display only. Do not gate a spend decision on this value — it’s racy; let debit() enforce the limit. |
credit( int $client_id, float $amount, string $reason = '', array $meta = [] ): array | array{ status, balance, transaction_id, message } | Branch on $result['status'] === 'success'. $reason shows in the transaction log. |
debit( int $client_id, float $amount, string $reason = '', array $meta = [] ): array | same shape | Refuses to overdraw unless $meta['allow_overdraft'] is truthy. |
Lower-level
*_within_txvariants exist for callers managing their own database transaction. Don’t reach for them from a sibling plugin — call the publiccredit()/debit()and let them manage their own transaction.
ClassService
Static methods. This is the one service that uses WP_Error. Query results are capped at 100 rows (default 20).
| Method | Returns | Notes |
|---|---|---|
query( array $args = [] ): array | array of class rows (id, name, status, mode, capacity, …, next_session_at) | Read-only listing. Filter by status, mode ('dropin'/'enrollment'), instructor_id, location_id, taxonomy, search, created_after, with limit/offset. |
create_draft( array $args ): int|WP_Error | int (new post id) or WP_Error | Creates a ggrove_class in draft so an admin reviews before it goes live (the session generator won’t run on it yet). Branch with is_wp_error(). name is required. |
get_next_session( int $class_id ): ?array | { id, start_datetime } or null | The next scheduled session for a class. |
Hook to listen for: after a successful draft insert,
create_draft()fires the actiongather_grove_class_draft_created( int $class_id, array $args ). Use it to react when a class draft is created — for example to notify a reviewer.
The REST API
Booking registers its routes under the namespace gather-grove/v1 — so a typical endpoint is /wp-json/gather-grove/v1/bookings. Every one of those routes is also mirrored to the canonical per-plugin namespace gather-grove/booking/v1, so /wp-json/gather-grove/booking/v1/bookings hits the same handler. Prefer the canonical namespace in new code; the legacy one stays for backward compatibility. (One wart: only gather-grove/v1 appears in the /wp-json/ discovery index — the mirrored routes work but aren’t listed there.)
Authentication patterns
Routes fall into a handful of authorization shapes. Match your call to the right one.
| Pattern | Used for | How it’s checked |
|---|---|---|
| Public / guest-scoped | Browsing sessions, validating a promo code, the booking-form fragment, creating a booking as a guest | permission_callback => '__return_true'. These are intentionally open so guests can book; the handler does its own per-request guarding (for example, rejecting a guest booking when the studio has disabled guest booking). |
| Logged-in | A client managing their own account, waivers, buying a pack or membership for themselves | is_user_logged_in(). The handler then resolves the caller’s own client id — it never trusts a client id from the request body. |
| Manage-capability | Admin and reporting actions: invoices, reports, instructor management | current_user_can( 'gg_manage_bookings' ). This is the studio-operator capability. |
| Owner / identity gate | Acting on one specific booking — cancel, leave a waitlist, approve | Allowed when the caller owns the booking or holds gg_manage_bookings. A few flows accept a narrowly-scoped fallback (for example, an unauthenticated cancel is allowed only for a still-unpaid booking via the JS payment-failure cleanup path). |
| Signed token | Email links — approve/decline a booking straight from an email, no login | A signed token (ApprovalService::verify_token) authorizes the action for that one booking, falling back to the capability or instructor-ownership path when a user is logged in. |
| Stripe signature | The Stripe webhook endpoint | permission_callback => '__return_true', but the handler verifies the Stripe webhook signature before doing anything — a missing or bad signature is rejected outright. This is a Stripe (customer-payment) signature, unrelated to Freemius licensing. |
For browser calls that go through the manage-capability or logged-in gates, send the standard WordPress REST nonce (
X-WP-Nonce) so WordPress authenticates the cookie session — that’s how the admin screens and widgets call these routes.
Pro-only controllers
Two controllers ship only in the paid build and are stripped from the free WordPress.org package, so their routes simply don’t register on a free site:
- Packages & memberships (
PackagesController) — the routes behind selling and managing class packs and memberships. Requires Professional. Note this gates creating and selling offerings; a client’s existing purchases and their consumption are always ungated. - Enrollments (
EnrollmentsController) — the routes for enrollment-course flows. Requires Professional.
The advanced report drilldown routes are likewise registered only on the paid build. If you call one of these endpoints on a free site you’ll get a 404, because the route was never registered — not a permission error. See Free vs Pro for the full tier breakdown, and remember that on a lapsed license these creation surfaces go read-only while existing data and client consumption keep working.
Adding a tab to a dashboard
Both member-facing dashboards are extensible, so a sibling plugin can put its own surface where members and staff already are:
gather_grove/booking/client_dashboard_tabs— tabs on the Client Dashboard widget.gather_grove/booking/instructor_dashboard_tabs— tabs on the Instructor Dashboard widget (Booking 1.65.0+).
Each filter receives an array of tab definitions and returns it with yours added — a slug, a label, and the callback that renders the panel. The tab bar renders whenever there is more than one place to go. Gather Grove Communities uses both: the client side carries Community and My Activity, and the instructor side carries Community and My Students.
Full REST route index
Every registered route, its methods, and its authorization shape — generated directly from the controllers in src/REST.
135 REST routes in the gather-grove/v1 namespace (mirrored at gather-grove/booking/v1). Generated from the live route registry, so it always matches the version you have installed. Route parameters appear as (?P<name>…) patterns.
| Method | Route |
|---|---|
| POST | /gather-grove/v1/appointments |
| POST | /gather-grove/v1/appointments/(?P<id>d+)/reschedule |
| GET | /gather-grove/v1/appointments/funding |
| POST | /gather-grove/v1/auth/login |
| GET, POST | /gather-grove/v1/auth/magic |
| POST | /gather-grove/v1/auth/magic-request |
| POST | /gather-grove/v1/auth/register |
| POST | /gather-grove/v1/auth/reset |
| POST | /gather-grove/v1/auth/reset-request |
| GET | /gather-grove/v1/booking-form |
| POST | /gather-grove/v1/bookings |
| GET | /gather-grove/v1/bookings/(?P<id>[w-]+) |
| GET, POST | /gather-grove/v1/bookings/(?P<id>[w-]+)/approve |
| POST | /gather-grove/v1/bookings/(?P<id>[w-]+)/cancel |
| GET, POST | /gather-grove/v1/bookings/(?P<id>[w-]+)/guest-waiver |
| GET, POST | /gather-grove/v1/bookings/(?P<id>[w-]+)/reject |
| GET, POST | /gather-grove/v1/bookings/(?P<id>[w-]+)/seats |
| GET | /gather-grove/v1/classes-fragment |
| GET, POST | /gather-grove/v1/client-waiver/(?P<id>[w-]+) |
| GET | /gather-grove/v1/clients/check-email |
| POST | /gather-grove/v1/course-checkout/balance |
| GET | /gather-grove/v1/desk/balances |
| POST | /gather-grove/v1/desk/bookings/(?P<id>d+)/cancel |
| GET | /gather-grove/v1/desk/bookings/(?P<id>d+)/cancel-preview |
| POST | /gather-grove/v1/desk/bookings/(?P<id>d+)/settle |
| GET | /gather-grove/v1/desk/calendar |
| GET | /gather-grove/v1/desk/clients |
| GET | /gather-grove/v1/desk/clients/(?P<id>d+)/card |
| POST | /gather-grove/v1/desk/clients/(?P<id>d+)/desk-notes |
| GET, POST | /gather-grove/v1/desk/clients/(?P<id>d+)/details |
| POST | /gather-grove/v1/desk/clients/(?P<id>d+)/gift-cards/redeem |
| POST | /gather-grove/v1/desk/clients/(?P<id>d+)/membership-card |
| GET | /gather-grove/v1/desk/clients/(?P<id>d+)/pay-options |
| POST | /gather-grove/v1/desk/clients/(?P<id>d+)/waivers/send |
| POST | /gather-grove/v1/desk/clients/(?P<id>d+)/waivers/sign |
| GET | /gather-grove/v1/desk/day |
| GET | /gather-grove/v1/desk/gift-cards/config |
| POST | /gather-grove/v1/desk/gift-cards/sell |
| POST | /gather-grove/v1/desk/membership/(?P<cp>d+)/cancel-pending |
| POST | /gather-grove/v1/desk/packs/(?P<cp>d+)/payment |
| GET, POST | /gather-grove/v1/desk/refunds/(?P<kind>[a-z]+)/(?P<id>d+) |
| POST | /gather-grove/v1/desk/season-fees/(?P<fee>d+)/payment |
| POST | /gather-grove/v1/desk/season-fees/(?P<fee>d+)/waive |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/attendance |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/book |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/enroll |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/membership |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/membership/(?P<cp>d+)/settle |
| GET | /gather-grove/v1/desk/sessions/(?P<id>d+)/roster |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/typed-card |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/waitlist |
| DELETE | /gather-grove/v1/desk/sessions/(?P<id>d+)/waitlist/(?P<waitlist_id>d+) |
| POST | /gather-grove/v1/desk/sessions/(?P<id>d+)/walk-in |
| POST | /gather-grove/v1/desk/typed-card/release |
| GET | /gather-grove/v1/desk/waivers/(?P<id>d+) |
| GET, POST | /gather-grove/v1/enrollments/(?P<id>d+)/approve |
| POST | /gather-grove/v1/enrollments/(?P<id>d+)/cancel |
| GET, POST | /gather-grove/v1/enrollments/(?P<id>d+)/reject |
| GET | /gather-grove/v1/enrollments/eligibility |
| POST | /gather-grove/v1/enrollments/purchase |
| GET | /gather-grove/v1/gift-cards/config |
| GET | /gather-grove/v1/gift-cards/print |
| POST | /gather-grove/v1/gift-cards/purchase |
| POST | /gather-grove/v1/gift-cards/redeem |
| GET | /gather-grove/v1/gift-cards/redeem-landing |
| POST | /gather-grove/v1/household/invite |
| POST | /gather-grove/v1/household/invites/(?P<id>d+)/cancel |
| POST | /gather-grove/v1/household/invites/(?P<id>d+)/resend |
| POST | /gather-grove/v1/household/link |
| POST | /gather-grove/v1/household/members |
| POST | /gather-grove/v1/household/members/(?P<id>d+)/billing |
| POST | /gather-grove/v1/household/members/(?P<id>d+)/manager |
| POST | /gather-grove/v1/household/members/(?P<id>d+)/remove |
| POST | /gather-grove/v1/household/members/(?P<id>d+)/rename |
| POST | /gather-grove/v1/household/members/(?P<id>d+)/update |
| POST | /gather-grove/v1/household/support |
| GET, POST | /gather-grove/v1/instructor/profile |
| POST | /gather-grove/v1/instructor/profile/photo |
| POST | /gather-grove/v1/instructor/sessions/(?P<id>d+)/cancel |
| POST | /gather-grove/v1/instructor/sessions/(?P<id>d+)/check-in |
| GET | /gather-grove/v1/instructor/sessions/(?P<id>d+)/late-cancel-preview |
| POST | /gather-grove/v1/instructor/sessions/(?P<id>d+)/message |
| POST, DELETE | /gather-grove/v1/instructor/sessions/(?P<id>d+)/sub-request |
| POST | /gather-grove/v1/instructor/sessions/(?P<id>d+)/walk-in |
| POST | /gather-grove/v1/instructor/sub-requests/(?P<id>d+)/claim |
| GET, POST | /gather-grove/v1/invoices |
| GET, PUT | /gather-grove/v1/invoices/(?P<id>d+) |
| GET | /gather-grove/v1/invoices/(?P<id>d+)/public |
| POST | /gather-grove/v1/invoices/(?P<id>d+)/send |
| POST | /gather-grove/v1/memberships/billing-options |
| POST | /gather-grove/v1/memberships/cancel |
| GET | /gather-grove/v1/memberships/my-memberships |
| POST | /gather-grove/v1/memberships/pay-ahead |
| POST | /gather-grove/v1/memberships/rate |
| POST | /gather-grove/v1/memberships/request |
| GET, POST | /gather-grove/v1/memberships/requests/(?P<id>[w-]+)/approve |
| GET, POST | /gather-grove/v1/memberships/requests/(?P<id>[w-]+)/reject |
| POST | /gather-grove/v1/memberships/subscribe |
| POST | /gather-grove/v1/memberships/subscribe-and-book |
| POST | /gather-grove/v1/memberships/subscribe-for |
| GET | /gather-grove/v1/nonce |
| GET | /gather-grove/v1/notifications |
| POST | /gather-grove/v1/notifications/(?P<id>d+)/dismiss |
| POST | /gather-grove/v1/notifications/(?P<id>d+)/read |
| POST | /gather-grove/v1/notifications/read-all |
| POST | /gather-grove/v1/open-balance/pay |
| GET | /gather-grove/v1/packages |
| GET | /gather-grove/v1/packages/available |
| POST | /gather-grove/v1/packages/purchase |
| POST | /gather-grove/v1/packages/purchase-and-book |
| POST | /gather-grove/v1/packages/purchase-for |
| GET | /gather-grove/v1/payment-methods |
| POST | /gather-grove/v1/payment-methods/default |
| POST | /gather-grove/v1/payment-methods/detach |
| POST | /gather-grove/v1/payment-methods/setup-intent |
| GET, POST | /gather-grove/v1/profile |
| GET, POST | /gather-grove/v1/profile/notification-prefs |
| POST | /gather-grove/v1/profile/photo |
| POST | /gather-grove/v1/promo/family-grant |
| POST | /gather-grove/v1/promo/validate |
| GET | /gather-grove/v1/rentals/availability |
| POST | /gather-grove/v1/rentals/request |
| GET | /gather-grove/v1/schedule-fragment |
| GET | /gather-grove/v1/services/(?P<id>d+)/slots |
| GET | /gather-grove/v1/session-credits |
| GET | /gather-grove/v1/sessions/(?P<id>[w-]+)/availability |
| GET | /gather-grove/v1/sessions/calendar |
| GET | /gather-grove/v1/statements/monthly |
| GET | /gather-grove/v1/verify-email |
| POST | /gather-grove/v1/waitlist/(?P<id>[w-]+)/leave |
| GET | /gather-grove/v1/waivers/(?P<id>d+) |
| GET | /gather-grove/v1/waivers/(?P<id>d+)/form |
| POST | /gather-grove/v1/waivers/(?P<id>d+)/sign |
| GET | /gather-grove/v1/waivers/owed |
| POST | /gather-grove/v1/webhooks/stripe |
Requirements & a note on Elementor
Booking needs WordPress 6.4+, PHP 8.2+, and the free Elementor plugin (for the widgets that render the booking UI). Elementor Pro is only needed to edit dynamic tags inside the Theme Builder — see the Dynamic tags reference. None of that affects the PHP services or REST API, which are available regardless. For the customer-payment side, see Payments, Stripe & commerce; that Stripe integration is entirely separate from Freemius, which is the merchant of record for plugin licensing only.
Applies to Gather Grove Booking v1.278.2. The reference tables on this page are generated from the plugin source — last synced November 11, 2026.