Using the Calendar APIs, you can programmatically block time slots in your staff's Bookings calendars. This tutorial demonstrates how to build an interface that allows Wix users to efficiently manage staff availability by creating blocked time sessions for individual staff members or resources. This functionality is useful for scenarios such as staff vacation and time off, equipment maintenance, or training sessions.
By the end of this tutorial, you'll have a resource availability management interface that allows Wix users to:
Caution: The interface created in this tutorial should only be accessible in a protected area, not exposed to regular site visitors. Consider implementing this functionality in a dashboard page or on a members-only page with appropriate permissions.
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 doing this tutorial:
This step creates an interface for Wix users to set up blocked time events.
At the end of this step, you'll have a functional page with all the necessary input elements for blocking time slots, including options for recurring patterns. The interface should look like this:

To create the interface:
Add the following elements to your page:
resourcesDropdown.startDate.startTime.endDate.endTime.recurrenceCheckbox.recurrenceContainer.untilDate.untilTime.intervalDropdown.button.Place untilDate, untilTime, and intervalDropdown inside recurrenceContainer.
In the Properties & Events panel, set recurrenceContainer to Collapsed by default.
Select intervalDropdown, and then select Manage Choices to populate the dropdown with options.
Each option represents a number of weeks to set as the interval between recurring events.
The panel should look like this:

This step creates a backend code file with methods that call Wix APIs.
At the end of this step, you'll have 2 backend methods:
To add backend code:
Create a new backend file called blockedOffTime.web.js in your backend folder.
Add the required imports:
queryResources(), and returns a mapping of the resource into objects with the following fields:
label: The name of the resource, to display as a dropdown option.value: A resource ID, to provide as a value for the dropdown option.event object. The method defines an elevated call to the Calendar API's createEvent() method, and makes the call with the specified event object.Note: Elevated permissions are unnecessary if the implementation is in a dashboard page.
This step ties everything together. We use page code to define the behavior of some page elements and call our backend methods.
At the end of this step, you'll have page code that:
resourcesDropdown with options using our backend method.recurrenceContainer based on recurrenceCheckbox.createBlockedOffTimeEvent when the button is pressed.To add the following code to your page:
onClick event handler for the button and an onChange event handler for the checkbox. The next steps define these methods.getResourceList() from the backend and populates resourcesDropdown with the response.recurrenceContainer when recurrenceCheckbox becomes checked or unchecked.localDate fields: YYYY-MM-DDTHH:mm:ss. The 'en-CA' locale provides the correct format for the date.event object.recurrenceCheckbox is checked, add recurrence data to the event object. The 'en-CA' locale and { weekday: 'long' } provide the chosen date's weekday in English.createBlockedOffTimeEvent() method from the backend, specifying the constructed event object.You've successfully created an interface that allows Wix users to block off time slots in staff calendars, including support for both single time blocks and recurring patterns.