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."IN" (and possibly others). A 401 means the key is missing,
wrong, or from the other environment.
2. Find a destination
"type": "place":
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
nationality; suppliers price by it. Details:
Search Hotels.
4. Poll for prices
Cards withprice.status = "checking" are still being priced. Poll every 2
seconds while the result page is visible.
Pick a hotel that has a price:
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:
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.decision is NOT_BOOKABLE, prebooking_id is null: go back to step 5.
Details: Prebook a Room.
7. Create the booking
Generate oneIdempotency-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.
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.
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: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 aCONFIRMED (or ON_HOLD) booking whose
available_actions contains CANCEL.
After the guest accepts the penalty:
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.
What to read next
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.