# Set Cancellation Windows

## How to Add Cancellation Windows


Cancellation windows define when the cancel and modify buttons are active. This
means the cancel and modify functions will be inoperable in user confirmation
emails and will disappear from all other surfaces, including the confirmation modal.

![Confirmation modal with cancel and modify buttons removed](https://developers.google.com/static/actions-center/images/reserve-cancel-modify.png)

Cancellation windows can be enabled in two ways: service-level and
slot-level. The processes for specifying windows at these levels are
discussed below.

If both a service-level and a slot-level cancellation window are set, the
slot-level window will take effect. If neither are set, the cancellation window
defaults to the start of the time slot (i.e. the user can be cancelled at the
last minute).

### Service level definition

Service-level cancellation windows can be enabled by specifying
`rules.min_advance_online_canceling` in the
[Service](https://developers.google.com/actions-center/verticals/reservations/e2e/reference/feeds/services-feed#SchedulingRules-definition)
feed. 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 can only be cancelled up
until 24h before the start time this field would be set to
86400 (so a booking for 3pm can only be cancelled until 3pm the previous day).
This would apply to all slots for that service
(unless overridden by [slot level definition](https://developers.google.com/actions-center/verticals/reservations/e2e/reference/tutorials/set-cancellation-windows#slot-level)).

### JSON

```json
{
  "service": [
    {
      "rules": {
        "min_advance_online_canceling": 86400
      }
    }
  ]
}
```

### Slot level definition

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

### JSON

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

> [!WARNING]
> **Warning** : Implementing cancellation window in feeds does not prevent you from having to implement and handle the [`BookingFailure`](https://developers.google.com/actions-center/verticals/reservations/e2e/reference/booking-server-api-rest/e2e-difinitions/bookingfailure-definition) `OUTSIDE_CANCELLATION_WINDOW`. There might be edge cases (such as a stall browser tab) where an `https://developers.google.com/actions-center/verticals/reservations/e2e/reference/booking-server-api-rest/e2e-methods/updatebooking-method` might be sent outside of the specified cancellation window. Upon receiving an `https://developers.google.com/actions-center/verticals/reservations/e2e/reference/booking-server-api-rest/e2e-methods/updatebooking-method`, your system must confirm that the change occurs within the specified cancellation window and, if it's not, respond with `UpdateBookingResponse.booking_failure = OUTSIDE_CANCELLATION_WINDOW`.