Using the Bookings APIs and Calendar APIs, you can create a backend interface where staff members can block their vacation time. This tutorial shows you how to build a dashboard page where site collaborators select a staff member, choose vacation dates, and block that time in the Bookings calendar. During those periods, the staff member is unavailable for bookings.
To schedule staff vacations, you need to understand how Wix Bookings manages staff members, resources, and calendars.
Wix Bookings automatically creates and manages an associated resource for each staff member. Each resource has an associated schedule, which Wix Bookings uses to manage that resource's availability. The entries on the schedule are events, during which the resource can't be booked.
Therefore, to schedule a staff member's vacation time, you need the full resource object associated with that staff member, which contains the ID of the events schedule associated with that resource. To create the vacation event, you must specify that schedule ID.
Learn more about scheduling and availability in Wix Bookings and how Wix Bookings uses the Calendar APIs.
By the end of this tutorial, you'll have a dashboard page that:
The code in this article was written using the following module versions:
Learn how to install npm packages in the editor or using the CLI.
Use the following steps to build the functionality:
It's important to note the following points before starting to code:
Create backend methods to query staff members and create vacation events on their schedules:
In your site's backend folder, create a new file called staff-management.web.js.
Add the following import statements:
Create a web method to query all staff members. Specify RESOURCE_DETAILS in the optional fields array to retrieve the full resource object. It contains the schedule ID needed to create vacation events:
Create a second backend file called event-management.web.js to manage vacation events.
Add the following import statements to this file:
Create a web method to set up a staff member's vacation. This method receives the staff member details and date range, constructs an event object, and creates a blocked calendar event:
These backend methods allow site members to query staff and create vacation events on their schedules.
This step creates a dashboard page interface that allows site collaborators to select a staff member, choose vacation dates, and create blocked time events.
To build the frontend interface:
Add a dashboard page to your site.
Add the following elements to the dashboard page:
Your dashboard page should look like this:

In your dashboard page's code editor, add the following code to import the backend methods and initialize a variable to store the queried staff members:
Add methods to format dates and set up the details of the vacation event:
Add a method to query staff members and populate the dropdown menu:
Set up the dashboard page interface:
In the page's onReady() method, set up the dashboard page:
When a site collaborator chooses vacation dates and clicks the setup button, the code creates a blocked event in the Bookings Calendar.

Here is the complete tutorial code:
Here are the complete backend files:
Here's the complete dashboard page code: