Jetron TicketFluid

Client & methods

createClient options, methods, and the ApiResult envelope.

Creating a client

import { createClient } from '@jetronticket/api'

const client = createClient({
  apiKey: 'jt_public_...',
})

Prop

Type

Methods

One method per endpoint:

MethodEndpoint
health()GET /health (unauthenticated)
getHost(options?)GET /host
listEvents(params?)GET /events
getEvent(slug, options?)GET /events/{slug}
getEventGallery(slug, options?)GET /events/{slug}/gallery
listSponsors(slug, options?)GET /events/{slug}/sponsors
listMoments(slug, params?)GET /events/{slug}/moments (pass limit and cursor to page)
listTickets(slug, options?)GET /events/{slug}/tickets (pass saleId to scope to one sale)
listAddons(slug, options?)GET /events/{slug}/addons
listSales(slug, options?)GET /events/{slug}/sales
verifySalePassword(slug, saleId, body, options?)POST /events/{slug}/sales/{saleId}/verify-password
joinSaleWaitlist(slug, saleId, body, options?)POST /events/{slug}/sales/{saleId}/waitlist
validatePromoCode(slug, body, options?)POST /events/{slug}/promo-codes/validate
createReservation(slug, body, options?)POST /events/{slug}/reservations
releaseReservation(slug, options?)DELETE /events/{slug}/reservations
createOrder(slug, body, options?)POST /events/{slug}/orders
getOrder(slug, reference, options?)GET /events/{slug}/orders/{reference}
lookupAttendeeTickets(body, options?)POST /attendees/tickets/lookup (private key, server only)
lookupAttendeeAddons(body, options?)POST /attendees/addons/lookup (private key, server only)

Every method accepts per-request options with signal (an AbortSignal) and headers. The checkout methods (createReservation, createOrder, releaseReservation) also accept deviceId, sent as the X-Device-ID header. So do listAddons and validatePromoCode, so an attendee's own reservation is not counted against them.

Device IDs

A device ID ties an attendee's reservation, order and release calls together. The client fills it in when you don't pass deviceId, based on deviceIdMode:

ModeDefault inWhat happens
'browser'BrowsersOne device ID per browser, stored in localStorage under jetron_fluid_device_id and sent on every checkout call. You never pass deviceId.
'per-reservation'Node.js, Bun, Deno, and other serversEach createReservation without a deviceId gets a new device ID, returned as reservationToken. Pass it as deviceId to refresh the reservation, create the order, or release it. createOrder and releaseReservation throw if you leave it out.

A deviceId option, or an X-Device-ID you set in headers, always takes precedence over the automatic value. Automatic device IDs need Web Crypto (crypto.randomUUID), which browsers and Node.js 20+ provide.

'per-reservation' exists because one server-side client serves many attendees: a single shared device ID would put them all in one cart. Keep each attendee's reservationToken in their session. See Browser or server.

server.ts
const { data: reservation } = await client.createReservation('my-event', { items })

await client.createOrder('my-event', orderDetails, {
  deviceId: reservation.reservationToken,
})

Two keys on a server

Each endpoint accepts one key type, so a client works with one key. A server that renders events and also shows attendees their tickets and add-ons creates two clients:

server.ts
import { createClient } from '@jetronticket/api'

const fluid = createClient({ apiKey: process.env.JETRON_PUBLIC_KEY! })
const fluidPrivate = createClient({ apiKey: process.env.JETRON_PRIVATE_API_KEY! })

const { data: events } = await fluid.listEvents()

if (!session?.user.emailVerified) throw new Error('Sign in first')

const { data: tickets } = await fluidPrivate.lookupAttendeeTickets({
  email: session.user.email,
  used: false,
})

const { data: addons } = await fluidPrivate.lookupAttendeeAddons({
  email: session.user.email,
})

Only look up an email the signed-in user has proven they own. See How trust works.

Calling a public endpoint with the private client, or lookupAttendeeTickets or lookupAttendeeAddons with the public one, throws an ApiError with status 403.

lookupAttendeeTickets takes email (required), eventSlug, used, limit and cursor, and resolves to an ApiResult whose data is { items, nextCursor }. lookupAttendeeAddons takes the same body without used, and resolves the same way. See Attendee tickets for the fields and statuses.

createClient throws on a private key in the browser

createClient throws an Error when it gets a jt_private_... key while running in a browser. The private key reads your attendees' QR codes, so it must stay on your server. Look tickets and add-ons up from a server route and send the result to your app.

The ApiResult envelope

Every method resolves to an ApiResult<T> with the payload already unwrapped from the response envelope:

interface ApiResult<T> {
  data: T // unwrapped payload (null on a 304 Not Modified)
  status: number // HTTP status code
  etag: string | null // response ETag, when present
  notModified: boolean // true when a conditional GET returned 304
  response: Response // the raw fetch Response
}

Escape hatch: request()

For anything not covered by a dedicated method, request() performs an authenticated call against the same base URL and unwraps the envelope:

const { data } = await client.request<{ example: string }>('GET', '/some/path', {
  query: { key: 'value' },
})

Exported types

All request/response types are exported and mirror the API Reference schemas, including EventSummary, Event, EventHeadliner, EventArtistProfile, EventGallery, EventList, Ticket, TicketSale, Sale, SaleList, Addon, AddonList, IncludedAddon, Reservation, Order, OrderDetails, CreateReservationRequest, CreateOrderRequest, LookupAttendeeTicketsRequest, AttendeeTicketOrderList, AttendeeTicketOrder, AttendeeTicketEvent, AttendeeTicket, LookupAttendeeAddonsRequest, AttendeeAddonPurchaseList, AttendeeAddonPurchase, AttendeeAddon, AttendeeAddonCode, and the enums EventStatus, EventArtistPlatform, TicketStatus, SalePhase, AddonStatus, AddonFulfillment, OrderStatus, AttendeeTicketStatus, and Country:

import type {
  Addon,
  Event,
  EventGallery,
  EventHeadliner,
  EventSummary,
  Order,
  Reservation,
  Sale,
  Ticket,
} from '@jetronticket/api'

On this page