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.jsCreating an Instance
const api = new ResytechApi({
debug: true
});All configuration options are optional. The client ships with sensible defaults.
ResytechApiConfig
| Property | Type | Default | Description |
|---|---|---|---|
baseUrl | string | https://api.bookingui.com/v1 | Base URL for the Booking API |
cmsBaseUrl | string | https://crm-intake.resytech.com/v1 | Base URL for the CMS API (blog, etc.) |
debug | boolean | false | Enable console logging of all requests and responses |
timeout | number | 30000 | Request timeout in milliseconds |
headers | Record<string, string> | undefined | Custom 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
| Method | Signature | Description |
|---|---|---|
setAuthToken | setAuthToken(token: string): void | Manually set a Bearer token on all controllers |
getAuthToken | getAuthToken(): string | null | Get the current token (or null if not authenticated) |
clearAuthToken | clearAuthToken(): void | Remove the token from all controllers |
isAuthenticated | isAuthenticated(): boolean | Returns 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); // DisableController Reference
The ResytechApi instance exposes these controllers as public properties:
| Controller | Property | Description |
|---|---|---|
InitializationController | api.initialization | Session initialization and token acquisition |
ActivityController | api.activity | Activity details |
CalendarController | api.calendar | Availability calendars |
TimeslotController | api.timeslots | Time slot availability |
AddonController | api.addon | Eligible add-ons |
CartController | api.cart | Shopping cart management |
CheckoutController | api.checkout | Payment and checkout |
InvoiceController | api.invoice | Invoice retrieval and payment |
WaiverController | api.waiver | Digital waiver forms |
SurveyController | api.survey | Post-booking surveys |
GiftCardPurchaseController | api.giftCardPurchase | Gift card purchasing |
BlogController | api.blog | Blog 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
| Field | Type | Required | Description |
|---|---|---|---|
identifier | string | No | A unique session identifier for your integration |
InitializationResponse
| Field | Type | Description |
|---|---|---|
success | boolean | Whether initialization succeeded |
activities | InitializationActivity[] | List of bookable activities for this location |
buiAccessToken | string | Bearer token for authenticated API calls |
operator | Operator | Operator company and contact information |
locationGuid | string | Location UUID |
checkoutSettings | CheckoutSettings | UI configuration (titles, themes, custom CSS/JS, etc.) |
hasSmsWorkflow | boolean | Whether SMS workflows are enabled |
isTestMode | boolean | Whether the location is in test mode |
InitializationActivity
A simplified activity object returned during initialization:
| Field | Type | Description |
|---|---|---|
uuid | string | Activity unique identifier |
name | string | Activity display name |
tagline | string | Short tagline |
description | string | Activity description |
equipment | Equipment[] | Available equipment |
media | Media[] | Images and media |
startingAtPrice | number | Lowest available price |
manifest | Manifest | Guest limits and demographics |
firstAvailableDate | Date | Earliest bookable date |
durations | Duration[] | Available booking durations |
type | number | Activity type identifier |
dynamicDurationSettings | ActivityDynamicDurationSetting | Dynamic duration configuration (if enabled) |
Operator
| Field | Type | Description |
|---|---|---|
uuid | string | Operator UUID |
companyName | string | Company name |
locationName | string | Location name |
addressLine1 | string | Street address |
addressLine2 | string | Suite/unit |
city | string | City |
state | string | State/province |
postalCode | string | Postal/ZIP code |
operatorAccountId | string | Stripe connected account ID |
contactEmail | string | Contact email |
contactPhone | string | Contact phone |
website | string | Website URL |
