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. createDepartureHold takes a token of 32 to 256 characters that the caller makes up. Only its SHA-256 hash is stored. checkoutHold, startBookingCheckout, and completeBookingCheckout need the same token.
  • Booking code and email. lookupBooking and cancelMyBooking need both. A wrong pair returns "Booking not found".
  • Link tokens. Waiver and rebook tokens are derived on the server. waiverForToken, signWaiver, and rebookWithCredit take one.

Queries

QueryArgumentsAccessPurpose
toursOnSalenonePublicActive tours with an upcoming on-sale departure, with ticket types, add-ons, meeting point, and policy
tourAvailabilitytourId, from, toPublicBookable departures with seats left. At most 92 days
checkoutHoldholdId, tokenHold tokenThe held quote, expiry, and booking code if any
lookupBookingbookingRef, emailCode and emailBooking, lines, guests, meeting point, waiver links, refund if cancelled now
waiverForTokentokenLink tokenWaiver text for one participant
operatorNamenonePublicOperator name from settings
tourTotalnoneSigned in (returns 0 without a session)Number of tours, used by the setup card
departuresInRangefrom, tocanCheckInDepartures with booked and held seats, guides, waiver gaps, staffing. At most 31 days
departureManifestdepartureIdcanCheckInBookings and participants for a departure
redirectToInitnonePublicTrue while there are no users
bookingRefExistsbookingRefPublicWhether a code exists (no guest details), so an unknown booking page is a 404
manageBookingbookingRef, tokenManage linkThe booking, what can change, move targets, refund if cancelled now
partyChangeQuotebookingRef, token, inputManage linkPrice of a party change and the difference to pay or refund
waitlistStatusentryId, tokenWaitlist linkPlace in line and any held offer
giftCardBalancecodePublicWhat a code is worth. Same answer for a wrong and a void code
isGuidenoneSigned inWhether the user is a guide
bookingMoveOptionsbookingIdcanManageBookingsDepartures a booking can move to (same tour, same price, room)
bookingParty, bookingPartyQuotebookingId, inputcanManageBookingsThe current party, and the price of a change
operatorBookingByKeyidempotencyKeycanManageBookingsWhether a timed-out staff booking committed
waitlistBoardstatuscanManageBookingsOpen waitlist entries and offers, or all
participantWaiverparticipantIdcanCheckInWaiver text for on-site signing
myDeparturesdayscanCheckIn, as a guideThe signed-in guide's accepted departures
pickupSheet, dayPickupSheetdepartureId or daycanCheckInPrintable pickup sheet. Guides see only their own departures
pricingRuleBoardnonecanManageToursPricing rules with their tours and ticket types
giftCardBoardsearchcanManagePaymentsGift cards, ledger, outstanding balance
salesReportfrom, to, basiscanReadPaymentsSales 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.

MutationAccessWhat it does
createDepartureHold(input, idempotencyKey)PublicHolds seats for 10 minutes and returns a quote. Optional promo code
startBookingCheckout(input, idempotencyKey)Hold tokenCreates a pending_payment booking and a Stripe payment intent. Returns the client secret
completeBookingCheckout(input, idempotencyKey)Hold tokenConfirms the payment with Stripe and the seats
cancelMyBooking(bookingRef, email, idempotencyKey)Code and emailCancels by policy and refunds
signWaiver(input, idempotencyKey)Link tokenRecords a waiver signature
rebookWithCredit(input, idempotencyKey)Link tokenBooks a departure of the same tour with a credit
createChannelBooking(input, idempotencyKey)canManageBookingsPhone, walk-up, or reseller booking
generateDepartures(input, idempotencyKey)canManageDeparturesCreates departures from schedules
sweepDepartures(idempotencyKey)canManageDeparturesFlags short departures, closes past the cutoff
resizeDeparture(input, idempotencyKey)canManageDeparturesChanges capacity
cancelDeparture(input, idempotencyKey)canManageDeparturesCancels and refunds, or offers credit
closeDeparture(input, idempotencyKey)canManageDeparturesCompletes an ended departure and drafts guide payouts
assignGuide(input, idempotencyKey)canManageGuidesOffers a departure to a guide
respondToAssignment(input, idempotencyKey)Guide or canManageGuidesAccepts or declines
assignResource(input, idempotencyKey)canManageResourcesAssigns a vehicle or pool
checkInParticipant(input, idempotencyKey)canCheckInChecks one guest in
markNoShow(input, idempotencyKey)canCheckInMarks a booking no-show
generateChannelStatement(input, idempotencyKey)canManageChannelsBuilds a reseller statement
requestRefundApproval(bookingId, reason, amount)canIssueRefundsOpens a refund approval
approveRefund(approvalId)canIssueRefundsApproves it, as a different user
refundBooking(input, idempotencyKey)canIssueRefundsRefunds. Returns the booking code and refund id
ensureTourOnboardingRecord(entity, data)canManageOnboardingSetup helper, allow-listed entities only
seedTourActivity(template, seed)canManageOnboardingSetup helper for departures and bookings
updateActiveUser(data)Signed inUpdates the user's name or onboarding status only
cancelManagedBooking(bookingRef, token, idempotencyKey)Manage linkCancels under the booking's policy snapshot and refunds
rescheduleManagedBooking(bookingRef, token, departureId, idempotencyKey)Manage linkMoves the same booking to another departure of the same tour
changeParty(bookingRef, token, input, idempotencyKey)Manage linkChanges the party. Starts a card payment for a difference
completePartyChange(bookingRef, token, changeId, idempotencyKey)Manage linkApplies a paid party change. Safe to repeat
joinWaitlist(input, idempotencyKey)PublicJoins the waitlist and returns the private link
claimWaitlistOffer(entryId, token, cartToken)Waitlist linkTakes a held offer into checkout
leaveWaitlist(entryId, token, idempotencyKey)Waitlist linkLeaves the waitlist or turns down an offer
moveBooking(input, idempotencyKey)canManageBookingsMoves a booking until its departure starts
changeBookingParty(input, idempotencyKey)canManageBookings (refund part needs canIssueRefunds)Staff party change
resetGuestLink(input, idempotencyKey)canManageBookingsInvalidates the old manage link and returns a new one
addToWaitlist(input, idempotencyKey)canManageBookingsAdds a phone caller to the waitlist
bookWaitlistOffer(input, idempotencyKey)canManageBookingsBooks an open offer for cash at the held quote
withdrawWaitlistEntry(input, idempotencyKey)canManageBookingsRemoves a waitlist entry
rebookWeatherBooking(input, idempotencyKey)canManageBookingsMoves a weather-cancelled booking to another departure at the paid amount
weatherCancelDeparture(input, idempotencyKey)canManageDeparturesCancels for weather with a required reason. Each booking then waits for a rebook or refund
unassignResource(input, idempotencyKey)canManageResourcesRemoves a resource from a departure
undoNoShow(input, idempotencyKey)canCheckInReverses a no-show before the departure completes
syncOfflineCheckIns(input, idempotencyKey)canCheckInApplies queued offline taps in order, one audit row per tap
captureWaiverOnSite(input, idempotencyKey)canCheckInRecords a waiver signed on the guide's device
savePricingRule(input, idempotencyKey), removePricingRule(input, idempotencyKey)canManageToursEdits seasonal pricing rules
issueGiftCard(input, idempotencyKey)canManagePaymentsSells a card for cash or issues a voucher. Returns the code
revealGiftCardCode(id)canManagePaymentsShows a code again. Audited
voidGiftCard(input, idempotencyKey)canManagePaymentsVoids a card and writes off its balance
transitionGuidePayout(input, idempotencyKey)canManageGuides and canManagePaymentsRecords a guide payout state. No money moves
transitionChannelStatement(input, idempotencyKey)canManageChannels and canManagePaymentsRecords a reseller statement as paid. No money moves
exportSalesCsv(input)canReadPaymentsBuilds 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/completion is 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.

On this page