Introduction
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.
The Bookings Resources API provides functionality for creating and managing resources.
A resource is a business asset like a staff member, or equipment needed to provide a service. Each resource owns a schedule. The schedule defines the resource's availability using the business's default working hours. Resources have tags that you can use for grouping. For example, add a "room"
tag for classroom resources, and an "equipment"
tag for resources like computers and projectors.
With the Resources API, you can:
Before you begin
It's important to note the following points before starting to code:
- There are 2 tags that are used by the Wix Bookings app:
"staff"
: Resources with the"staff"
tag appear in the Bookings app's Staff page."business"
: The Bookings app creates a resource with a name and tag value of"business"
. This resource owns a schedule that contains the operating hours of the business and cannot be deleted. This schedule is used when creating resources that use the business’s operating hours for the resource's working hours.
- You can have up to 135 active resources and an additional 135 deleted resources.
- A resource can have one schedule only.
- When updating a resource's schedule you cannot change the system tags used by the Wix Bookings app. Tags used by the app have the values
"INDIVIDUAL"
,"GROUP"
, and"COURSE"
.
Terminology
- Resource: Business asset like a staff member, room, or equipment that's needed to provide a service.
- Schedule: Collection of all sessions that belong to the same class, course, appointment, or resource.
Setup
To use the Resources API, install the @wix/bookings
package using npm or Yarn:
1npm install @wix/bookings
or
1yarn add @wix/bookings
Then import { resources }
from @wix/bookings
:
1import { resources } from '@wix/bookings'
Creates a resource.
The createResource()
function returns a Promise that resolves to the created resource.
Bookings resources are created with a schedule. The schedule determines the resource's availability by the business's default working hours.
When creating a resource using createResource()
, get the business resource's schedule ID and include it in the schedules
object. The default hours can bee found in the Dashboard under Settings in the Bookings section, on the Appointment hours page.
Notes:
- The Wix Bookings app shows default business hours on the Staff page in the dashboard.
- A resource can have one schedule only.
- You can have up to 135 active resources and an additional 135 deleted resources.
Permission Scopes
For app development, you must have one of the following permission scopes:function createResource(resource: Resource, options: CreateResourceOptions): Promise<Resource>
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Deletes a resource.
The deleteResource()
function returns a Promise that is resolved when a resource is deleted.
Deleting a resource updates its status to DELETED
.
You cannot delete a resource if it has booked sessions.
Notes:
- The Bookings app automatically creates a resource with a name and tag of value
"business"
. This resource is used for the business's schedule and working hours and cannot be deleted. - You can have up to 135 active resources and an additional 135 deleted resources.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteResource(_id: string): Promise<DeleteResourceResponse>
Updates a resource.
The updateResource()
function returns a Promise that resolves when a resource is updated. Use this function to update all bookings resource information except for the resource's schedule. To update a resource's schedule use updateSchedule()
.
Note:
When updating a resource you cannot change the system tags used by the Wix Bookings app. Tags used by the app have the values "business"
and "staff"
.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateResource(_id: string, resource: UpdateResource): Promise<Resource>
Updates a resource's schedule.
The updateSchedule()
function returns a Promise that resolves when a resource's schedule has been updated. Use this function to update the bookings resource's schedule. To update other resource details use updateResource()
.
Notes:
- A resource can have one schedule only.
- When updating a resource's schedule you cannot change the system tags used by the Wix Bookings app. Tags used by the app have the values
"INDIVIDUAL"
,"GROUP"
, and"COURSE"
.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateSchedule(resourceId: string, schedule: Schedule): Promise<UpdateScheduleResponse>