> 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 # ListBookingPolicies # Package: policies # Namespace: BookingPolicyProvider # Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-service-plugin/list-booking-policies.md ## Introduction Retrieves booking policies for the specified services. Wix calls this method when a customer views available booking times or books a service. For example: - When a customer loads the Bookings calendar to select a time slot, [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) calls this method. - When a customer books a service, [Get Availability Time Slot](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/get-availability-time-slot.md) calls this method. Wix uses the returned policies to calculate the `bookingPolicyViolations` property, considering: - Limits on how early or late a customer can book. - Whether online bookings are allowed. Your implementation must return a policy for each service in the request, in the same order. All fields in the response must be returned unless explicitly marked as optional. --- ## REST API ### Schema ``` Method: listBookingPolicies Description: Retrieves booking policies for the specified services. Wix calls this method when a customer views available booking times or books a service. For example: - When a customer loads the Bookings calendar to select a time slot, [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) calls this method. - When a customer books a service, [Get Availability Time Slot](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/get-availability-time-slot.md) calls this method. Wix uses the returned policies to calculate the `bookingPolicyViolations` property, considering: - Limits on how early or late a customer can book. - Whether online bookings are allowed. Your implementation must return a policy for each service in the request, in the same order. All fields in the response must be returned unless explicitly marked as optional. URL: https://www.wixapis.com/v2/list-booking-policies Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: serviceIds Method parameters: param name: serviceIds | type: array | description: IDs of services to retrieve booking policies for. | required: true Return type: ListBookingPoliciesResponse - name: bookingPolicies | type: array | description: Booking policies for the requested services. - name: serviceId | type: string | description: Service GUID. - name: limitEarlyBooking | type: LimitEarlyBooking | description: Policy for limiting early bookings. - name: enabled | type: boolean | description: Whether there's a limit on how early a customer can book. If `false`, customers can book as far in advance as they want. Default: `false` - name: earliestBookingInMinutes | type: integer | description: Maximum number of minutes before the slot start time that a booking can be made. Must be greater than `latestBookingInMinutes`. Default: `10080` (7 days) - name: limitLateBooking | type: LimitLateBooking | description: Policy for limiting late bookings. - name: enabled | type: boolean | description: Whether there's a limit on how late a customer can book. If `false`, customers can book up to the last minute. Default: `false` - name: latestBookingInMinutes | type: integer | description: Minimum number of minutes before the slot start time that a booking can be made. Must be less than `earliestBookingInMinutes`. Default: `1440` (1 day) - name: onlineBooking | type: OnlineBooking | description: Policy for allowing online bookings. - name: enabled | type: boolean | description: Whether the service can be booked online. Default: `true` - name: intakeFormPolicy | type: IntakeFormPolicy | description: Rules for Intake Form integration - name: formId | type: string | description: GUID of the form used as an intake form for the service. - name: requireBeforeBook | type: boolean | description: Whether the intake form must be completed before booking. If `false`, the form is handled after booking. Default: `false` ``` ### Examples ### List the booking policies - decoded JWT The data payload will include the following object as an encoded JWT. For the purposes of this example, we show the request and response objects decoded. ```curl curl -X POST \ 'https://provider.example.com/v2/list-booking-policies' \ -H 'user-agent: Wix' \ -H 'accept-encoding: gzip, deflate' \ -H 'content-type: text/plain; charset=utf-8' \ -d '{ "data": { "request": { "serviceIds": [ "9bf5cd2d-32fa-4ee7-952c-5e4b6de14714" ] }, "metadata": { "requestId": "1674480822.92546993606315181", "identity": { "identityType": "ANONYMOUS_VISITOR", "anonymousVisitorId": "c7808c1d-e6a5-49e5-bcbe-b3fcf2f72d28" }, "instanceId": "bb2b1658-9855-4598-b1e0-48e8cdb7f98a" } }, "aud": "3467d501-9004-498d-9b5c-d50f6d4ede66", "iss": "wix.com", "iat": 1674480823, "exp": 1678080823 }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.policies.BookingPolicyProvider.listBookingPolicies(request, metadata) Description: Retrieves booking policies for the specified services. Wix calls this method when a customer views available booking times or books a service. For example: - When a customer loads the Bookings calendar to select a time slot, [List Availability Time Slots](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md) calls this method. - When a customer books a service, [Get Availability Time Slot](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/get-availability-time-slot.md) calls this method. Wix uses the returned policies to calculate the `bookingPolicyViolations` property, considering: - Limits on how early or late a customer can book. - Whether online bookings are allowed. Your implementation must return a policy for each service in the request, in the same order. All fields in the response must be returned unless explicitly marked as optional. Method parameters: param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature. Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ``` - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs. - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: languages | type: array | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. - name: instanceId | type: string | description: The service provider app's instance GUID. param name: request | type: ListBookingPoliciesRequest - name: serviceIds | type: array | description: IDs of services to retrieve booking policies for. Return type: PROMISE - name: bookingPolicies | type: array | description: Booking policies for the requested services. - name: serviceId | type: string | description: Service GUID. - name: limitEarlyBooking | type: LimitEarlyBooking | description: Policy for limiting early bookings. - name: enabled | type: boolean | description: Whether there's a limit on how early a customer can book. If `false`, customers can book as far in advance as they want. Default: `false` - name: earliestBookingInMinutes | type: integer | description: Maximum number of minutes before the slot start time that a booking can be made. Must be greater than `latestBookingInMinutes`. Default: `10080` (7 days) - name: limitLateBooking | type: LimitLateBooking | description: Policy for limiting late bookings. - name: enabled | type: boolean | description: Whether there's a limit on how late a customer can book. If `false`, customers can book up to the last minute. Default: `false` - name: latestBookingInMinutes | type: integer | description: Minimum number of minutes before the slot start time that a booking can be made. Must be less than `earliestBookingInMinutes`. Default: `1440` (1 day) - name: onlineBooking | type: OnlineBooking | description: Policy for allowing online bookings. - name: enabled | type: boolean | description: Whether the service can be booked online. Default: `true` - name: intakeFormPolicy | type: IntakeFormPolicy | description: Rules for Intake Form integration - name: formId | type: string | description: GUID of the form used as an intake form for the service. - name: requireBeforeBook | type: boolean | description: Whether the intake form must be completed before booking. If `false`, the form is handled after booking. Default: `false` ``` ### Examples ### listBookingPolicies ```javascript import { bookingPolicy } from '@wix/bookings/service-plugins'; async function listBookingPolicies(request,metadata) { const response = await bookingPolicy.listBookingPolicies(request,metadata); }; ``` ### listBookingPolicies (with elevated permissions) ```javascript import { bookingPolicy } from '@wix/bookings/service-plugins'; import { auth } from '@wix/essentials'; async function myListBookingPoliciesMethod(request,metadata) { const elevatedListBookingPolicies = auth.elevate(bookingPolicy.listBookingPolicies); const response = await elevatedListBookingPolicies(request,metadata); } ``` ### listBookingPolicies (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { bookingPolicy } from '@wix/bookings/service-plugins'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { bookingPolicy }, // Include the auth strategy and host as relevant }); async function listBookingPolicies(request,metadata) { const response = await myWixClient.bookingPolicy.listBookingPolicies(request,metadata); }; ``` ---