GraphQL API
Endpoint, authentication, generated CRUD, and every custom Tour Guide query and mutation.
GraphQL is served at /api/graphql. The checked-in schema.graphql in the repo is the reference for a revision. The custom operations return a JSON scalar, so read their shapes from the source in features/keystone/mutations/tour-*.ts.
Authentication
Staff sessions use the keystonejs-session cookie. Sign in with authenticateUserWithPassword, sign out with endSession. MCP clients can also use OAuth bearer tokens. Operator operations check the caller's Role flags. See Roles and permissions.
Guests have no session. The guest operations use proof:
- Hold token.
createDepartureHoldtakes atokenof 32 to 256 characters that the caller makes up. Only its SHA-256 hash is stored.checkoutHold,startBookingCheckout, andcompleteBookingCheckoutneed the same token. - Booking code and email.
lookupBookingandcancelMyBookingneed both. A wrong pair returns "Booking not found". - Link tokens. Waiver and rebook tokens are derived on the server.
waiverForToken,signWaiver, andrebookWithCredittake one.
Queries
| Query | Arguments | Access | Purpose |
|---|---|---|---|
toursOnSale | none | Public | Active tours with an upcoming on-sale departure, with ticket types, add-ons, meeting point, and policy |
tourAvailability | tourId, from, to | Public | Bookable departures with seats left. At most 92 days |
checkoutHold | holdId, token | Hold token | The held quote, expiry, and booking code if any |
lookupBooking | bookingRef, email | Code and email | Booking, lines, guests, meeting point, waiver links, refund if cancelled now |
waiverForToken | token | Link token | Waiver text for one participant |
operatorName | none | Public | Operator name from settings |
tourTotal | none | Signed in (returns 0 without a session) | Number of tours, used by the setup card |
departuresInRange | from, to | canCheckIn | Departures with booked and held seats, guides, waiver gaps, staffing. At most 31 days |
departureManifest | departureId | canCheckIn | Bookings and participants for a departure |
redirectToInit | none | Public | True while there are no users |
bookingRefExists | bookingRef | Public | Whether a code exists (no guest details), so an unknown booking page is a 404 |
manageBooking | bookingRef, token | Manage link | The booking, what can change, move targets, refund if cancelled now |
partyChangeQuote | bookingRef, token, input | Manage link | Price of a party change and the difference to pay or refund |
waitlistStatus | entryId, token | Waitlist link | Place in line and any held offer |
giftCardBalance | code | Public | What a code is worth. Same answer for a wrong and a void code |
isGuide | none | Signed in | Whether the user is a guide |
bookingMoveOptions | bookingId | canManageBookings | Departures a booking can move to (same tour, same price, room) |
bookingParty, bookingPartyQuote | bookingId, input | canManageBookings | The current party, and the price of a change |
operatorBookingByKey | idempotencyKey | canManageBookings | Whether a timed-out staff booking committed |
waitlistBoard | status | canManageBookings | Open waitlist entries and offers, or all |
participantWaiver | participantId | canCheckIn | Waiver text for on-site signing |
myDepartures | days | canCheckIn, as a guide | The signed-in guide's accepted departures |
pickupSheet, dayPickupSheet | departureId or day | canCheckIn | Printable pickup sheet. Guides see only their own departures |
pricingRuleBoard | none | canManageTours | Pricing rules with their tours and ticket types |
giftCardBoard | search | canManagePayments | Gift cards, ledger, outstanding balance |
salesReport | from, to, basis | canReadPayments | Sales totals, occupancy, weekly trend. At most 400 days |
Mutations
Every mutation that changes data takes an idempotencyKey of up to 200 characters. Reusing a key with the same input returns the first result. Reusing it with different input fails.
| Mutation | Access | What it does |
|---|---|---|
createDepartureHold(input, idempotencyKey) | Public | Holds seats for 10 minutes and returns a quote. Optional promo code |
startBookingCheckout(input, idempotencyKey) | Hold token | Creates a pending_payment booking and a Stripe payment intent. Returns the client secret |
completeBookingCheckout(input, idempotencyKey) | Hold token | Confirms the payment with Stripe and the seats |
cancelMyBooking(bookingRef, email, idempotencyKey) | Code and email | Cancels by policy and refunds |
signWaiver(input, idempotencyKey) | Link token | Records a waiver signature |
rebookWithCredit(input, idempotencyKey) | Link token | Books a departure of the same tour with a credit |
createChannelBooking(input, idempotencyKey) | canManageBookings | Phone, walk-up, or reseller booking |
generateDepartures(input, idempotencyKey) | canManageDepartures | Creates departures from schedules |
sweepDepartures(idempotencyKey) | canManageDepartures | Flags short departures, closes past the cutoff |
resizeDeparture(input, idempotencyKey) | canManageDepartures | Changes capacity |
cancelDeparture(input, idempotencyKey) | canManageDepartures | Cancels and refunds, or offers credit |
closeDeparture(input, idempotencyKey) | canManageDepartures | Completes an ended departure and drafts guide payouts |
assignGuide(input, idempotencyKey) | canManageGuides | Offers a departure to a guide |
respondToAssignment(input, idempotencyKey) | Guide or canManageGuides | Accepts or declines |
assignResource(input, idempotencyKey) | canManageResources | Assigns a vehicle or pool |
checkInParticipant(input, idempotencyKey) | canCheckIn | Checks one guest in |
markNoShow(input, idempotencyKey) | canCheckIn | Marks a booking no-show |
generateChannelStatement(input, idempotencyKey) | canManageChannels | Builds a reseller statement |
requestRefundApproval(bookingId, reason, amount) | canIssueRefunds | Opens a refund approval |
approveRefund(approvalId) | canIssueRefunds | Approves it, as a different user |
refundBooking(input, idempotencyKey) | canIssueRefunds | Refunds. Returns the booking code and refund id |
ensureTourOnboardingRecord(entity, data) | canManageOnboarding | Setup helper, allow-listed entities only |
seedTourActivity(template, seed) | canManageOnboarding | Setup helper for departures and bookings |
updateActiveUser(data) | Signed in | Updates the user's name or onboarding status only |
cancelManagedBooking(bookingRef, token, idempotencyKey) | Manage link | Cancels under the booking's policy snapshot and refunds |
rescheduleManagedBooking(bookingRef, token, departureId, idempotencyKey) | Manage link | Moves the same booking to another departure of the same tour |
changeParty(bookingRef, token, input, idempotencyKey) | Manage link | Changes the party. Starts a card payment for a difference |
completePartyChange(bookingRef, token, changeId, idempotencyKey) | Manage link | Applies a paid party change. Safe to repeat |
joinWaitlist(input, idempotencyKey) | Public | Joins the waitlist and returns the private link |
claimWaitlistOffer(entryId, token, cartToken) | Waitlist link | Takes a held offer into checkout |
leaveWaitlist(entryId, token, idempotencyKey) | Waitlist link | Leaves the waitlist or turns down an offer |
moveBooking(input, idempotencyKey) | canManageBookings | Moves a booking until its departure starts |
changeBookingParty(input, idempotencyKey) | canManageBookings (refund part needs canIssueRefunds) | Staff party change |
resetGuestLink(input, idempotencyKey) | canManageBookings | Invalidates the old manage link and returns a new one |
addToWaitlist(input, idempotencyKey) | canManageBookings | Adds a phone caller to the waitlist |
bookWaitlistOffer(input, idempotencyKey) | canManageBookings | Books an open offer for cash at the held quote |
withdrawWaitlistEntry(input, idempotencyKey) | canManageBookings | Removes a waitlist entry |
rebookWeatherBooking(input, idempotencyKey) | canManageBookings | Moves a weather-cancelled booking to another departure at the paid amount |
weatherCancelDeparture(input, idempotencyKey) | canManageDepartures | Cancels for weather with a required reason. Each booking then waits for a rebook or refund |
unassignResource(input, idempotencyKey) | canManageResources | Removes a resource from a departure |
undoNoShow(input, idempotencyKey) | canCheckIn | Reverses a no-show before the departure completes |
syncOfflineCheckIns(input, idempotencyKey) | canCheckIn | Applies queued offline taps in order, one audit row per tap |
captureWaiverOnSite(input, idempotencyKey) | canCheckIn | Records a waiver signed on the guide's device |
savePricingRule(input, idempotencyKey), removePricingRule(input, idempotencyKey) | canManageTours | Edits seasonal pricing rules |
issueGiftCard(input, idempotencyKey) | canManagePayments | Sells a card for cash or issues a voucher. Returns the code |
revealGiftCardCode(id) | canManagePayments | Shows a code again. Audited |
voidGiftCard(input, idempotencyKey) | canManagePayments | Voids a card and writes off its balance |
transitionGuidePayout(input, idempotencyKey) | canManageGuides and canManagePayments | Records a guide payout state. No money moves |
transitionChannelStatement(input, idempotencyKey) | canManageChannels and canManagePayments | Records a reseller statement as paid. No money moves |
exportSalesCsv(input) | canReadPayments | Builds the sales CSV. Each export is audited |
Input shapes
input DepartureHoldInput { departureId: ID!, tickets: [TourTicketChoice!]!, addOns: [TourTicketChoice!], promoCode: String, token: String! }
input StartBookingCheckoutInput { holdId: ID!, token: String!, lead: BookingLeadInput!, participants: [BookingParticipantInput!]! }
input RefundBookingInput { bookingId: ID!, amountCents: Int!, reason: String!, approvalId: ID, cancelBooking: Boolean }
input CancelDepartureInput { departureId: ID!, reason: String!, offerCredit: Boolean }requestRefundApproval and approveRefund take no idempotencyKey.
Example: hold seats
mutation Hold($input: DepartureHoldInput!) {
createDepartureHold(input: $input, idempotencyKey: "hold-123")
}{
"input": {
"departureId": "…",
"tickets": [{ "id": "…", "qty": 2 }],
"token": "a-random-string-of-at-least-32-characters"
}
}Capacity, in short
Seats left for a departure are its capacity minus booked seats, minus seats in unexpired holds, minus unsold channel allocation. Every operation that changes seats takes a transaction lock on the departure and counts again before it writes.
Generated CRUD
Lists keep generated queries. Generated create and update are blocked for command-only lists: Booking, BookingLine, InventoryHold, Departure, Participant, WaiverSignature, GuideAssignment, ResourceAssignment, GuidePayout, ChannelStatement, OperationalTask, PromoRedemption, and AuditEvent. No list allows generated delete. Status select fields can be set at creation but not changed by update.
Webhook and assistant
POST /api/webhooks/payment/[provider]for Stripe events./api/completionis the dashboard assistant./api/mcp-transport/[transport]is its MCP endpoint. It has generic tools (listModels,queryData,searchModels,getFieldsForType,lookupInputType,createData,updateData,deleteData,modelSpecificSearch) and runs as the caller, so list access still applies. It adds no tour-specific tools. A request without a session or token gets 401.