Skip to main content
This walkthrough makes every call of the booking flow once, in order, from your terminal. Each step shows the smallest request that works and the few response fields you need for the next step. It takes about 15 minutes. You need curl and jq. Run all steps in the same shell so the variables carry over.
Sandbox only has hotels in 12 test cities: Paris, Los Angeles, Dubai, Rome, Naples, Istanbul, Tokyo, Bangkok, Chiang Mai, New Delhi, Ho Chi Minh City and Marrakech. This guide uses Dubai. If you search for another city, Sandbox returns an empty result. That does not mean your key or request is wrong. Use IDs that Sandbox returns, not IDs copied from Production. See Sandbox test cities.

1. Set up Sandbox and your environment

Sign in at unifystays.com, choose Sandbox, add and enable at least one supplier, and create a Sandbox API key. See Portal & Environments.
Check that the key works:
You should see "IN" (and possibly others). A 401 means the key is missing, wrong, or from the other environment.

2. Find a destination

Send at least 3 characters. Pick a result with "type": "place":
Never send the result’s id field (place-2930267). It is only a UI key. For a hotel result send type: "hotel" and its hotel_id as a number. Details: Destination Autocomplete.

3. Search hotels

Always send the traveller’s real nationality; suppliers price by it. Details: Search Hotels.

4. Poll for prices

Cards with price.status = "checking" are still being priced. Poll every 2 seconds while the result page is visible.
Pick a hotel that has a price:
The search price is indicative. The price you charge comes from the next steps. Details: Get Search Price Updates.

5. Get rooms and read the stream

Send the same dates, occupancy and nationality as the search.
Now read the stream. The offers arrive as provider_options events; the last event is done. The connection stays open after done, so this command stops by itself after 50 seconds. (A real client closes the connection at done.)
Choose an offer. For this walkthrough take a refundable one:
Browsers cannot send x-api-key with EventSource, so open the stream from your server and forward events to the browser. Reconnecting, family objects and room cards are covered in Stream Room Updates and Get Hotel Rooms.

6. Prebook the chosen offer

Prebook asks the supplier right now whether the room and price still hold.
If decision is NOT_BOOKABLE, prebooking_id is null: go back to step 5. Details: Prebook a Room.

7. Create the booking

Generate one Idempotency-Key for this booking attempt and keep it. Build the answers from the requirement_id values printed in step 6; never invent IDs. The example below is for one room with two adults and the common title, first name and last name requirements. If your offer asks for more (for example email or phone for the lead guest), add those answers too.
Use the real traveller’s public IP in X-Unifystays-End-User-IP in production (some suppliers require it). For a multi-room search, send one rooms[] entry for every room of the prebook.
The response to Create Booking is never a confirmed reservation. If the call times out, do not create a new key. Look the booking up with the same key: curl "$UNIFYSTAYS_BASE_URL/hotels/book/by-idempotency-key" -H "x-api-key: $UNIFYSTAYS_API_KEY" -H "Idempotency-Key: $IDEMPOTENCY_KEY".
A booking whose free-cancellation window ends within 2 days, or a non-refundable offer, starts as AWAITING_REVIEW and waits for approval in the portal. Nothing is reserved until then. Use a refundable offer with dates well ahead, as in this walkthrough, to get PROCESSING. Details: Create Booking.

8. Track the booking

Poll the status, or receive a webhook (see below).
When it is CONFIRMED, read the full record with GET /hotels/book/$BOOKING_ID/details. See Get Booking Status and Get Booking Details.

Or receive webhooks instead of polling

Register a public HTTPS endpoint, then send a test event:
The signing_secret is shown once. Verify every delivery with it (Verify Webhook Signatures), deduplicate on the event id, and apply events by data.object.version. The full guide is Webhooks.

9. Cancel the booking

Cancelling takes two calls: get a quote that shows the penalty, then cancel with the quote. This only works on a CONFIRMED (or ON_HOLD) booking whose available_actions contains CANCEL.
After the guest accepts the penalty:
The result is CANCELLED or CANCELLATION_PENDING. Do not tell the guest it is cancelled until the status is CANCELLED (poll step 8 or wait for booking.cancelled). Details: Quote Cancellation and Cancel Booking.

Hotel Booking Flow

Sequence diagram, expiries, error recovery and UI guidance.

IDs and Tokens Cheat Sheet

What to store, what to send back, how long each value lives.

Errors & Retries

Every error code and what to do about it.

Launch Checklist

Go-live steps for Production.