> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/rentals/sample-flows.md

## Article Content:

# Wix Rentals: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful jumping off point as you plan your implementation.

## Set up a rental service

Create a service that customers can book for a flexible number of hours or days. A service supports a single unit type, so create a separate service for each. The resource's working hours determine how a multi-day reservation is stored, so review [resource schedules](https://dev.wix.com/docs/api-reference/business-solutions/rentals/about-wix-rentals-availability.md#resource-schedules) before you start.

To set up a rental service:

1. Call [Create Resource Type](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resource-types-v2/create-resource-type.md) to define the category of bookable resources, such as conference rooms. Save the resource type ID.
1. Call [Create Resource](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/create-resource.md) for each bookable resource, such as Room A and Room B. Set the resource type ID from step 1 and configure working hours. To make a resource bookable around the clock, leave its working hours undefined. Save each resource ID.
1. Call [Create Service](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/create-service.md), specifying the following parameters:
   - `type`: `APPOINTMENT`.
   - `appId`: `ff5d6eb1-65e4-4f9a-8b14-64d34c12cc2e`.
   - `primaryResourceType`: The resource type ID from step 1.
   - `payment.rateType`: `FIXED`, with `payment.fixed.price` set to the price per unit.
   - The duration range parameters for the unit type you want, as described in the following table.
1. Save the service ID from the response.
1. Optionally, call [Create Booking Policy](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policies/create-booking-policy.md) to configure cancellation and rescheduling rules.

The following table shows the duration range parameters for each unit type. All parameters are nested under `schedule.availabilityConstraints.durationRange`:

| Unit type | Parameters | Allowed values | Example |
| --- | --- | --- | --- |
| `HOUR` | `hourOptions.minDurationInMinutes`, `hourOptions.maxDurationInMinutes` | 30 to 1440 minutes | `60` and `480` for 1 to 8 hours |
| `DAY` | `dayOptions.minDurationInDays`, `dayOptions.maxDurationInDays` | 1 to 8 days | `1` and `5` for 1 to 5 days |

The minimum must be less than or equal to the maximum.

## Book an hourly rental

Display the available time slots, let the customer select a start and end time, and create the booking. Learn more about [hourly availability](https://dev.wix.com/docs/api-reference/business-solutions/rentals/about-wix-rentals-availability.md#hourly-availability).

### Part 1: Select a time slot

To let the customer select when the rental starts and ends:

1. Call [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) with the `serviceId`, `timeZone`, `fromLocalDate`, and `toLocalDate`. Display the available start times to the customer and save the one they select.
1. Call [List Availability Time Slot End Options](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slot-end-options.md) with the `serviceId` and the selected start time as `localStartDate`. The service's maximum duration caps the response, so you don't need to specify `maxLocalEndDate`. Display the available end times to the customer and save the one they select.

### Part 2: Create the booking

To reserve the selected time range:

1. Call [Create Booking](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/create-booking.md), specifying the following parameters:
   - `bookedEntity.slot.serviceId`: The service ID.
   - `bookedEntity.slot.startDate`: The selected start time.
   - `bookedEntity.slot.endDate`: The selected end time.
   - `bookedEntity.slot.timezone`: The time zone the slot was displayed in.
   - `bookedEntity.slot.resourceSelections`: An entry with `resourceTypeId` set to the service's resource type ID, and `selectionMethod` set to `ANY_RESOURCE` to let Wix assign a resource, or `SPECIFIC_RESOURCE` when the customer chose a particular resource.
   - `contactDetails`: The customer's contact details.
1. Save the booking ID from the response. Wix creates the booking with status `CREATED`.

If the slot was taken between selection and booking, the call fails with `SLOT_NOT_AVAILABLE`. If the chosen duration falls outside the service's duration range, it fails with `INVALID_DURATION_PROVIDED`, and the response includes the allowed range so you can display a useful message. Handle both errors by returning the customer to the slot picker.

Then [handle payment for the rental](#handle-payment-for-a-rental).

## Book a daily rental with working hours

Book a multi-day rental on a resource that has working hours. Each working day is a separate bookable unit, so the reservation becomes a linked group of bookings, 1 per day. Learn more about [daily availability](https://dev.wix.com/docs/api-reference/business-solutions/rentals/about-wix-rentals-availability.md#daily-availability).

To book a daily rental on a resource with working hours:

1. Call [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) with the `serviceId`, `timeZone`, `fromLocalDate`, `toLocalDate`, and `timeSlotsPerDay` set to `1`. Display the available days to the customer and save the slot list.
1. After the customer selects a start date, iterate forward through the slot list to find the consecutive available days. Stop at the first gap or when you reach the service's maximum duration. Display the valid end dates to the customer.
1. Build an array of per-day bookings, 1 for each day in the selected range. Specify the following parameters in each booking:
   - `bookedEntity.slot.serviceId`: The service ID.
   - `bookedEntity.slot.startDate`: The start of the resource's working period on that day. For example, 9 AM.
   - `bookedEntity.slot.endDate`: The end of the resource's working period on that day. For example, 6 PM.
   - `bookedEntity.slot.timezone`: The time zone the slots were displayed in.
   - `contactDetails`: The customer's contact details.
1. Call [Create Multi Service Booking](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/introduction.md), specifying the following parameters:
   - `bookings`: The array of per-day bookings from step 3. A group holds between 2 and 8 bookings.
   - `multiServiceBookingType`: `SEQUENTIAL_BOOKINGS`.
1. Save the multi-service booking ID from `multiServiceBookingInfo.id` in the response. You need it to cancel the group later.

Wix creates the group all or nothing. If any day in the range is unavailable, or the days aren't consecutive, the call fails and no bookings are created.

Then [handle payment for the rental](#handle-payment-for-a-rental).

## Book a daily rental around the clock

Book a multi-day rental on a 24/7 resource, which has no working hours. Consecutive days form 1 unbroken block, so the whole range becomes a single booking.

To book a daily rental on a 24/7 resource:

1. Call [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) with the `serviceId`, `timeZone`, `fromLocalDate`, `toLocalDate`, and `timeSlotsPerDay` set to `1`. Display the available days to the customer and save the slot list.
1. After the customer selects a start date, iterate forward through the slot list to find the consecutive available days. Stop at the first gap or when you reach the service's maximum duration. Display the valid end dates to the customer.
1. Call [Create Booking](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/create-booking.md), specifying the following parameters:
   - `bookedEntity.slot.serviceId`: The service ID.
   - `bookedEntity.slot.startDate`: Midnight on the first day of the rental.
   - `bookedEntity.slot.endDate`: Midnight on the day after the last day of the rental. For a rental from Monday to Wednesday inclusive, this is midnight on Thursday.
   - `bookedEntity.slot.timezone`: The time zone the slots were displayed in.
   - `bookedEntity.slot.resourceSelections`: An entry with `resourceTypeId` set to the service's resource type ID, and `selectionMethod` set to `ANY_RESOURCE`.
   - `contactDetails`: The customer's contact details.
1. Save the booking ID from the response.

Wix derives `bookedEntity.slot.allDay` and sets it to `true`. Don't set this field yourself.

Then [handle payment for the rental](#handle-payment-for-a-rental).

## Handle payment for a rental

Charge the customer for a rental booking through Wix eCommerce. This flow is the same for hourly and daily rentals.

To charge the customer:

1. Call [Create Checkout](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/checkout/checkout/create-checkout.md), specifying the following parameters:
   - `catalogReference.appId`: The [Wix Bookings app ID](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md), `13d21c63-b5ec-5912-8397-c3a5ddb27a97`. Don't use the Wix Rentals app ID here.
   - `catalogReference.catalogItemId`: The booking ID.
1. Call [Get Checkout URL](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/checkout/checkout/get-checkout-url.md) and redirect the customer to the returned URL.
1. After checkout, Wix eCommerce creates an order and updates the booking status to `CONFIRMED`.

## Set up resource attributes

Define custom properties for your rental resources and display them on the public site. For example, a vacation rentals business can add `Capacity` (number), `Bed Type` (string), and `Has WiFi` (boolean) attributes to each room.

To set up resource attributes:

1. Call [Create Attribute Definition](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/attributes/attribute-definition/create-attribute-definition.md) for each property. Specify a unique `name`, a `valueType`, type-specific configuration (`stringConfig.allowedValues` for strings, `numberConfig.min`/`max` for numbers), and a `defaultValue`. Save the returned attribute definition ID. Definitions are created once per site.
1. Call [Bulk Upsert Attribute Values](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/attributes/attribute-value/bulk-upsert-attribute-values.md) with the resource ID as `entityId` and the list of values. Each entry is matched by `attributeDefinitionId`, so only the listed attributes are created or updated.
1. To display attributes on the public site, call [List Entity Attributes](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/attributes/attribute-value/list-entity-attributes.md) with the resource ID as `entityId`. Filter the results to attributes where `attributeDefinition.visibility` is `true`, because the API doesn't enforce visibility on the backend.

## Cancel a single rental booking

Cancel an hourly rental, or a daily rental on a 24/7 resource. Both are stored as a single booking. Learn more about [resource schedules](https://dev.wix.com/docs/api-reference/business-solutions/rentals/about-wix-rentals-availability.md#resource-schedules).

To cancel a single rental booking:

1. Call [Query Extended Bookings](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-reader-v2/query-extended-bookings.md) to retrieve the booking and verify that its status allows cancellation. Save the booking ID and current `revision`.
1. Call [Cancel Booking](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/cancel-booking.md) with the booking ID and the `revision` from step 1.
1. For rentals paid through Wix eCommerce, issue a refund with the [eCommerce Orders API](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/orders/introduction.md). Learn more about [order billing sample flows](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/order-billing/sample-flows.md).

## Cancel a multi-day rental booking group

Cancel a daily rental on a resource with working hours. Wix stores it as a linked group of bookings, so canceling the group cancels every booking in it.

Canceling a group needs the multi-service booking ID, which Wix returns when you create the group. Store it alongside the reservation in your own records, because `multiServiceBookingInfo` isn't exposed on the bookings you retrieve later.

To cancel a multi-day rental booking group:

1. Retrieve the multi-service booking ID you saved when you created the group.
1. Call [Cancel Multi Service Booking](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/cancel-multi-service-booking.md) with that ID. This cancels every linked booking in the group.
1. For rentals paid through Wix eCommerce, issue a refund with the [eCommerce Orders API](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/orders/orders/introduction.md).

## See also

- [About Wix Rentals](https://dev.wix.com/docs/api-reference/business-solutions/rentals/introduction.md)
- [Wix Rentals and the Bookings APIs](https://dev.wix.com/docs/api-reference/business-solutions/rentals/wix-rentals-and-the-bookings-apis.md)
- [About Wix Rentals Availability](https://dev.wix.com/docs/api-reference/business-solutions/rentals/about-wix-rentals-availability.md)
- [Bookings Writer V2 API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/bookings-writer-v2/introduction.md)
- [Time Slots V2 API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/introduction.md)
- [Attributes API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/attributes/introduction.md)