Resources API: Sample Use Cases and Flows

This article presents a possible use case that you could support, along with a sample flow to implement it. This examples can serve as a helpful starting point as you plan your implementation.

Create a bookable resource

You could create a resource that's bookable only at a specific location.

To create a bookable resource:

  1. Call Query Resource Types (SDK | REST) and save the ID of the relevant resource type.
  2. Call Query Locations (SDK | REST) to retrieve the ID of the business location.
  3. Call Create Resource (SDK | REST) to create the resource. Specify a name, the ID of the resource type and the ID of the business location.
  4. Call Query Services (SDK | REST) Confirm that the resource type is associated with relevant services by making sure that serviceResources.resourceType is set to the correct resource Type ID.
  5. Optional: For every service that doesn't specify the correct resourceType, call Update Service (SDK | REST). Specify the correct resource Type ID in serviceResources.resourceType.
Did this help?

Resources: Filtering and Sorting

This article covers field support for filtering in Query Resources (SDK | REST), Search Resources (SDK | REST), and Count Resources (SDK | REST).

Filtering

Specify the filter object in the following format:

Copy

The following table shows field support for filters and sorting for the resource object:

FieldSupported FiltersSortable
id$eq, $ne, $exists, $in, $nin, $startsWithSortable
name$eq, $ne, $exists, $in, $nin, $isEmpty
typeId$eq, $ne, $exists, $in, $nin, $startsWith, $isEmptySortable
locationOptions.availableInAllLocations$eq, $ne, $exists, $in, $ninSortable
locationOptions.specificLocationOptions.availableInBusinessLocations$eq, $ne, $exists, $in, $ninSortable
locationOptions.specificLocationOptions.businessLocations.locationId$eq, $ne, $isEmpty, $hasAll, $hasSomeSortable
eventsSchedule.scheduleId$eq, $ne, $exists, $in, $nin, $startsWithSortable

Sorting

Results in Query Resources (SDK | REST) and Search Resources (SDK | REST) are sorted by the id field in ascending order by default.

To sort by a different field, use the sort object in the following format:

Copy

See also

Did this help?

bulkCreateResources( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates up to 50 resources.

Refer to Create Resource (SDK | REST) for more details.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Bookings - all permissions
Manage Bookings
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
resourcesArray<Resource>Required

Resources to create.


optionsBulkCreateResourcesOptions
Returns
Return Type:Promise<BulkCreateResourcesResponse>
JavaScript
Errors
400Invalid Argument

There are 5 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?

bulkDeleteResources( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes multiple resources.

Refer to Delete Resource (SDK | REST) for more details.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Bookings - all permissions
Manage Bookings
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
idsArray<string>Required

IDs of the resources to delete.

Returns
Return Type:Promise<BulkDeleteResourcesResponse>
JavaScript
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

countResources( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Counts resources according to given criteria.

Refer to the supported filters article (SDK | REST) for a complete list of supported filters and sorting options.

Permissions
Manage Bookings - all permissions
Read Bookings - all read permissions
Manage Bookings
Read Bookings - Public Data
Read Bookings - Including Participants
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
optionsCountResourcesOptions

Filter to base the count on. See the supported filters article (SDK | REST) for a complete list of filtering options.

Returns
Return Type:Promise<CountResourcesResponse>
JavaScript
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

createResource( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a new resource.

Connected schedules

A new event schedule (SDK | REST) is automatically created for the resource.

Locations

If you don't specify locationOptions, Wix Bookings automatically sets locationOptions.availableInAllLocations to true.

If you specify 1 business location ID in locationOptions.specificLocationOptions.businessLocations, you must specify locationOptions.specificLocationOptions.availableInBusinessLocations as true. Currently, you can specify only a single business location.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Bookings - all permissions
Manage Bookings
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
resourceResourceRequired

Resource to create.

Returns
Return Type:Promise<Resource>
JavaScript
Errors
400Invalid Argument

There are 4 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?