The Resource Types API is an integral part of the Wix Bookings app, designed to manage and interact with resource types, such as room, equipment or vehicle. Defining resource types enables consistent classification of resources and is essential for making them bookable and avoiding double bookings.
The Resource Types API provides functionality to manage resource types, including creating, updating, deleting, and querying resource types.
It’s important to note the following points before starting to code:
For a comprehensive glossary of Wix Bookings terms, see Terminology
This article presents possible use cases that your app could support, along with sample flows to implement each use case. These examples can serve as a helpful starting point as you plan your app's functionality.
This use case demonstrates the process of creating a custom resource type with bookable resources such that their availability will be automatically managed by the Bookings app.
To create a custom resource type with bookable resources:
Use Create Resource Type to create a resource type by providing a descriptive name. Save the resource type ID.
Use Create Resource or Bulk Create Resources to create individual resources. Be sure to include the ID of the created resource type to make each resource bookable.
Use Query Services to retrieve the IDs of the services that require a resource of this type to booked.
Use Update Service to connect the resource type for each service providing the ID of the service and the ID of the resource type.
This article outlines error messages that might be issued when calling endpoints of the Resource Types API.
The Create Resource Type might issue the following error messages:
HTTP status | Error code | Error message | Troubleshooting |
---|---|---|---|
ALREADY_EXISTS (400) | RESOURCE_TYPE_ALREADY_EXISTS_FOR_NAME | ResourceType with name <name> already exists. | Make sure that the name of the resource type is unique within the site you are creating it. |
RESOURCE_EXHAUSTED (429) | MAX_NUMBER_OF_RESOURCE_TYPES_REACHED | The maximum number of <limit> resource types has been reached. | Delete unused resource types or upgrade your premium subscription. |
The Update Resource Type endpoint might issue the following error messages:
HTTP status | Error code | Error message | Troubleshooting |
---|---|---|---|
ALREADY_EXISTS (400) | RESOURCE_TYPE_ALREADY_EXISTS_FOR_NAME | ResourceType with name <name> already exists. | Make sure that the name of the resource type is unique within the site you are creating it. |
Query endpoints allow you to filter and sort results based on resource type properties. This article covers field support for filtering and sorting.
Specify the filter
object in the following format:
{
"filter": {
"fieldName": {
"$eq": "value"
}
}
}
The following table shows field support for filters and sorting for the Resource Type object:
Field | Supported Filters | Sortable |
---|---|---|
id | $eq , $ne , $exists , $in , $nin , $startsWith | Sortable |
name | $eq , $ne , $exists , $in , $nin , $startsWith , $isEmpty | Sortable |
Results 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:
{
"sort": [
{
"fieldName": "name",
"order": "DESC"
}
]
}
Related content:
A resource type is a classification of resources, e.g. room, equipment or vehicle.
Resource type ID.
Revision number, which increments by 1 each time the resource type is updated. To prevent conflicting changes, the current revision must be passed when updating the resource type.
Represents the time in YYYY-MM-DDThh:mm:ss.sssZ
format this resource type was created.
Represents the time in YYYY-MM-DDThh:mm:ss.sssZ
format this resource type was last updated.
The name of this resource type, for example meeting room
. The name must be unique per site.
Extensions enabling users to save custom data related to the resource type.
{
"resourceType": {
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "1",
"createdDate": "2024-11-14T13:32:36.462Z",
"updatedDate": "2024-11-14T13:32:36.462Z",
"name": "Meeting room"
}
}
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 type.
You can only call this method when authenticated as a Wix app or Wix user identity.
Resource type to be created.
The created resource type.
curl -X POST \
'https://www.wixapis.com/bookings/v2/resources/resource-types' \
-H 'Authorization: <AUTH>' \
-d '{
"resourceType": {
"name": "Meeting room"
}
}'
{
"resourceType": {
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "1",
"createdDate": "2024-11-14T13:32:36.462Z",
"updatedDate": "2024-11-14T13:32:36.462Z",
"name": "Meeting room"
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a resource type by ID.
ID of the resource type to retrieve.
The requested resource type.
curl -X GET \
'https://www.wixapis.com/bookings/v2/resources/resource-types/28221941-9d0d-4c91-806b-e2a08073d37a' \
-H 'Authorization: <AUTH>'
{
"resourceType": {
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "2",
"createdDate": "2024-11-14T13:32:36.462Z",
"updatedDate": "2024-11-14T13:39:20.409Z",
"name": "Meeting room with conference system"
}
}
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 type.
Deleting a resource type will automatically delete all resources of this type.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the resource type to delete.
curl -X DELETE \
'https://www.wixapis.com/bookings/v2/resources/resource-types/28221941-9d0d-4c91-806b-e2a08073d37a' \
-H 'Authorization: <AUTH>'
{}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a resource type.
Each time the resource type is updated, revision
increments by 1. You must include current revision of the resource type when updating it.
This ensures you're working with the latest service information and prevents unintended overwrites.
You can only call this method when authenticated as a Wix app or Wix user identity.
Resource type ID.
Resource type to update.
Updated resource type.
To update a resource type the fields id
and revision
are required. Partial updates are supported.
curl -X PATCH \
'https://www.wixapis.com/bookings/v2/resources/resource-types/28221941-9d0d-4c91-806b-e2a08073d37a' \
-H 'Authorization: <AUTH>' \
-d '{
"resourceType": {
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "1",
"name": "Meeting room with conference system"
}
}'
{
"resourceType": {
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "2",
"createdDate": "2024-11-14T13:32:36.462Z",
"updatedDate": "2024-11-14T13:39:20.409Z",
"name": "Meeting room with conference system"
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Queries resource types, given the provided paging, filtering, and sorting.
Up to 100 resource types can be returned per request. For field support for filters, see Resource types: Filtering and Sorting. To learn how to query resource types, see API Query Language.
WQL expression.
The retrieved resource types.
Paging metadata, including offset and count.
Query resource types, providing a limit to the number of results returned.
curl -X POST \
'https://www.wixapis.com/bookings/v2/resources/resource-types/query' \
-H 'Authorization: <AUTH>' \
-d '{
"query": {
"cursorPaging": {
"cursor": null,
"limit": 10
}
}
}'
{
"resourceTypes": [
{
"id": "28221941-9d0d-4c91-806b-e2a08073d37a",
"revision": "2",
"createdDate": "2024-11-14T13:32:36.462Z",
"updatedDate": "2024-11-14T13:39:20.409Z",
"name": "Meeting room with conference system"
},
{
"id": "51dde79f-0ce3-420e-b5dc-bb3f98533ae9",
"revision": "1",
"createdDate": "2024-11-14T13:46:58.237Z",
"updatedDate": "2024-11-14T13:46:58.237Z",
"name": "Beamer"
}
],
"pagingMetadata": {
"count": 2,
"cursors": {},
"hasNext": false
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Counts resource types according to given criteria.
For field support for filters, see Resource types: Filtering and Sorting. Use WQL filter to define the criteria.
Filter to apply on resource types to count.
The number of resource types matching the given filter.
curl -X POST \
'https://www.wixapis.com/bookings/v2/resources/resource-types/count' \
-H 'Authorization: <AUTH>' \
-d '{}'
{
"count": 2
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a resource type is created.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.bookings.resources.v2.resource_type
.
Event name. Expected created
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.bookings.resources.v2.resource_type_created",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"id": "14754b5a-7905-4b29-bff3-dd1c7a3071c0",
"entityFqdn": "wix.bookings.resources.v2.resource_type",
"slug": "created",
"entityId": "32883beb-d747-4e61-8a74-1f1f43a7d11d",
"createdEvent": {
"entity": {
"id": "32883beb-d747-4e61-8a74-1f1f43a7d11d",
"revision": "1",
"createdDate": "2024-11-27T16:15:05.563Z",
"updatedDate": "2024-11-27T16:15:05.563Z",
"name": "Laptop"
}
},
"eventTime": "2024-11-27T16:15:05.586954667Z",
"triggeredByAnonymizeRequest": false,
"entityEventSequence": "1"
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a resource type is deleted.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.bookings.resources.v2.resource_type
.
Event name. Expected deleted
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.bookings.resources.v2.resource_type_deleted",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"id": "eb94c557-9599-482c-8b2c-bb1ebca6e140",
"entityFqdn": "wix.bookings.resources.v2.resource_type",
"slug": "deleted",
"entityId": "32883beb-d747-4e61-8a74-1f1f43a7d11d",
"deletedEvent": {
"movedToTrash": true
},
"eventTime": "2024-11-27T16:21:39.268557862Z",
"triggeredByAnonymizeRequest": false,
"entityEventSequence": "12"
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a resource type is updated.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.bookings.resources.v2.resource_type
.
Event name. Expected updated
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.bookings.resources.v2.resource_type_updated",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"id": "a5277ada-60d9-4538-8495-6b955a94df2d",
"entityFqdn": "wix.bookings.resources.v2.resource_type",
"slug": "updated",
"entityId": "32883beb-d747-4e61-8a74-1f1f43a7d11d",
"updatedEvent": {
"currentEntity": {
"id": "32883beb-d747-4e61-8a74-1f1f43a7d11d",
"revision": "2",
"createdDate": "2024-11-27T16:15:05.563Z",
"updatedDate": "2024-11-27T16:18:50.149Z",
"name": "Laptop Windows",
"appId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97"
}
},
"eventTime": "2024-11-27T16:18:50.185050444Z",
"triggeredByAnonymizeRequest": false,
"entityEventSequence": "2"
}