## Request structure

`BatchAvailabilityLookup` requests can span across multiple services for the
same merchant, and slots requested can span multiple resources and days. We
recommend a single Service ID be used across merchants to simplify your
integration.

## Response times

`BatchAvailabilityLookup` requests have a latency threshold of 1.5 seconds
before the response is considered a failure. Make sure that your internal
networking and DNS routing are synced to minimize any delay in the request that
reaches your infrastructure. If there are significant timeout errors, your
integration might be taken offline until you can resolve them.

Every response to a request must return the actual status of your inventory at
that moment and not when the booking flow was entered. If a slot is booked out,
reflect that in current responses.

## Definitions

The `BatchAvailabilityLookup` method verifies that only current slots are
presented to users during the reservation flow.

### BatchAvailabilityLookup request

    message BatchAvailabilityLookupRequest {
      // ID of the merchant.
      string merchant_id = 1;

      // Multiple slot times to be checked for availability. All queried times apply
      // to the same merchant_id and service_id.
      repeated SlotTime slot_time = 3;

      reserved 2;
    }

### BatchAvailabilityLookup response

    // Response for the [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest]
    // RPC with the availabilities of the appointment slots.
    message BatchAvailabilityLookupResponse {
      // The availabilities for the requested SlotTime entries. There must be
      // exactly one slot_time_availability for each SlotTime entry in the
      // [ext.maps.booking.partner.v3.BatchAvailabilityLookupRequest].
      repeated SlotTimeAvailability slot_time_availability = 1;
    }

### SlotTime

    // Identifies a Slot service_id and start time and optionally, the Slot duration
    // and resources, for a specific merchant. Note that this differs from the
    // definition of Slot, as it does not include merchant_id identifier.
    message SlotTime {
      // ID of the service. (required)
      string service_id = 5;

      // Start time of the appointment slot in seconds of UTC time since Unix epoch
      // (required)
      int64 start_sec = 1;

      // Duration of the appointment slot in seconds (optional)
      int64 duration_sec = 2;

      // Opaque tag that identifies the availability slot and matches the value
      // provided in the Availability Feed (optional)
      string availability_tag = 3;

      // The set of resources that specifies the appointment slot, e.g. by
      // indicating the staff member and room selected by the user, or party size
      // for dining slots (optional)
      ResourceIds resource_ids = 4;

      // Indicates whether bookings of this slot will be confirmed
      // synchronously or asynchronously. (optional)
      // An UNSPECIFIED value will be interpreted as synchronous.
      ConfirmationMode confirmation_mode = 6;
    }

### SlotTimeAvailability

If no slots are found, return an empty response. Don't return a 400 error,
instead you can return 204 or other 2xx code. It verifies that the response is
correctly received.

    message SlotTimeAvailability {
      // The SlotTime for which availability was checked.
      SlotTime slot_time = 1;

      // Whether the requested SlotTime is available
      bool available = 2;
    }

## BatchAvailabilityLookup samples

### Page load

When a user clicks **Book Online** to initiate the booking flow, a
`BatchAvailabilityLookup` request is sent with known availability slots for the
merchant. For each slot sent in the request, your Booking Server returns a
response with the actual, current availability of the slot. Only available slots
are presented to the user on the frontend.

If a user changes their party size or selects another date, another page load
request can be sent.

### Page load request

     {
        "merchant_id" : "1234",
       "slot_time" : [
           {
              "duration_sec" : "1800",
              "resource_ids" : {
                 "party_size" : 2
              },
              "service_id" : "1000",
              "start_sec" : "1606467600"
           },
           {
              "duration_sec" : "1800",
              "resource_ids" : {
                 "party_size" : 2
              },
              "service_id" : "1000",
              "start_sec" : "1606469400"
           },
           {
              "duration_sec" : "1800",
              "resource_ids" : {
                 "party_size" : 2
              },
              "service_id" : "1000",
              "start_sec" : "1606471200"
           }
        ]
     }

### Page load response

     { "slot_time_availability" :
        [
           {
              "available" : true,
              "slot_time" : {
                    "duration_sec" : "1800",
                    "resource_ids" : {
                         "party_size" : 2 },
                     "service_id" : "1000",
                     "start_sec" : "1606467600"  }
           },
           {
              "available" : true,
              "slot_time" : {
                    "duration_sec" : "1800",
                    "resource_ids" : {
                         "party_size" : 2 },
                     "service_id" : "1000",
                     "start_sec" : "1606469400" }
           },
           {
              "available" : false,
              "slot_time" : {
                     "duration_sec" : "1800",
                      "resource_ids" : {
                           "party_size" : 2 },
                     "service_id" : "1000",
                     "start_sec" : "1606471200" }
           }
        ]
     }

### Slot click

When a user selects a bookable slot a `BatchAvailabilityLookup` request is sent
for the specific slot. Your Booking Server returns a response with the actual,
current availability of the slot. The expected response is **False** for the
availability if that slot is booked out by another Google user, internally
within your system or between the page load and slot click requests.

### Slot click request

     {
        "merchant_id" : "1234",
        "slot_time" : [
           {
              "duration_sec" : "1800",
              "resource_ids" : {
                 "party_size" : 2
              },
              "service_id" : "1000",
              "start_sec" : "1606467600"
           }
        ]
     }

### Slot click response

     {
        "slot_time_availability" : [
           {
              "available" : true,
              "slot_time" : {
               "duration_sec" : "1800",
                 "resource_ids" : {
                    "party_size" : 2
                 },
                 "service_id" : "1000",
                 "start_sec" : "1606467600"
              }
           }
        ]
     }