# Inventory Message

## Overview

The Inventory message (`OTA_HotelInvCountNotifRQ`) defines the inventory counts
(number of physical rooms) that are available to be booked for specific room
types. When you send an Inventory message, you indicate how many rooms of that
type are available on a given date. If no rooms of that type are available,
products involving that room type and date will not display.

The following sections cover general guidelines, a basic example, and how-to
scenarios to get you started with adding and updating inventory and sending
Inventory messages.

For examples of various inventory-related scenarios, see
[How-tos](https://developers.google.com/hotels/hotel-prices/dev-guide/ari-inventory-message#inventoryhowtos).

## Required and optional elements

The [XML reference](https://developers.google.com/hotels/hotel-prices/xml-reference/ari-overview)
provides descriptions of the required and optional elements. For details
on attributes and child elements, see [Inventory elements \&
attributes](https://developers.google.com/hotels/hotel-prices/xml-reference/ari-inv).

## Syntax and schemas

Use the [Inventory
syntax](https://developers.google.com/hotels/hotel-prices/xml-reference/ari-inv#inv-syntax) example as a
reference when you create the Inventory message to ensure you are following the
correct format.

You can use a third-party XML tool such as xmllint to validate your feeds with
the published schemas before submitting them to Google. For the Inventory
message schema, see [Hotel ads schemas](https://developers.google.com/hotels/hotel-prices/dev-guide/schemas).

## Guidelines

Use the following guidelines for an Inventory message:

- Inventory is keyed by hotel, date, and room type.

- Inventory count must be greater than `0` for all nights of the stay in order
  to show the price for the associated rate plan and occupancy.

- If inventory count is equal to `0`, then rooms will be not be available to
  book for the specified Room ID and date range.

- `CountType` must always have the value of `2` to be valid since it indicates
  a count of "definite availability."

- Send updated inventory whenever a reservation or cancellation for a room
  occurs in your system.

> [!NOTE]
> **Note:** Send room inventory counts by using either `OTA_HotelInvCountNotifRQ` (recommended method) or the alternate method using the `<BookingLimit>` attribute of the `OTA_HotelAvailNotifRQ` message.

### Inventory versus availability

Inventory is the number of bookable rooms based on physical count and
availability indicates whether the combination of room type and rate plan is
allowed to be booked. For ARI, availability and inventory can both vary based
on a set of dates or type of accommodation, and both have corresponding
message types. Inventory and availability are keyed by hotel, date, and room
type, with the addition of rate plan for availability.

There can be "no availability" even when there is inventory since inventory
and availability are independent of each other.

There are two concepts of availability. First, there's the overall availability
of a product for a given stay which is impacted by factors such as
whether every night has a defined rate, inventory for the associated room type,
and the availability restriction is open. Second, there's the specific
restriction for a product on a given date, represented by `<RestrictionStatus
Restriction="Master" Status="Open"/>` in `OTA_HotelAvailNotifRQ`, and closing
this availability is known as a "stop sell."

Inventory must be an integer greater than `0` for the room and the availability
restriction must be open in order to show the price for a product.

> [!NOTE]
> **Note:** If a room is sold out, any rate plans associated with that room can no longer be sold.

## Example

This section provides a basic example of an Inventory message using required
and optional elements. Once you prepare your file, you will need to send it to
Google via a POST message to this endpoint:

    https://www.google.com/travel/hotels/uploads/ota/hotel_inv_count_notif

To learn more about how to push/POST the message, see [Pushing
messages](https://developers.google.com/hotels/hotel-prices/dev-guide/ari-overview#pushing-messages).

> [!IMPORTANT]
> **Key Point:** Send Google an updated Inventory message whenever your inventory changes, such as when bookings and cancellations occur.

For `HotelCode`, use the unique Hotel ID you used within your system for
identifying the property. This value must match the Hotel ID specified using
[`<id>` in the `<listing>`
element](https://developers.google.com/hotels/hotel-prices/xml-reference/hotel-list-feed#listing) in the
Hotel List feed. For `<RoomID>`, use the same ID you used within your system for
room types. Consistency with your system is critical for ensuring that Google
is correctly displaying your data.

> [!NOTE]
> **Note:** `<CountType=2>` is the only valid option since it indicates a count of "definite availability."

This example shows how to set inventory for 13 bookable rooms for the
month of December:

    <?xml version="1.0" encoding="UTF-8"?>
    <OTA_HotelInvCountNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05"
                              EchoToken="12345678"
                              TimeStamp="2022-02-25T20:50:37-05:00"
                              Version="3.0">
      <POS><Source><RequestorID ID="partner_key" /></Source></POS>
      <Inventories HotelCode="HotelID">
        <Inventory>
          <StatusApplicationControl Start="2022-12-01"
                                    End="2022-12-31"
                                    InvTypeCode="RoomID"/>
          <InvCounts>
            <InvCount Count="13" CountType="2"/>
          </InvCounts>
        </Inventory>
      </Inventories>
    </OTA_HotelInvCountNotifRQ>

For more examples, see [Inventory
examples](https://developers.google.com/hotels/hotel-prices/xml-reference/ari-inv#inv-examples).

## How-tos

This section provides a scenario you might encounter while sending an
Inventory message.

### Scenario: How to block rooms from being booked

#### Description

You need to indicate that there are no remaining rooms that can be booked for
this room type on a specific set of dates, most commonly because they are
sold out.

#### Solution

You set `<InvCount Count>` to a `0` value and add the desired date range.

#### Sample

This sample shows how to use `InvCount` to set inventory to `0` for the
specified room and dates (for example, the first few weeks in January).

> [!NOTE]
> **Note:** If the inventory count for a room is `0` for any night of a stay, then the stay can't be booked for any products associated with that room.

    <?xml version="1.0" encoding="UTF-8"?>
    <OTA_HotelInvCountNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05"
                              EchoToken="12345678"
                              TimeStamp="2022-02-25T20:50:37-05:00"
                              Version="3.0">
      <POS><Source><RequestorID ID="partner_key" /></Source></POS>
      <Inventories HotelCode="Property_1">
        <Inventory>
          <StatusApplicationControl Start="2023-01-01"
                                    End="2023-01-15"
                                    InvTypeCode="ROOMID"/>
          <InvCounts>
            <InvCount Count="0" CountType="2"/>
          </InvCounts>
        </Inventory>
      </Inventories>
    </OTA_HotelInvCountNotifRQ>