Getting Started with the Xeni Activities APIHow to Book an ActivityHow to Browse Activity Tags and CategoriesHow to Cancel an Activity BookingHow to Check Activity AvailabilityHow to Get Activity DetailsHow to Retrieve Activity Booking DetailsHow to Search for Activities with FiltersHow to Search for Activity DestinationsCar Rental API - Getting StartedCar Rental API - Understanding Response FieldsHow to Book a Car RentalHow to Get Rental Car Details and Equipment Add-OnsHow to Retrieve or Cancel a Car Rental BookingHow to Search for Available Rental CarsHow to Search for Pickup LocationsHow to Use Car Rental Search FiltersDeals API Best Practices for IntegrationDeals API Frequently Asked QuestionsGetting Started with the Xeni Deals APIDeals API Request Parameters and Headers ReferenceDeals API Supported Currencies and LocalizationHow to Display Deals in Your ApplicationHow to Fetch Hotel Deals by LocationFlights API Error Codes and TroubleshootingGetting Started with the Xeni Flights APIHow to Book a FlightHow to Check Flight Availability and PricingHow to Confirm or Cancel a Flight BookingHow to Retrieve Fare Rules for a FlightHow to Retrieve Flight Booking DetailsHow to Search for Airports Using AutocompleteHow to Search for FlightsHow to Use Flight Search Filters, Sorting, and PaginationHow to Check Room Availability and PricingHow to Filter Vacation Rental ResultsHow to Get Resort Property Details, Amenities, and AccessibilityHow to Hold and Confirm a Resort BookingHow to Release a Resort HoldHow to Retrieve Resort Booking DetailsHow to Search for Available ResortsHow to Search for Resort DestinationsHow to Search for Vacation Rental LocationsHow to Search for Vacation RentalsHow to Use Resort Search Filters and SortingGetting Started with the Xeni Resorts APIResorts API: Understanding Booking Statuses and PoliciesGetting Started with the Vacation Rentals APIVacation Rentals Frequently Asked QuestionsVacation Rentals Supported Property TypesUnderstanding Async Search for Vacation RentalsAuthentication & API SignaturesBooking Hotels — Direct API & SSO CheckoutError Handling, Rate Limits & Best PracticesGetting Started with the Xeni Hotels APIManaging Bookings: Status, Retrieval & CancellationPricing Confirmation & Token LifecycleRetrieving Hotel Details & Room AvailabilitySearching for Hotels: Locations, Filters & PaginationSearching for HotelsSession Management & Correlation IDsAPI authentication and getting your API keys

Session Management & Correlation IDs

Last updated: 2026-02-13

Session Management & Correlation IDs

The Xeni Hotels API uses correlation IDs to tie related API calls together within a single search-to-booking session. Understanding how correlation IDs work is essential for a correct integration. This article explains the session lifecycle, when correlation IDs change, and how to manage them.

What Is a Correlation ID?

A correlation ID is a unique identifier that the API generates and returns in the response headers of your first API call (typically the autocomplete/location search). It links all subsequent calls — hotel search, details, availability, pricing, and booking — into a coherent session.

Think of it as a session token for the API. Without it, the API can't associate your availability check with the hotel search that preceded it.

How Correlation IDs Are Created

  1. You make your first API call (usually GET /hotels/api/v2/autocomplete).
  2. The response includes an x-correlation-id header.
  3. You capture this value and include it as the x-correlation-id header in every subsequent API call.

Example: Capturing the Correlation ID

// JavaScript (axios)const response = await axios.get('/hotels/api/v2/autocomplete', {  params: { key: 'Miami' },  headers: {    'Authorization': signature,    'Content-Type': 'application/json'  }});

// Capture the correlation ID from response headersconst correlationId = response.headers['x-correlation-id'];

// Use it in all subsequent callsconst searchResponse = await axios.post('/hotels/api/v2/properties?page=1&limit=20', searchBody, { headers: { 'Authorization': signature, 'Content-Type': 'application/json', 'x-correlation-id': correlationId // Pass it forward }});

Example: Python

# Python (requests)response = requests.get(    f"{base_url}/hotels/api/v2/autocomplete",    params={"key": "Miami"},    headers={"Authorization": signature, "Content-Type": "application/json"})

Capture from response headerscorrelation_id = response.headers.get("x-correlation-id")

Use in subsequent callssearchresponse = requests.post( f"{baseurl}/hotels/api/v2/properties?page=1&limit=20", json=searchbody, headers={ "Authorization": signature, "Content-Type": "application/json", "x-correlation-id": correlationid })

*

Session Lifecycle

A session begins with a location search and continues through the entire booking flow:

┌─────────────────────────────────────────────────────┐│ SESSION START                                        ││                                                      ││  1. searchLocations("Miami")                         ││     → API returns x-correlation-id: "abc-123"        ││                                                      ││  2. searchHotels(lat, long, dates)                   ││     → Send x-correlation-id: "abc-123"               ││                                                      ││  3. getHotelDetails(propertyId)                      ││     → Send x-correlation-id: "abc-123"               ││                                                      ││  4. checkAvailability(propertyId, dates, occupancy)  ││     → Send x-correlation-id: "abc-123"               ││                                                      ││  5. getPrice(availabilityToken)                      ││     → Send x-correlation-id: "abc-123"               ││                                                      ││  6. SSO Checkout or createBooking(pricingToken)      ││     → Uses x-correlation-id: "abc-123"               ││                                                      ││ SESSION END                                          │└─────────────────────────────────────────────────────┘

The same correlation ID is used throughout the entire flow. All steps are linked to the same session.

*

When Does the Correlation ID Change?

A new correlation ID is generated when a new location search is performed. This is by design — a new location search starts a new session.

Example: User Changes Destination

1. User searches "Miami"   → correlationId = "abc-123"   → Hotels in Miami are displayed
  1. User searches "Las Vegas" → API returns NEW correlationId = "def-456" → Hotels in Las Vegas are displayed
  1. User selects a hotel in Las Vegas → Use correlationId "def-456" (NOT "abc-123") → The Miami session is effectively abandoned

Important: When a new location search returns a new correlation ID, you must discard the old correlation ID and all associated session data (search results, availability tokens, pricing tokens). These are invalidated when the session changes.

*

What to Store in Your Session

To manage the search-to-booking flow, your application should maintain session state that tracks these values:

FieldSet WhenUsed By
correlationIdLocation searchAll subsequent API calls (header)
locationDataLocation searchHotel search (coordinates), SSO checkout URL
searchParamsHotel searchPagination, availability check, SSO checkout URL
searchResultsHotel searchDisplay to user, hotel selection
propertyIdUser selects a hotelDetails, availability, SSO checkout URL
roomIdAvailability checkSSO checkout URL
availabilityTokenAvailability checkPrice confirmation
pricingTokenPrice confirmationSSO checkout URL, booking creation
pricingTokenIssuedAtPrice confirmationToken expiry check (10-minute window)

*

Session Storage Recommendations

Server-Side Sessions

For most integrations, we recommend storing session data server-side with a TTL (time-to-live):

  • Redis — Ideal for session storage with automatic expiration. Set a TTL of 30 minutes to match the API signature lifetime.
  • In-memory store — Suitable for development or single-server deployments. Use a Map with periodic cleanup.
  • Database — Viable for persistence, but add a last_activity timestamp and clean up stale sessions.

Recommended TTL

Set your session TTL to 30 minutes, matching the API signature lifetime. Extend the TTL on each user interaction to keep active sessions alive.

Session Cleanup

When a session expires or the user starts a new search:

  1. Discard the old correlation ID.
  2. Clear stored search results, tokens, and pricing data.
  3. The new location search will establish a fresh session with a new correlation ID.

*

Common Pitfalls

PitfallConsequenceSolution
Not passing x-correlation-idAPI calls fail or return inconsistent data.Always capture and forward the correlation ID after the first call.
Reusing old correlation IDsBooking or availability calls reference stale search context.Replace the correlation ID whenever a new location search returns a new one.
Using an availability token after getting a pricing tokenBooking fails.Always use the pricing_token from the pricing confirmation step.
Not clearing session data on new searchOld tokens and results from a previous destination contaminate the new search flow.Reset all session data (except the new correlation ID) when the user searches a new location.

*
](#article-9)_

Was this article helpful?