# Set a minimum advanced booking time

## Setting a minimum advanced booking time

There are many cases in which a merchant would like specific services or
slots to be booked a minimum time in advance. These can be set at either the
service level and/or at the availability level. If it is set at both, the
setting at the availability level will be used.

### Service level definition

At the
[service level the field is called `rules.min_advance_booking`](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/feeds/services-feed#SchedulingRules-definition). This field
should be set to the number of seconds in advance of the reservation start
time that the booking needs to be made. For example if the booking always
needs to be made 1 hour before the start time this field would be set to
3600 (so a booking for 3pm can be booked up until 2pm). This would apply to
all slots for that service (unless overridden by [slot level definition](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/tutorials/set-minimum-advanced-booking-time#slot-level)).

### JSON

```json
"service": [
  {
    "rules": {
      "min_advance_booking": 3600
    }
  }
]
```

### Slot level definition

At the
[availability slot level the field is called
`scheduling_rule_overrides.last_bookable_sec`](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/feeds/availability-feed#Availability-definition). This
field is the last time (EPOCH timestamp) that the specific slot can be booked.
This would apply to each individual slot where this was specified.

### JSON

```json
"service_availability": [
  {
    "availability": {
      "scheduling_rule_overrides": {
        "last_bookable_sec": 1468081800
        }
    }
  }
]
```

> [!WARNING]
> **Warning** : Implementing advance booking limit in feeds does not prevent you from having to check if the booking is within the allowed booking window and handle it [`BookingFailure`](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/booking-server-api-rest/e2e-definitions/bookingfailure-definition) `SLOT_UNAVAILABLE`. There might be edge cases (such as a stall browser tab) where a [`CreateBooking`](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/booking-server-api-rest/e2e-methods/createbooking-method) might be sent outside of the booking window. Upon receiving a [`CreateBooking`](https://developers.google.com/actions-center/verticals/local-services/e2e/reference/booking-server-api-rest/e2e-methods/createbooking-method), your system must confirm that the booking occurs within the allowed booking window and, if it's not, respond with `CreateBookingResponse.booking_failure = SLOT_UNAVAILABLE`.