API reference

HTS APIs

Every endpoint, schema and error code, rendered from the published OpenAPI files, in the order you integrate them.

OpenAPI 3.1.0 · version 2

CFAR Lodging API

Download OpenAPI JSON

Base URLs

Staging
https://fintech.staging.htsapis.com/lodging-cfar/v2
Production
https://fintech.htsapis.com/lodging-cfar/v2

Authentication

X-Api-Key API key sent in the header on every call.

Contact HTS for access

Endpoints

Offer & Merchandising

Endpoints for creating, pricing, and retrieving offers for a customer's reservation, as well as generating merchandising content for those offers.


Guide for integrating the HTS merchandising component into your website to display CFAR offers.

Overview

HTS merchandising components are lightweight, embeddable widgets that display product offers on your website. They are delivered as web components that render in Shadow DOM with isolated styling.

There are two integration modes: Web Component and Iframe. The mode is determined by your tenant's configuration. The merchandising_url in the create offer response already points to the correct endpoint for your integration mode:

  • .../component/sdk.js → Web Component mode
  • .../index.html → Iframe mode

{{HTS_ORIGIN}} — Throughout this guide, {{HTS_ORIGIN}} represents the HTS domain for your environment (e.g. staging or production). The exact origin is provided during onboarding and must be used for CSP headers and postMessage origin verification.

Web Component Iframe
How it loads <script> tag + custom element on your page <iframe> pointing to the merchandising URL
Isolation Shadow DOM within host page Full iframe boundary
Sizing Inline flow — fills container width, height adjusts automatically Requires manual height management via hts-dimension event
Theming CSS custom properties on the host element hts-theme ingress event with design tokens
Sending commands window.postMessage(...) iframe.contentWindow.postMessage(...)
CSP requirement script-src + connect-src for {{HTS_ORIGIN}} frame-src for {{HTS_ORIGIN}}

Integration Flow

  1. Create an offer — call the create offer API to obtain a merchandising_url.
  2. Embed the component — load the component on your page using the merchandising_url.
  3. Customer selects an option — the component emits an hts-selection event with the chosen offer tokens.
  4. Process the selection — use the offer tokens to create an order.

Embedding the Component

Web Component

Element Name
<hts-lodging-cfar-merchandising>

Static HTML:

<!-- Preconnect for faster DNS resolution -->
<link rel="preconnect" href="{{HTS_ORIGIN}}" />

<!-- Merchandising script (merchandising_url from create offer API response) -->
<script src="{{MERCHANDISING_URL}}" type="module" async></script>

<!-- Merchandising component -->
<hts-lodging-cfar-merchandising></hts-lodging-cfar-merchandising>

Dynamic (JavaScript):

// merchandising_url is provided in the create offer API response
const sdkUrl = merchandisingUrl;

// Load the merchandising script
const script = document.createElement('script');
script.src = sdkUrl;
script.type = 'module';
script.async = true;
document.head.appendChild(script);

// Insert the custom element
const component = document.createElement('hts-lodging-cfar-merchandising');
document.body.appendChild(component);
Iframe

Use the merchandising_url from the create offer API response as the iframe src.

<iframe
  id="hts-merchandising"
  src="{{MERCHANDISING_URL}}"
  style="width: 100%; border: none; height: 400px;">
</iframe>

Adjust the iframe height dynamically using the hts-dimension event:

window.addEventListener('message', (event) => {
  if (event.origin !== '{{HTS_ORIGIN}}') return;

  if (event.data.type === 'hts-dimension') {
    const iframe = document.getElementById('hts-merchandising');
    iframe.style.height = event.data.data.height + 'px';
  }
});

Egress Events (Component → Partner)

The component communicates with your page using the postMessage API. These events are identical for both integration modes — listen via window.addEventListener('message', ...).

Event Types

Event Type Description When Fired
hts-initialized Component loaded and ready On component mount
hts-option-selected User selected an option When selection changes
hts-invalid-params Invalid parameters detected On parameter validation failure
hts-data-loaded Offer data loaded After successful data parsing
hts-dimension Component dimensions changed When size changes
hts-view-terms User viewing terms When terms link is clicked
hts-link-clicked User clicked a link When FAQ or T&C links are clicked
hts-initialization-failed Initialization blocked When the app cannot initialize (e.g. unsupported locale)
hts-validated Checkout readiness changed On each hts-validate, and on change once enabled (or immediately with validate)
hts-offer-conversion-displayed Amounts are being shown in a display currency On the first converted render, and on each display-currency change (only while a conversion is active)

Listening to Events

window.addEventListener('message', (event) => {
  // Verify origin for security
  if (event.origin !== '{{HTS_ORIGIN}}') return;

  const { type, product, data } = event.data;

  switch (type) {
    case 'hts-initialized':
      console.log(`${product} component initialized`);
      break;
    case 'hts-option-selected':
      if (data.attached && data.offer) {
        // User selected the offer — offerTokens contains one token per room/unit
        console.log(`Offer selected, price: ${data.offer.premium} ${data.offer.currency}`);
      } else {
        // User declined the offer
      }
      break;
    case 'hts-invalid-params':
      console.error('Validation failed:', data.error);
      break;
    case 'hts-dimension':
      // For iframe: update iframe height
      // For web component: typically not needed (inline flow)
      break;
    case 'hts-link-clicked':
      // contextType is "faq" or "termsAndConditions"
      break;
    case 'hts-initialization-failed':
      // Widget will not render — hide container and do not require selection
      console.warn('Initialization failed:', data.type);
      break;
    case 'hts-validated':
      // Enable/disable your proceed control based on data.isValid
      setProceedEnabled(data.isValid);
      break;
  }
});

Event Payloads

All egress events share this envelope structure:

{
  "type": "<event-type>",
  "product": "lodging-cfar",
  "data": { ... }
}

hts-initialized

Fired once when the component has loaded and is ready to display. Wait for this event before sending any ingress events to the component.

{
  "type": "hts-initialized",
  "product": "lodging-cfar",
  "data": {
    "sessionId": "7a60d98a-c46e-42be-ba9f-fde95cc50307",
    "version": "1.422.0"
  }
}
Field Type Description
data.sessionId string The session ID for this offer flow
data.version string Component build version

hts-option-selected

Fired when the user selects or deselects an offer option.

User selected the offer:

{
  "type": "hts-option-selected",
  "product": "lodging-cfar",
  "data": {
    "attached": true,
    "selected": "option-1",
    "offer": {
      "offerTokens": ["token-room-1", "token-room-2"],
      "premium": "20.00",
      "currency": "USD"
    }
  }
}

User declined the offer:

{
  "type": "hts-option-selected",
  "product": "lodging-cfar",
  "data": {
    "attached": false,
    "selected": "none"
  }
}
Field Type Description
data.attached boolean true if the offer is selected, false if declined
data.selected string Option identifier ("option-1", "option-2", "none")
data.offer.offerTokens string[] One token per room/unit in the booking. Present only when attached: true
data.offer.premium string Total price of the offer
data.offer.currency string ISO 4217 currency code

hts-data-loaded

Fired after offer data has been successfully parsed and is ready for display.

{
  "type": "hts-data-loaded",
  "product": "lodging-cfar",
  "data": [
    {
      "offerTokens": ["token-room-1"],
      "premium": "20.00",
      "currency": "USD"
    }
  ]
}
Field Type Description
data array Array of offer objects that were parsed from the merchandising URL

hts-dimension

Fired whenever the widget's rendered size changes.

{
  "type": "hts-dimension",
  "product": "lodging-cfar",
  "data": {
    "width": 800,
    "height": 450
  }
}
Field Type Description
data.width number Widget width in pixels
data.height number Widget height in pixels

For iframe integration, use this to update iframe height. For web component integration, this is informational.

hts-invalid-params

Fired when the merchandising URL parameters fail validation.

{
  "type": "hts-invalid-params",
  "product": "lodging-cfar",
  "data": {
    "error": { "offers": "required parameter missing" }
  }
}
Field Type Description
data.error object Validation error details (structure varies)

hts-view-terms

Fired when the user clicks the terms and conditions link.

{
  "type": "hts-view-terms",
  "product": "lodging-cfar",
  "data": {
    "url": "https://hts.hopper.com/<path-to-legal-doc>"
  }
}
Field Type Description
data.url string URL of the terms page

hts-link-clicked

Fired when the user clicks an FAQ or terms and conditions link.

{
  "type": "hts-link-clicked",
  "product": "lodging-cfar",
  "data": {
    "url": "https://hts.hopper.com/<path-to-legal-doc>",
    "contextType": "termsAndConditions"
  }
}
Field Type Description
data.url string URL of the clicked link
data.contextType string Either "faq" or "termsAndConditions"

hts-initialization-failed

Fired when the app cannot initialize due to a precondition failure. The widget will not render.

{
  "type": "hts-initialization-failed",
  "product": "lodging-cfar",
  "data": {
    "type": "unsupported_locale",
    "locale": "ja"
  }
}
Field Type Description
data.type string Failure reason. Currently only "unsupported_locale"
data.locale string The unsupported locale that was requested

The only failure type today is unsupported_locale, indicating the tenant is configured to reject unsupported locales rather than falling back to English.

hts-validated

Tells you whether it is safe to proceed to checkout. Use it to enable/disable your proceed/checkout control.

{
  "type": "hts-validated",
  "product": "lodging-cfar",
  "data": { "isValid": false }
}
Field Type Description
data.isValid boolean true when it is safe to proceed to checkout, false otherwise

When it fires. hts-validated is not emitted on load — this event stays quiet until you opt in (other widget events still fire as normal). It starts emitting the first time either you send an hts-validate ingress event (e.g. when the customer attempts to proceed), or you set the validate attribute/parameter on the component (see the Component Attributes / Iframe Parameters tables below). From then on it emits the current isValid whenever the value changes (this automatic stream is de-duplicated). In addition, every hts-validate you send always responds with a fresh hts-validated carrying the current validity — even when it hasn't changed — so you can re-query readiness at any time; that ingress also re-shows the in-widget "selection required" prompt.

How to interpret isValid: Treat isValid: false as "disable proceed," not "show an error." If you want a checkout-readiness signal at load without any customer action, set validate; the first hts-validated then reflects the offer's selection mode (a forced-choice widget starts isValid: false; one that permits no selection starts isValid: true). Otherwise drive validation from the proceed attempt: send hts-validate and read the resulting hts-validated. Surface validation messaging only at the proceed attempt (hts-validate and/or your own copy).

hts-offer-conversion-displayed

Fired while the widget is displaying amounts converted to a currency other than the offer currency. Lets you confirm both what the customer will actually be charged (always in the offer currency) and the converted amounts shown on screen. See the hts-display-currency ingress event below for how to drive the conversion.

{
  "type": "hts-offer-conversion-displayed",
  "product": "lodging-cfar",
  "data": {
    "offerIdentifier": ["token-room-1"],
    "premium": 20,
    "currency": "USD",
    "display": {
      "premium": 18.4,
      "currency": "EUR",
      "exchangeRate": "0.92"
    }
  }
}
Field Type Description
data.offerIdentifier string[] Offer tokens the reported amounts cover
data.premium number Price in the offer currency — the amount the customer is actually charged
data.currency string Offer (contract) currency, ISO 4217
data.display.premium number Price converted to the display currency
data.display.currency string Display currency, ISO 4217
data.display.exchangeRate string Multiplier applied to the offer currency to produce the displayed amounts

When it fires. On the first converted render, and again on every display-currency change. It is emitted only while a conversion is active, so treat its absence as "amounts are in the offer currency." The conversion is display-only: the contract, and the amount charged, stay in currency.

Ingress Events (Partner → Component)

The host page can send commands to the widget via postMessage.

Event Type Description Use Case
hts-selection Programmatically select an option Restore a previous selection or sync with partner state
hts-validate Trigger validation state Show validation errors when the user tries to proceed without selecting
hts-theme Apply a custom theme at runtime Override design tokens dynamically after the widget has loaded
hts-display-currency Switch the currency amounts are displayed in Render prices in the customer's currency, e.g. from a currency picker on your page

Targeting: For web component integration, post to window with origin {{HTS_ORIGIN}}. For iframe integration, post to iframe.contentWindow. Examples below show both.

hts-selection

Sets the selected option inside the widget using option identifiers.

{ "type": "hts-selection", "option": "option-1" }
Field Type Values Description
type string "hts-selection" Event type
option string "none", "option-1", "option-2" Option identifier to select

Web Component:

// Programmatically select an offer option
window.postMessage({ type: 'hts-selection', option: 'option-1' }, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-merchandising');
iframe.contentWindow.postMessage({ type: 'hts-selection', option: 'option-1' }, '{{HTS_ORIGIN}}');

hts-validate

Triggers the widget's validation state, highlighting that a selection is required. Useful when the user clicks "Continue" or "Book" without making a selection.

{ "type": "hts-validate" }
Field Type Description
type string Event type. No additional fields.

Web Component:

window.postMessage({ type: 'hts-validate' }, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-merchandising');
iframe.contentWindow.postMessage({ type: 'hts-validate' }, '{{HTS_ORIGIN}}');

hts-theme

Applies a custom theme to the widget at runtime by sending a partial map of design token overrides. Any subset of tokens can be sent; omitted tokens keep their current values.

For initial theming, CSS custom properties on the host element are preferred (see Theming). Use this event for dynamic theme changes after the widget has loaded.

{
  "type": "hts-theme",
  "tokens": {
    "colorPrimary": "#1a73e8",
    "fontFamilyBase": "Inter, sans-serif"
  }
}
Field Type Description
type string Event type
tokens object Partial map of design token names to string values. See the CSS Custom Properties table for valid token names.

Web Component:

window.postMessage({
  type: 'hts-theme',
  tokens: { colorPrimary: '#1a73e8' }
}, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-merchandising');
iframe.contentWindow.postMessage({
  type: 'hts-theme',
  tokens: { colorPrimary: '#1a73e8' }
}, '{{HTS_ORIGIN}}');

hts-display-currency

Switches the currency the widget displays amounts in, after it has loaded — use it to power an on-page currency switcher. This is display-only: the contract, and the amount the customer is charged, stay in the offer currency, and the widget shows a disclaimer naming both currencies.

{ "type": "hts-display-currency", "currency": "EUR", "exchangeRate": 0.92 }
Field Type Description
type string "hts-display-currency"
currency string | null Display currency as a 3-letter ISO 4217 code, or null to revert to the offer currency
exchangeRate number Optional. Multiplier applied to the offer currency (e.g. 0.92). Omit it to have HTS resolve a current rate. Must be positive and finite — a zero, negative, or non-numeric rate rejects the whole event with hts-invalid-params

currency and exchangeRate move together: switching currency clears any rate you supplied before, so send the new rate alongside the new currency. Setting the offer's own currency counts as no conversion — amounts render normally and no event fires. Each accepted change is reported by the hts-offer-conversion-displayed egress event, which tells you the currency actually shown (the widget falls back to the offer currency if no rate can be resolved).

Web Component:

// HTS resolves the rate
window.postMessage({ type: 'hts-display-currency', currency: 'EUR' }, '{{HTS_ORIGIN}}');

// ...or convert with your own rate
window.postMessage({ type: 'hts-display-currency', currency: 'EUR', exchangeRate: 0.92 }, '{{HTS_ORIGIN}}');

// Back to the offer currency
window.postMessage({ type: 'hts-display-currency', currency: null }, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-merchandising');
iframe.contentWindow.postMessage({ type: 'hts-display-currency', currency: 'EUR', exchangeRate: 0.92 }, '{{HTS_ORIGIN}}');

An initial display currency can also be set at load, without an event, via the display-currency / exchange-rate-to-display attributes (web component) or the displayCurrency / exchangeRateToDisplay parameters (iframe) — see the tables below. This event and those inputs feed the same state, so you can seed a currency on load and switch from there.

Component Attributes

When using the web component, customizations are set as kebab-case attributes on the custom element.

Attribute Type Description
selected string Pre-select an option (none, or an offer id)
validate boolean Emit hts-validated (current validity) as soon as this attribute is set — on load or later — instead of staying silent until the first hts-validate. Default false.
rewards-type string Override rewards type
rewards-conversion string Override rewards conversion
display-currency string Render amounts in this currency (3-letter ISO 4217 code, e.g. EUR). Display-only — the contract stays in the offer currency.
exchange-rate-to-display string Exchange rate as a multiplier from the offer currency (e.g. 0.92). Requires display-currency; omit to have HTS resolve a rate.
<hts-lodging-cfar-merchandising
  selected="none"
  rewards-type="miles"
  rewards-conversion="100"
></hts-lodging-cfar-merchandising>

<hts-lodging-cfar-merchandising selected="option-1"></hts-lodging-cfar-merchandising>

Iframe Parameters

When using iframe integration, the same customizations are supplied as camelCase query parameters on the merchandising URL. See the Iframe embedding example in Integration Modes above.

Parameter Type Description
selected string Pre-select an option (none, or an offer id)
validate boolean Emit hts-validated (current validity) from load instead of staying silent until the first hts-validate. Default false.
rewardsType string Override rewards type
rewardsConversion string Override rewards conversion
displayCurrency string Render amounts in this currency (3-letter ISO 4217 code, e.g. EUR). Display-only — the contract stays in the offer currency.
exchangeRateToDisplay string Exchange rate as a multiplier from the offer currency (e.g. 0.92). Requires displayCurrency; omit to have HTS resolve a rate.

Responsive Sizing

The widget is fully responsive. The partner controls the container width — the widget fills the available width and adjusts its height dynamically based on content. There is no fixed pixel height for mobile or desktop.

After each resize, the widget emits an hts-dimension event:

{
  "type": "hts-dimension",
  "product": "lodging-cfar",
  "data": { "width": 800, "height": 450 }
}
  • Web component: The widget flows inline — height adjusts automatically. The hts-dimension event is informational.
  • Iframe: You must listen for hts-dimension and update the iframe's height (see the iframe embedding example above).

Theming

Web Component: CSS Custom Properties

The component renders in Shadow DOM with isolated styling. CSS custom properties pierce the Shadow DOM boundary, so you can set them on the host element or an ancestor.

If no custom properties are set, the widget uses the defaults below. HTS may also apply partner-specific themes server-side based on partnerId.

Header & Borders

CSS Custom Property Token Default Used For
--hts-color-header-fg colorHeaderFg light-dark(rgb(23, 46, 94), rgb(119, 158, 255)) Header title and icon
--hts-color-header-bg colorHeaderBg light-dark(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)) Header fill
--hts-color-header-background colorHeaderBackground light-dark(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)) Deprecated alias of colorHeaderBg. Prefer colorHeaderBg. If both are set, colorHeaderBg wins.
--hts-color-border colorBorder light-dark(rgb(217, 217, 217), rgb(217, 217, 217)) Banner, option card, and radio strokes
--hts-color-option-hover-bg colorOptionHoverBg light-dark(rgb(246, 246, 246), rgb(17, 17, 17)) Option card hover fill

Focus, selected-option border, and the terms link follow colorPrimary. Partners who set an opaque header fill must also set colorHeaderFg; the widget does not auto-correct contrast. Hosts who theme the card surface should also set colorOptionHoverBg if they do not want the default grey hover.

Brand Colors

CSS Custom Property Token Default Used For
--hts-color-primary colorPrimary #2f394e Selected option border, radio button fill, bullet icons
--hts-color-primary-lighter colorPrimaryLighter #eff3ff Header icon background, light accent surfaces
--hts-color-secondary colorSecondary #4f46e5 Secondary accent elements, links

Text Colors

CSS Custom Property Token Default Used For
--hts-color-text-primary colorTextPrimary #181d29 Main body text, headings
--hts-color-text-secondary colorTextSecondary #6B7280 Descriptions, secondary labels, muted text

Recommended Badge

CSS Custom Property Token Default Used For
--hts-color-recommended colorRecommended #4f46e5 "Recommended" ribbon background
--hts-color-text-recommended colorTextRecommended #eff3ff "Recommended" ribbon text

Status Colors

CSS Custom Property Token Default Used For
--hts-color-status-success colorStatusSuccess #56C470 Success status indicators
--hts-color-success-fg colorSuccessFg #27c281 Success text, bullet point icons, checkmarks
--hts-color-success-bg colorSuccessBg #e8f8f0 Success message background
--hts-color-discount-bg colorDiscountBg #DCFCE7 Discount badge / savings highlight background
--hts-color-error-fg colorErrorFg #CC2427 Error text, validation messages
--hts-color-error-bg colorErrorBg #f9eff1 Error message background
--hts-color-warning-fg colorWarningFg #a7173c Warning text, warning icon
--hts-color-warning-bg colorWarningBg #f9eff1 Warning banner background

Typography

CSS Custom Property Token Default Used For
--hts-font-family-base fontFamilyBase 'Proxima Nova', sans-serif All text in the widget
--hts-font-size-body-md fontSizeBodyMd 14px Standard body text
--hts-font-size-body-sm fontSizeBodySm 12px Small body text, captions
--hts-font-size-body-xs fontSizeBodyXs 10px Fine print, disclaimers
--hts-font-size-title-lg fontSizeTitleLg 20px Large titles, main heading
--hts-font-size-title-md fontSizeTitleMd 16px Medium titles, section headings
--hts-font-size-title-sm fontSizeTitleSm 14px Small titles, option labels
--hts-font-weight-base fontWeightBase 400 Normal text weight
--hts-font-weight-emphasis fontWeightEmphasis 600 Emphasized text (prices, key values)
--hts-font-weight-headline fontWeightHeadline 700 Headlines, section headers
--hts-font-style-headline fontStyleHeadline normal Headline font style (normal, italic, or oblique)
--hts-font-weight-title fontWeightTitle 700 Titles within options

Layout

CSS Custom Property Token Default Used For
--hts-border-radius-base borderRadiusBase 8px Border radius on cards, buttons, option containers, header icon
hts-lodging-cfar-merchandising {
  --hts-color-primary: #1a73e8;
  --hts-color-secondary: #ea4335;
  --hts-color-header-fg: #1a73e8;
  --hts-color-header-bg: transparent;
  --hts-color-border: #d9d9d9;
  --hts-color-option-hover-bg: #f6f6f6;
  --hts-font-family-base: 'Inter', sans-serif;
  --hts-font-style-headline: normal;
  --hts-border-radius-base: 12px;
}
Iframe: hts-theme Event

CSS custom properties cannot cross iframe boundaries. For iframe integrations, use the hts-theme ingress event to send design token overrides. The token names correspond to the "Token" column in the tables above.

const iframe = document.getElementById('hts-merchandising');
iframe.contentWindow.postMessage({
  type: 'hts-theme',
  tokens: {
    colorPrimary: '#1a73e8',
    colorSecondary: '#ea4335',
    colorHeaderFg: '#1a73e8',
    colorHeaderBg: 'transparent',
    colorBorder: '#d9d9d9',
    colorOptionHoverBg: '#f6f6f6',
    fontFamilyBase: 'Inter, sans-serif',
    fontStyleHeadline: 'normal',
    borderRadiusBase: '12px'
  }
}, '{{HTS_ORIGIN}}');

See the hts-theme ingress event for the full specification.

Security

Web Component Iframe
CSP script-src 'self' {{HTS_ORIGIN}}; connect-src 'self' {{HTS_ORIGIN}}; frame-src 'self' {{HTS_ORIGIN}};
Origin check Verify event.origin on all message events Same
HTTPS Required in production Required in production

Loading Tolerance

If the hts-initialized event is not received within a reasonable tolerance period after embedding the component, the hosting application should hide the widget and not require forced selection. This prevents user experience degradation if the component fails to load.

Alternative: Merchandising Contents API

Partners who cannot embed the widget can use the Create Offer Merchandising Contents endpoint to retrieve product copy and messaging as JSON. This approach requires the partner to build their own UI while using HTS-provided content.

POST/offers/pricePrice CFAR Offers
GET/offers/{id}Get CFAR Offer
POST/offersCreate CFAR Offers
PUT/merchandising_contentsCreate Merchandising Contents
Contract Management

Endpoints for managing the lifecycle of contracts after purchase, including creation, confirmation, retrieval, search, and cancellation.

PUT/orders/{id}/purchasePurchase a CFAR Order
PUT/orders/{id}/voidVoid a CFAR Order
PUT/orders/{id}/cancelCancel a CFAR Order
GET/orders/{id}Get CFAR Order
POST/orders/searchSearch Orders
POST/orders/{id}/user_projected_payoutsGet User Projected Payouts
POST/ordersCreate a CFAR Order
GET/contracts/{id}Get CFAR Contract
POST/contracts/searchSearch Contracts
HTS Self-Service Exercise

The partner utilizes the HTS frontend to handle 100% of the exercise experience end to end.


Guide for integrating the HTS exercise component into your website to handle CFAR cancellation and refund flows.

Overview

The HTS exercise component is an embeddable widget that guides the end user through the CFAR cancellation process — reviewing the booking, confirming cancellation, and processing the refund. It is delivered as a web component that renders in Shadow DOM with isolated styling.

To obtain the exercise URL, call the Create Order Exercise URL endpoint (POST /orders/{id}/exercise_url). The response contains an exercise_url that you embed on your page.

{{HTS_ORIGIN}} — Throughout this guide, {{HTS_ORIGIN}} represents the HTS domain for your environment (e.g. staging or production). The exact origin is provided during onboarding and must be used for CSP headers and postMessage origin verification.

There are two integration modes: Web Component and Iframe. The mode is determined by your tenant's configuration. The exercise_url in the response already points to the correct endpoint for your integration mode:

  • .../component/sdk.js?... → Web Component mode
  • .../cancel-lodging/... → Iframe / redirect mode
Web Component Iframe
How it loads <script> tag + custom element on your page <iframe> pointing to the exercise URL
Isolation Shadow DOM within host page Full iframe boundary
Sizing Inline flow — fills container width, height adjusts automatically Requires manual height management via hts-dimension event
Theming CSS custom properties on the host element hts-theme ingress event with design tokens
Sending commands window.postMessage(...) iframe.contentWindow.postMessage(...)
CSP requirement script-src + connect-src for {{HTS_ORIGIN}} frame-src for {{HTS_ORIGIN}}

Integration Flow

  1. Get exercise URL — call the create order exercise URL API to obtain the exercise_url.
  2. Embed the component — load the component on your page using the exercise_url.
  3. User reviews and confirms — the component walks the user through cancellation and refund details.
  4. Process exercise events — listen for hts-exercise (or hts-exercise-click-confirm under partner_fulfill) to handle the result.

Embedding the Component

Web Component

Element Name
<hts-fintech-exercise>

Static HTML:

<!-- Preconnect for faster DNS resolution -->
<link rel="preconnect" href="{{HTS_ORIGIN}}" />

<!-- Exercise script (exercise_url from Create Order Exercise URL response) -->
<script src="{{EXERCISE_URL}}" type="module" async></script>

<!-- Exercise component -->
<hts-fintech-exercise></hts-fintech-exercise>

Dynamic (JavaScript):

// exercise_url is provided in the Create Order Exercise URL API response
const exerciseUrl = response.exercise_url;

// Load the exercise script
const script = document.createElement('script');
script.src = exerciseUrl;
script.type = 'module';
script.async = true;
document.head.appendChild(script);

// Insert the custom element
const component = document.createElement('hts-fintech-exercise');
document.body.appendChild(component);
Iframe

Use the exercise_url from the API response as the iframe src.

<iframe
  id="hts-exercise"
  src="{{EXERCISE_URL}}"
  style="width: 100%; border: none; height: 600px;">
</iframe>

Adjust the iframe height dynamically using the hts-dimension event:

window.addEventListener('message', (event) => {
  if (event.origin !== '{{HTS_ORIGIN}}') return;

  if (event.data.type === 'hts-dimension') {
    const iframe = document.getElementById('hts-exercise');
    iframe.style.height = event.data.data.height + 'px';
  }
});

URL Parameters

The exercise_url returned by the API includes all required parameters. For reference, the parameters are:

Parameter Type Required Description
token string Yes JWT token authorizing the exercise session
tenant string Yes Tenant slug identifying your integration
productType string Yes Always lodging-cfar for lodging
orderId string Yes The order ID to exercise
locale string No BCP 47 locale code (default: en)
headless boolean No Enable headless mode — see below

Egress Events (Component → Partner)

The component communicates with your page using the postMessage API. These events are identical for both integration modes — listen via window.addEventListener('message', ...).

Event Types

Event Type Description When Fired
hts-ready Component loaded and ready After initialization completes
hts-dimension Component dimensions changed When size changes
hts-exercise Exercise lifecycle status When fulfill starts, succeeds, or fails
hts-exercise-click-confirm User confirmed cancellation When user clicks "Confirm Cancel"
hts-exercise-click-cancel User cancelled out of exercise When user clicks "Go Back"
hts-exercise-click-support User clicked support link When user requests help
hts-exercise-refund-option-selected User selected a refund option When user picks a refund method (FTC flows)
hts-navigate-back User wants to go back When user navigates backward
hts-scroll-to-top Component requests scroll When a new page is shown
hts-exit User is exiting the flow When exercise flow completes or user leaves

Listening to Events

window.addEventListener('message', (event) => {
  // Verify origin for security
  if (event.origin !== '{{HTS_ORIGIN}}') return;

  const { type, data } = event.data;

  switch (type) {
    case 'hts-ready':
      if (data.status === 'success') {
        console.log('Exercise component ready');
      } else {
        // Component failed to initialize — hide container
        console.error('Exercise component failed to load');
      }
      break;
    case 'hts-exercise':
      // Exercise fulfill lifecycle
      if (data.status === 'success') {
        console.log('Exercise completed successfully');
      } else if (data.status === 'error') {
        console.error('Exercise failed');
      }
      break;
    case 'hts-exercise-click-confirm':
      // User confirmed cancellation
      if (data?.quoteId) {
        // partner_fulfill policy: partner must now fulfill the exercise
        console.log('User confirmed, quoteId:', data.quoteId);
      }
      break;
    case 'hts-exercise-click-cancel':
      // User decided not to cancel
      break;
    case 'hts-dimension':
      // For iframe: update iframe height
      // For web component: typically not needed (inline flow)
      break;
    case 'hts-exit':
      // User is done — navigate them away or close the component
      break;
  }
});

Event Payloads

All egress events share this envelope structure:

{
  "type": "<event-type>",
  "data": { ... }
}

hts-ready

Fired once when the component has loaded and is ready to display. Wait for this event before sending any ingress events to the component.

{
  "type": "hts-ready",
  "data": {
    "status": "success",
    "metadata": {
      "vertical": "lodging"
    }
  }
}
Field Type Description
data.status string "success" if ready, "error" if initialization failed
data.metadata.vertical string Product vertical ("lodging" for lodging CFAR)

hts-dimension

Fired whenever the component's rendered size changes.

{
  "type": "hts-dimension",
  "data": {
    "width": 800,
    "height": 600
  }
}
Field Type Description
data.width number Component width in pixels
data.height number Component height in pixels

For iframe integration, use this to update iframe height. For web component integration, this is informational.

hts-exercise

Fired during the exercise fulfill lifecycle.

{
  "type": "hts-exercise",
  "data": {
    "status": "success"
  }
}
Field Type Description
data.status string "pending" when fulfill starts, "success" when completed, "error" on failure

This event is fired under the hts_fulfill exercise policy (default). Under partner_fulfill, the component emits hts-exercise-click-confirm instead and the partner handles fulfillment.

hts-exercise-click-confirm

Fired when the user confirms their wish to cancel.

Under hts_fulfill policy (default):

{
  "type": "hts-exercise-click-confirm",
  "data": null
}

Under partner_fulfill policy:

{
  "type": "hts-exercise-click-confirm",
  "data": {
    "quoteId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}
Field Type Description
data object or null null under default policy; contains quoteId under partner_fulfill
data.quoteId string Exercise quote ID — the partner must call PUT /exercise_quotes/{id}/fulfill with this ID

hts-exercise-click-cancel

Fired when the user decides not to proceed with cancellation.

{
  "type": "hts-exercise-click-cancel",
  "data": null
}

No additional fields.

hts-exercise-click-support

Fired when the user clicks a support or help link.

{
  "type": "hts-exercise-click-support",
  "data": null
}

No additional fields.

hts-exercise-refund-option-selected

Fired when the user selects a refund option (relevant for future travel credit flows).

{
  "type": "hts-exercise-refund-option-selected",
  "data": null
}

No additional fields.

hts-navigate-back

Fired when the user wants to navigate backward (e.g., back to trips list).

{
  "type": "hts-navigate-back",
  "data": {
    "route": "trips"
  }
}
Field Type Description
data.route string Target route. Currently only "trips"

hts-scroll-to-top

Fired when the component transitions to a new page and the host should scroll to the top.

{
  "type": "hts-scroll-to-top",
  "data": {
    "behavior": "instant"
  }
}
Field Type Description
data.behavior string "instant" or "smooth" — the recommended scroll behavior

hts-exit

Fired when the user is exiting the exercise flow (flow completed or user chose to leave).

{
  "type": "hts-exit",
  "data": null
}

No additional fields.

Ingress Events (Partner → Component)

The host page can send commands to the component via postMessage.

Event Type Description Use Case
hts-external-navigation Drive page navigation Headless mode — host controls forward/backward navigation
hts-theme Apply a custom theme at runtime Override design tokens dynamically after the component has loaded

Targeting: For web component integration, post to window with origin {{HTS_ORIGIN}}. For iframe integration, post to iframe.contentWindow. Examples below show both.

hts-external-navigation

Drives navigation within the exercise flow. Used in headless mode when the host page provides its own navigation controls.

{ "type": "hts-external-navigation", "data": { "direction": "forward" } }
Field Type Values Description
type string "hts-external-navigation" Event type
data.direction string "forward", "backward" Navigation direction

Web Component:

// Advance to the next step
window.postMessage({
  type: 'hts-external-navigation',
  data: { direction: 'forward' }
}, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-exercise');
iframe.contentWindow.postMessage({
  type: 'hts-external-navigation',
  data: { direction: 'forward' }
}, '{{HTS_ORIGIN}}');

hts-theme

Applies a custom theme to the component at runtime by sending a partial map of design token overrides. Any subset of tokens can be sent; omitted tokens keep their current values.

For initial theming, CSS custom properties on the host element are preferred (see Theming). Use this event for dynamic theme changes after the component has loaded.

{
  "type": "hts-theme",
  "tokens": {
    "colorPrimary": "#1a73e8",
    "fontFamilyBase": "Inter, sans-serif"
  }
}
Field Type Description
type string Event type
tokens object Partial map of design token names to string values. See the CSS Custom Properties table for valid token names.

Web Component:

window.postMessage({
  type: 'hts-theme',
  tokens: { colorPrimary: '#1a73e8' }
}, '{{HTS_ORIGIN}}');
Iframe
const iframe = document.getElementById('hts-exercise');
iframe.contentWindow.postMessage({
  type: 'hts-theme',
  tokens: { colorPrimary: '#1a73e8' }
}, '{{HTS_ORIGIN}}');

Exercise Policies

The exercise component supports two policies that determine who handles the actual cancellation fulfillment:

hts_fulfill (Default)

HTS handles the full exercise lifecycle — the component calls the fulfill API, cancels the booking via callback to the partner, processes the refund, and shows the result. The component emits hts-exercise events with status pending → success / error.

partner_fulfill

The component displays the cancellation summary and collects user confirmation, but does not call fulfill. Instead, it emits hts-exercise-click-confirm with a quoteId. The partner must:

  1. Cancel the booking on their end.
  2. Call PUT /exercise_quotes/{quoteId}/fulfill to complete the exercise.

This policy is configured per-tenant. Partners using this policy should listen for hts-exercise-click-confirm and handle the fulfillment API call from their backend.

Headless Mode

When headless=true is passed as a URL parameter, the component hides its built-in navigation buttons and success/error screens. The host page is responsible for:

  1. Driving navigation — send hts-external-navigation events with direction: "forward" or "backward" to move between steps.
  2. Handling scroll — listen for hts-scroll-to-top and scroll the container.
  3. Showing results — listen for hts-exercise (or hts-exercise-click-confirm under partner_fulfill) and display your own confirmation UI.

Headless mode is useful when embedding the exercise flow within a partner's existing booking management UI, where the partner wants full control over the surrounding layout and navigation.

Theming

Web Component: CSS Custom Properties

The component renders in Shadow DOM with isolated styling. CSS custom properties pierce the Shadow DOM boundary, so you can set them on the host element or an ancestor.

If no custom properties are set, the component uses the defaults below. HTS may also apply partner-specific themes server-side based on partnerId.

Header & Borders

CSS Custom Property Token Default Used For
--hts-color-header-fg colorHeaderFg light-dark(rgb(23, 46, 94), rgb(119, 158, 255)) Header title and icon
--hts-color-header-bg colorHeaderBg light-dark(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)) Header fill
--hts-color-header-background colorHeaderBackground light-dark(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)) Deprecated alias of colorHeaderBg. Prefer colorHeaderBg. If both are set, colorHeaderBg wins.
--hts-color-border colorBorder light-dark(rgb(217, 217, 217), rgb(217, 217, 217)) Banner, option card, and radio strokes
--hts-color-option-hover-bg colorOptionHoverBg light-dark(rgb(246, 246, 246), rgb(17, 17, 17)) Option card hover fill

Focus, selected-option border, and the terms link follow colorPrimary. Partners who set an opaque header fill must also set colorHeaderFg; the widget does not auto-correct contrast. Hosts who theme the card surface should also set colorOptionHoverBg if they do not want the default grey hover.

Brand Colors

CSS Custom Property Token Default Used For
--hts-color-primary colorPrimary #2f394e Selected option border, radio button fill, bullet icons
--hts-color-primary-lighter colorPrimaryLighter #eff3ff Header icon background, light accent surfaces
--hts-color-secondary colorSecondary #4f46e5 Secondary accent elements, links

Text Colors

CSS Custom Property Token Default Used For
--hts-color-text-primary colorTextPrimary #181d29 Main body text, headings
--hts-color-text-secondary colorTextSecondary #6B7280 Descriptions, secondary labels, muted text

Status Colors

CSS Custom Property Token Default Used For
--hts-color-status-success colorStatusSuccess #56C470 Success status indicators
--hts-color-success-fg colorSuccessFg #27c281 Success text, bullet point icons, checkmarks
--hts-color-success-bg colorSuccessBg #e8f8f0 Success message background
--hts-color-error-fg colorErrorFg #CC2427 Error text, validation messages
--hts-color-error-bg colorErrorBg #f9eff1 Error message background
--hts-color-warning-fg colorWarningFg #a7173c Warning text, warning icon
--hts-color-warning-bg colorWarningBg #f9eff1 Warning banner background

Typography

CSS Custom Property Token Default Used For
--hts-font-family-base fontFamilyBase 'Proxima Nova', sans-serif All text in the component
--hts-font-size-body-md fontSizeBodyMd 14px Standard body text
--hts-font-size-body-sm fontSizeBodySm 12px Small body text, captions
--hts-font-size-body-xs fontSizeBodyXs 10px Fine print, disclaimers
--hts-font-size-title-lg fontSizeTitleLg 20px Large titles, main heading
--hts-font-size-title-md fontSizeTitleMd 16px Medium titles, section headings
--hts-font-size-title-sm fontSizeTitleSm 14px Small titles, option labels
--hts-font-weight-base fontWeightBase 400 Normal text weight
--hts-font-weight-emphasis fontWeightEmphasis 600 Emphasized text (prices, key values)
--hts-font-weight-headline fontWeightHeadline 700 Headlines, section headers
--hts-font-style-headline fontStyleHeadline normal Headline font style (normal, italic, or oblique)
--hts-font-weight-title fontWeightTitle 700 Titles within options

Layout

CSS Custom Property Token Default Used For
--hts-border-radius-base borderRadiusBase 8px Border radius on cards, buttons, containers
hts-fintech-exercise {
  --hts-color-primary: #1a73e8;
  --hts-color-secondary: #ea4335;
  --hts-color-header-fg: #1a73e8;
  --hts-color-header-bg: transparent;
  --hts-color-border: #d9d9d9;
  --hts-color-option-hover-bg: #f6f6f6;
  --hts-font-family-base: 'Inter', sans-serif;
  --hts-font-style-headline: normal;
  --hts-border-radius-base: 12px;
}
Iframe: hts-theme Event

CSS custom properties cannot cross iframe boundaries. For iframe integrations, use the hts-theme ingress event to send design token overrides. The token names correspond to the "Token" column in the tables above.

const iframe = document.getElementById('hts-exercise');
iframe.contentWindow.postMessage({
  type: 'hts-theme',
  tokens: {
    colorPrimary: '#1a73e8',
    colorSecondary: '#ea4335',
    colorHeaderFg: '#1a73e8',
    colorHeaderBg: 'transparent',
    colorBorder: '#d9d9d9',
    colorOptionHoverBg: '#f6f6f6',
    fontFamilyBase: 'Inter, sans-serif',
    fontStyleHeadline: 'normal',
    borderRadiusBase: '12px'
  }
}, '{{HTS_ORIGIN}}');

See the hts-theme ingress event for the full specification.

Responsive Sizing

The component is fully responsive. The partner controls the container width — the component fills the available width and adjusts its height dynamically based on content.

After each resize, the component emits an hts-dimension event:

{
  "type": "hts-dimension",
  "data": { "width": 800, "height": 600 }
}
  • Web component: The component flows inline — height adjusts automatically. The hts-dimension event is informational.
  • Iframe: You must listen for hts-dimension and update the iframe's height (see the iframe embedding example above).

Security

Web Component Iframe
CSP script-src 'self' {{HTS_ORIGIN}}; connect-src 'self' {{HTS_ORIGIN}}; frame-src 'self' {{HTS_ORIGIN}};
Origin check Verify event.origin on all message events Same
HTTPS Required in production Required in production

Loading Tolerance

If the hts-ready event is not received within a reasonable tolerance period after embedding the component, the hosting application should hide the widget and provide an alternative cancellation path. This prevents user experience degradation if the component fails to load.

POST/orders/{id}/exercise_urlCreate order exercise URL
Partner Self-Service Exercise

For cases where the partner-owned frontend handles the orchestration of the self-service exercise, and HTS provides the backend logic to expose rebooking options, refund breakdowns, and actually fulfill the exercise.

POST/orders/{id}/exercise_quotesCreate CFAR Exercise Quote
PUT/exercise_quotes/{id}/fulfillFulfill CFAR Exercise Quote
Partner Manual Exercise

For cases where the regular, automated flow is not possible: the partner cancelled the reservation and refunded the customer on its own, and informs HTS of the exercise after the fact.

PUT/orders/{id}/exerciseManual CFAR Exercise
Analytics

Endpoints for tracking events and analytics data.

POST/eventsCreate Event
Partner Endpoints

Endpoints that partners must implement and that HTS calls on-demand.

GET/get_bookingGet Booking
POST/cancel_bookingCancel Booking
GET/search_bookingsSearch Bookings