ResytechResytech Docs

ResytechApi Overview & Setup

Initialize and configure the ResytechApi client for building custom booking flows with the Resytech platform.

The ResytechApi class provides a typed JavaScript/TypeScript client for the Resytech Booking API. Use it to build fully custom booking experiences with direct API access to activities, calendars, time slots, carts, checkout, and more.

Installation

Include the library via script tag or npm:

<script src="https://static.resytech.com/js/resytech.js"></script>
npm install resytech.js

Creating an Instance

const api = new ResytechApi({
  debug: true
});

All configuration options are optional. The client ships with sensible defaults.

ResytechApiConfig

PropertyTypeDefaultDescription
baseUrlstringhttps://api.bookingui.com/v1Base URL for the Booking API
cmsBaseUrlstringhttps://crm-intake.resytech.com/v1Base URL for the CMS API (blog, etc.)
debugbooleanfalseEnable console logging of all requests and responses
timeoutnumber30000Request timeout in milliseconds
headersRecord<string, string>undefinedCustom headers applied to every request

Authentication Flow

Authentication is handled automatically. When you call initialize(), the API returns a buiAccessToken that the client stores and attaches to all subsequent requests as a Bearer token.

const api = new ResytechApi();

// Step 1: Initialize session — token is stored automatically
const init = await api.initialization.initialize({
  identifier: 'my-unique-session-id'
});

// Step 2: All subsequent calls are authenticated
const activity = await api.activity.getActivity('activity-uuid');

You do not need to manually set the token after initialization. The client intercepts the initialize() response, extracts buiAccessToken, and calls setAuthToken() internally.

Auth Methods

MethodSignatureDescription
setAuthTokensetAuthToken(token: string): voidManually set a Bearer token on all controllers
getAuthTokengetAuthToken(): string | nullGet the current token (or null if not authenticated)
clearAuthTokenclearAuthToken(): voidRemove the token from all controllers
isAuthenticatedisAuthenticated(): booleanReturns true if a token is currently set

Manual Token Management

If you need to persist sessions across page loads, store and restore the token:

// Save token after initialization
const init = await api.initialization.initialize({ identifier: 'session-1' });
localStorage.setItem('resytech_token', api.getAuthToken());

// Restore token on next page load
const savedToken = localStorage.getItem('resytech_token');
if (savedToken) {
  api.setAuthToken(savedToken);
}

Utility Methods

setCustomHeaders

Apply custom headers to all controllers at once.

api.setCustomHeaders({
  'X-Custom-Tracking': 'abc123',
  'X-Source': 'mobile-app'
});

getConfig

Returns a copy of the current configuration.

const config = api.getConfig();
// { baseUrl: 'https://api.bookingui.com/v1', debug: false, timeout: 30000, ... }

setDebug

Toggle debug logging at runtime.

api.setDebug(true);  // Enable — logs all requests and responses to console
api.setDebug(false); // Disable

Controller Reference

The ResytechApi instance exposes these controllers as public properties:

ControllerPropertyDescription
InitializationControllerapi.initializationSession initialization and token acquisition
ActivityControllerapi.activityActivity details
CalendarControllerapi.calendarAvailability calendars
TimeslotControllerapi.timeslotsTime slot availability
AddonControllerapi.addonEligible add-ons
CartControllerapi.cartShopping cart management
CheckoutControllerapi.checkoutPayment and checkout
InvoiceControllerapi.invoiceInvoice retrieval and payment
WaiverControllerapi.waiverDigital waiver forms
SurveyControllerapi.surveyPost-booking surveys
GiftCardPurchaseControllerapi.giftCardPurchaseGift card purchasing
BlogControllerapi.blogBlog posts and categories (CMS API)

Error Response Format

Every API call returns an object extending ApiResponseBase. On failure, the response looks like this:

interface ApiResponseBase {
  success: boolean;        // false on error
  message: string;         // Human-readable error message
  statusCode: number;      // HTTP status code (0 for network errors, 408 for timeout)
  action: string;          // The endpoint or action that failed
  isNetworkError: boolean; // true if the request never reached the server
}

Errors are never thrown as exceptions. Always check response.success before using the data:

const result = await api.activity.getActivity('some-uuid');

if (!result.success) {
  console.error(`Error ${result.statusCode}: ${result.message}`);
  if (result.isNetworkError) {
    console.error('Could not reach the server');
  }
  return;
}

// Safe to use result.activity
console.log(result.activity.name);

Timeout Handling

Requests that exceed the configured timeout (default 30 seconds) are aborted and return:

{
  success: false,
  message: 'Request timeout',
  statusCode: 408,
  action: '/activity/some-uuid',
  isNetworkError: true
}

Complete Initialization Example

// Create the client
const api = new ResytechApi({
  debug: true,
  timeout: 15000,
  headers: {
    'X-Source': 'custom-booking-page'
  }
});

// Initialize session
const init = await api.initialization.initialize({
  identifier: 'booking-page-session'
});

if (!init.success) {
  console.error('Failed to initialize:', init.message);
  return;
}

// The response includes everything you need to build a booking UI
console.log('Operator:', init.operator?.companyName);
console.log('Activities:', init.activities?.length);
console.log('Authenticated:', api.isAuthenticated());
console.log('Test mode:', init.isTestMode);

InitializationRequest

FieldTypeRequiredDescription
identifierstringNoA unique session identifier for your integration

InitializationResponse

FieldTypeDescription
successbooleanWhether initialization succeeded
activitiesInitializationActivity[]List of bookable activities for this location
buiAccessTokenstringBearer token for authenticated API calls
operatorOperatorOperator company and contact information
locationGuidstringLocation UUID
checkoutSettingsCheckoutSettingsUI configuration (titles, themes, custom CSS/JS, etc.)
hasSmsWorkflowbooleanWhether SMS workflows are enabled
isTestModebooleanWhether the location is in test mode

InitializationActivity

A simplified activity object returned during initialization:

FieldTypeDescription
uuidstringActivity unique identifier
namestringActivity display name
taglinestringShort tagline
descriptionstringActivity description
equipmentEquipment[]Available equipment
mediaMedia[]Images and media
startingAtPricenumberLowest available price
manifestManifestGuest limits and demographics
firstAvailableDateDateEarliest bookable date
durationsDuration[]Available booking durations
typenumberActivity type identifier
dynamicDurationSettingsActivityDynamicDurationSettingDynamic duration configuration (if enabled)

Operator

FieldTypeDescription
uuidstringOperator UUID
companyNamestringCompany name
locationNamestringLocation name
addressLine1stringStreet address
addressLine2stringSuite/unit
citystringCity
statestringState/province
postalCodestringPostal/ZIP code
operatorAccountIdstringStripe connected account ID
contactEmailstringContact email
contactPhonestringContact phone
websitestringWebsite URL

On this page