> 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: Introduction ## Article: Introduction ## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-service-plugin/introduction.md ## Article Content: # About the Booking Policy Service Plugin The Booking Policy service plugin allows you to provide custom booking policies that control when customers can book services. With this service plugin, you can: - Limit how early customers can book a service. - Limit how late customers can book a service. - Control whether online bookings are allowed. Learn more about [service plugin extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md). ## Before you begin It's important to note the following point before starting to code: - Without the service plugin, each service supports only a single static [booking policy](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policies/introduction.md). The service plugin is called dynamically at query time, so your implementation can return different policies for the same service based on custom criteria. ## Use cases - [Limit early bookings](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-service-plugin/sample-flows.md#limit-early-bookings). - [Allow booking up until session start](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-service-plugin/sample-flows.md#allow-booking-up-until-session-start). - [Disable online booking for specific services](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policy-service-plugin/sample-flows.md#disable-online-booking-for-specific-services). ::::tabs :::REST ## Get started To enable Wix to communicate with your app: 1. Go to [Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/about-extensions.md) in your app's dashboard. 1. Click **Create Extension** in the top right. 1. Filter by **Bookings** in the left menu, then find **Booking Policy service plugin** and click **Create**. 1. Provide the following configuration in the JSON editor and then click **Save**. | Name | Type | Description | | --- | --- | --- | | `deploymentUri`|string|**Required.** Base URI where your service plugin endpoints are deployed. For example, to call the List Booking Policies endpoint at `https://my-booking-policy.com/v2/list-booking-policies`, the base URI you provide here is `https://my-booking-policy.com/`. | | `providerName`|string|**Required.** Display name for your provider. | ::: :::SDK ## Get started Follow these steps to begin implementing your service plugin. ### Step 1 | Choose a framework You can implement this service plugin with the following [frameworks](https://dev.wix.com/docs/build-apps/get-started/overview/wix-s-development-frameworks.md): + **Wix CLI:** Learn how to [implement a service plugin with the CLI and the SDK](https://dev.wix.com/docs/wix-cli/legacy-clis/legacy-wix-cli-for-apps/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md). + **Self-hosted:** Learn how to [implement a self-hosted service plugin with the SDK and the Wix Dev Center](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md). ### Step 2 | Configure your service plugin To configure and customize your plugin, you need to provide important information in the service plugin configuration file. You can [configure your plugin in your app's dashboard](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-1--add-a-service-plugin-extension-to-your-app). For details, see [Booking Policy Provider Extension Configuration](https://dev.wix.com/docs/rest/business-solutions/bookings/policies/booking-policy-service-plugin/extension-config.md). ### Step 3 | Define handler functions Use [`bookingPolicy.provideHandlers()`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-4--define-handler-functions) to define the following handler functions that implement your custom business logic. Make sure you define all required functions. | Function | Required | |-----------------------------|----------------| | [`listBookingPolicies()`](https://dev.wix.com/docs/rest/business-solutions/bookings/policies/booking-policy-service-plugin/list-booking-policies.md) | Yes | ## Code examples Below is an example for implementing the Booking Policy service plugin in your code. ### CLI: Basic code structure This is the basic code structure for implementing the Booking Policy service plugin with the Wix CLI: ```js import { bookingPolicy } from '@wix/bookings/service-plugins' bookingPolicy.provideHandlers({ listBookingPolicies: async (payload) => { const {request, metadata} = payload; // Add your logic here } }); ``` ### Self-hosted: Basic code structure This is the basic code structure for implementing a self-hosted Booking Policy service plugin: ```js import { createClient } from '@wix/sdk'; import { bookingPolicy } from '@wix/bookings/service-plugins' const wixClient = createClient({ auth: { appId: , publicKey: }, modules: { bookingPolicy } }); wixClient.bookingPolicy.provideHandlers({ listBookingPolicies: async (payload) => { const { request, metadata } = payload; // Add your logic here } }); // Implement a router to process all requests express.post('/plugins-and-webhooks/*', (req, res) => { wixClient.process(req); }); ``` ::: :::: ## Terminology For a comprehensive glossary of Wix Bookings terms, see [Terminology](https://dev.wix.com/docs/api-reference/business-solutions/bookings/terminology.md). ## See also + [About Service Plugin Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md) + [Add a Service Plugin Extension With the CLI](https://dev.wix.com/docs/wix-cli/legacy-clis/legacy-wix-cli-for-apps/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md) + [Add a Self-hosted Service Plugin With the SDK](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md) + [Add Self-hosted Service Plugin Extensions with REST](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-rest.md) + [Booking Policies API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/policies/booking-policies/introduction.md) + [Availability Time Slots Configuration service plugin](https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/availability-time-slots-configuration-service-plugin/introduction.md) @sdk_package_setup