Search...
createResource( )
Developer Preview
Creates a resource.
Description
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.
This function is not a universal function and runs only on the backend.
Syntax
function createResource(resource: wix-bookings-v1.Resources.Resource, options: wix-bookings-v1.Resources.CreateResourceOptions): Promise<wix-bookings-v1.Resources.CreateResourceResponse>
createResource Parameters
NAME
TYPE
DESCRIPTION
resource
Resource
Resource to create.
options
Optional
CreateResourceOptions
Options for assigning a schedule to a resource.
Returns
Return Type:
Promise<
CreateResourceResponse
>Was this helpful?
createResource example
Copy Code
1import { resources } from 'wix-bookings.v1';23 async function createResource(resource, options) {4 try {5 const result = await resources.createResource(resource, options);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13