> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifystays.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Find Booking by Idempotency-Key

> Recover a booking whose create response never reached you.

If a [Create Booking](/api-reference/create-booking) call times out, or your
system fails before saving `data.booking_id`, look the booking up with the same
`Idempotency-Key` you sent on the create call. The response has the same shape
as [Get Booking Status](/api-reference/get-booking-status).

## Request Example

<RequestExample>
  ```bash theme={null}
  curl "$UNIFYSTAYS_BASE_URL/hotels/book/by-idempotency-key" \
    -H "x-api-key: $UNIFYSTAYS_API_KEY" \
    -H "Idempotency-Key: order-2987349823-booking-1"
  ```
</RequestExample>

## Reading the result

* **200**: a booking exists for the key. Save `data.booking_id` and continue
  with the normal polling or webhook flow.
* **404** `BOOKING_NOT_FOUND`: no booking was created with the key. Retrying
  Create Booking with the same key and payload is safe; if the original request
  is still in flight, the retry returns that same booking instead of creating a
  second one.

The lookup is scoped to your organization and never creates, replays or
changes a booking.


## OpenAPI

````yaml reference/openapi.json GET /hotels/book/by-idempotency-key
openapi: 3.0.0
info:
  title: Unifystays API
  description: >-
    One unified hotel API across suppliers. Integrate once, then enable and
    manage suppliers from the Unifystays portal.
  version: '1.0'
  contact: {}
servers:
  - url: https://api-sandbox.unifystays.com
    description: Sandbox
  - url: https://api.unifystays.com
    description: Production
security:
  - x-api-key: []
tags: []
paths:
  /hotels/book/by-idempotency-key:
    get:
      tags:
        - Hotels
      summary: Find a booking by Idempotency-Key
      description: >-
        Returns the booking created by `POST /hotels/book` with this
        `Idempotency-Key`, in the same shape as `GET /hotels/book/{booking_id}`.
        Use it to recover a booking whose create response was lost (timeout,
        crash) without risking a second booking. Returns 404 when no booking was
        created with the key, which means it is safe to retry the create with
        the same key.
      operationId: HotelBookingController_getBookingByIdempotencyKey
      parameters:
        - name: Idempotency-Key
          in: header
          description: The key sent on the original `POST /hotels/book`.
          required: true
          schema:
            type: string
        - name: language
          description: Enter language code(ex. en)
          in: header
          schema: {}
        - name: X-Unifystays-Contract-Version
          in: header
          required: false
          description: Hotel API contract version. Missing defaults to v1.
          schema:
            type: string
            enum:
              - '1'
            default: '1'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HotelBookingResponseDto'
          headers:
            X-Unifystays-Contract-Version:
              description: Selected hotel contract version.
              schema:
                type: string
                enum:
                  - '1'
        '404':
          description: No booking was created with this Idempotency-Key.
          headers:
            X-Unifystays-Contract-Version:
              description: Selected hotel contract version.
              schema:
                type: string
                enum:
                  - '1'
        '406':
          description: CONTRACT_VERSION_UNSUPPORTED
          headers:
            X-Unifystays-Contract-Version:
              description: Selected hotel contract version.
              schema:
                type: string
                enum:
                  - '1'
components:
  schemas:
    HotelBookingResponseDto:
      type: object
      properties:
        contract_version:
          type: string
          example: '1'
        success:
          type: boolean
          example: true
        message:
          type: string
          example: Booking request accepted and is being processed.
        data:
          $ref: '#/components/schemas/BookingStatusDataDto'
      required:
        - contract_version
        - success
        - message
        - data
    BookingStatusDataDto:
      type: object
      properties:
        booking_id:
          type: string
          example: ubk_eGQ0dW9uV1Vi
          description: >-
            Stable Unifystays booking id used for status, details, and
            cancellation endpoints.
        accepted_offer_id:
          type: string
          example: off_01J...
        status:
          type: string
          enum:
            - AWAITING_REVIEW
            - PROCESSING
            - CONFIRMED
            - ON_HOLD
            - FAILED
            - CANCELLATION_PENDING
            - CANCELLED
          example: PROCESSING
        is_terminal:
          type: boolean
          example: false
        provider:
          $ref: '#/components/schemas/BookingProviderStatusDto'
        next_poll_after_ms:
          type: object
          description: Client hint to re-check booking status. Null when terminal.
          example: 5000
          nullable: true
        processing_reason:
          type: string
          enum:
            - SUPPLIER_CONFIRMATION_PENDING
            - HOTEL_CONFIRMATION_PENDING
            - CANCELLATION_PENDING
            - RECONCILIATION_REQUIRED
            - HOLD_CONFIRMATION_REQUIRED
            - MANUAL_REVIEW_REQUIRED
          nullable: true
        action_required:
          type: boolean
        available_actions:
          type: array
          items:
            type: string
            enum:
              - GET_STATUS
              - GET_DETAILS
              - CANCEL
              - CONFIRM_HOLD
              - CONTACT_SUPPORT
              - REVIEW_BOOKING
        hold_deadline_at:
          type: string
          nullable: true
        created_at:
          type: string
          example: '2026-04-15T12:12:11.000Z'
        updated_at:
          type: string
          example: '2026-04-15T12:12:11.000Z'
        review_expires_at:
          type: string
          nullable: true
      required:
        - booking_id
        - accepted_offer_id
        - status
        - is_terminal
        - provider
        - next_poll_after_ms
        - processing_reason
        - action_required
        - available_actions
        - hold_deadline_at
        - created_at
        - updated_at
        - review_expires_at
    BookingProviderStatusDto:
      type: object
      properties:
        code:
          type: string
          example: TBO
        booking_id:
          type: object
          example: '100055869'
          nullable: true
          description: >-
            Supplier's primary booking/order identifier used to find the
            booking. Null until the supplier assigns it.
        booking_code:
          type: object
          example: REZ6A5A81E9
          nullable: true
          description: >-
            Supplier's secondary booking code, when the supplier provides a
            distinct second reference. Null when it does not.
        hotel_confirmation_number:
          type: object
          example: HCN-482910
          nullable: true
          description: >-
            Hotel confirmation number issued or recognized by the property. It
            may arrive after supplier confirmation.
        hotel_confirmation_status:
          type: object
          example: Confirmed
          nullable: true
        hotel_confirmation_note:
          type: object
          nullable: true
        hotel_contact_phone:
          type: object
          nullable: true
        hotel_contact_name:
          type: object
          nullable: true
      required:
        - code
        - booking_id
        - booking_code
        - hotel_confirmation_number
        - hotel_confirmation_status
        - hotel_confirmation_note
        - hotel_contact_phone
        - hotel_contact_name
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: Environment-specific API key created in the Unifystays portal

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.