HTS APIs
Every endpoint, schema and error code, rendered from the published OpenAPI files, in the order you integrate them.
Flights CFAR API
Base URLs
- Staging
- https://fintech.staging.htsapis.com/flights-cfar/v2
- Production
- https://fintech.htsapis.com/flights-cfar/v2
Endpoints
Endpoints for creating, pricing, and retrieving offers for a customer's itinerary, as well as generating merchandising content for those offers.
Merchandising SDK Integration
HTS merchandising SDKs are lightweight, embeddable components that display product offers on your website. The SDKs are built with SolidJS and delivered as web components that render in Shadow DOM with isolated styling.
Integration Flow
1. Obtain SDK URL from create offer API → 2. Embed SDK in partner purchase flow → 3. Customer selects option → 4. Process selection event
Custom Element
| Element Name |
|---|
<hts-flights-cfar-merchandising> |
Basic Integration
<!-- Preconnect for faster DNS resolution -->
<link rel="preconnect" href="https://hts.hopper.com" />
<!-- SDK Script (merchandising_url from create offer API response) -->
<script src="{{MERCHANDISING_URL}}" type="module" async></script>
<!-- SDK Component -->
<hts-flights-cfar-merchandising></hts-flights-cfar-merchandising>
Dynamic Integration (JavaScript)
// merchandising_url is provided in the create offer API response
const sdkUrl = merchandisingUrl;
// Create and insert script
const script = document.createElement('script');
script.src = sdkUrl;
script.type = 'module';
script.async = true;
document.head.appendChild(script);
// Create and insert component
const component = document.createElement('hts-flights-cfar-merchandising');
document.body.appendChild(component);
Handling SDK Events
The SDK communicates with your page using the postMessage API.
Event Types
| Event Type | Description | When Fired |
|---|---|---|
hts-initialized |
SDK 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) |
Listening to Events
window.addEventListener('message', (event) => {
// Verify origin for security
if (event.origin !== 'https://hts.hopper.com') return;
const { type, product, data } = event.data;
switch (type) {
case 'hts-initialized':
console.log(`${product} SDK initialized`);
break;
case 'hts-option-selected':
if (data.attached && data.offer) {
// User selected the offer
console.log(`Offer selected, price: ${data.offer.premium} ${data.offer.currency}`);
} else {
// User declined the offer
}
break;
case 'hts-invalid-params':
console.error('SDK validation failed:', data.error);
break;
case 'hts-dimension':
// Adjust iframe height if using iframe integration
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('SDK initialization failed:', data.type);
break;
case 'hts-validated':
// Enable/disable your proceed control based on data.isValid
setProceedEnabled(data.isValid);
break;
}
});
Key Event Payloads
hts-option-selected
{
"type": "hts-option-selected",
"product": "flights-cfar",
"data": {
"attached": true,
"selected": "0018868d-652f-4134-b094-a37ebb651f1a",
"offer": {
"offerId": "0018868d-652f-4134-b094-a37ebb651f1a",
"premium": "48.00",
"currency": "USD",
"coveragePercentage": "100"
}
}
}
When attached is false, the user declined the offer.
hts-initialization-failed
{
"type": "hts-initialization-failed",
"product": "flights-cfar",
"data": {
"type": "unsupported_locale",
"locale": "ja"
}
}
Fired when the app cannot initialize due to a precondition failure. The widget will not render. Currently the only failure type 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.
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.
{
"type": "hts-validated",
"product": "flights-cfar",
"data": { "isValid": false }
}
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).
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 |
entry-point |
string | The placement the widget is shown in; adjusts UI & copy |
<hts-flights-cfar-merchandising
selected="none"
rewards-type="miles"
rewards-conversion="100"
entry-point="postbooking"
></hts-flights-cfar-merchandising>
<!-- Pre-select a specific offer -->
<hts-flights-cfar-merchandising selected="0018868d-..."></hts-flights-cfar-merchandising>
Iframe Parameters
When using iframe integration, the same customizations are supplied as camelCase query parameters on the merchandising URL. See the Iframe Integration (Alternative) section below for the embed snippet.
| 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 |
entryPoint |
string | The placement the widget is shown in; adjusts UI & copy |
Iframe Integration (Alternative)
For partners who prefer iframe-based integration, use the merchandising_url from the create offer response:
<iframe
src="{{MERCHANDISING_URL}}"
style="width: 100%; border: none; height: 400px;">
</iframe>
Use the hts-dimension event to adjust iframe height dynamically.
Loading Tolerance
If the hts-initialized event is not received within a reasonable tolerance period after embedding the SDK, the hosting application should hide the widget and not require forced selection. This prevents user experience degradation if the SDK fails to load.
Styling and Theming
The SDK renders in Shadow DOM with partner-specific themes applied automatically based on your partnerId. Internal component styling cannot be overridden due to Shadow DOM encapsulation. Contact HTS if you need theme customization.
Security Considerations
- Origin Verification: Always verify
event.originwhen handling postMessage events - HTTPS Only: Always use HTTPS URLs in production
- CSP Headers: Ensure your Content Security Policy allows loading scripts from
hts.hopper.com
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.
Endpoints for managing the lifecycle of contracts after purchase, including creation, confirmation, retrieval, search, and cancellation.
For cases where self-service tooling is not functioning properly, either due to a disruption that was not automatically identified by HTS, or an exercise that needs to occur outside of our tooling (like a payout to a different payment method than used for purchase, or a rebooking that was done directly with the GDS).
The partner utilizes the HTS frontend to handle 100% of the exercise experience end to end.
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.
Endpoints that partners must implement and that HTS calls on-demand.
