sortStaffMembers( )


Important:


Sorts staff members using custom business logic for assigning resources to a booking.

Wix calls this method in real time when multiple staff members are available and Wix needs to assign a staff member:

  • During booking creation: When a customer completes a booking and multiple staff members are available for the selected time slot.
  • During booking modifications: When an existing booking is modified (time change, service change) and staff reassignment is needed.
  • During availability checks: In some cases, when displaying available time slots to customers, to optimize the staff assignment preview.

Your implementation must return the resources in your preferred assignment order. Wix assigns the first resource to the booking and uses subsequent resources as fallbacks if the primary choice becomes unavailable before creating the booking.

Response validation

Your response must contain the exact same resource IDs provided in the request, in your preferred order. Don't add, remove, or duplicate resources. If the response is invalid, Wix falls back to random staff assignment.

Performance requirements

Your implementation must respond in under 5 seconds or Wix times out and falls back to random staff assignment. For optimal user experience, we recommend responding in under 500 milliseconds. You can use caching strategies and avoid synchronous external API calls during sorting.

Method Declaration
Copy
Method Parameters
payloadSortStaffMembersEnvelope
Returns
Return Type:SortStaffMembersResponse | Promise<SortStaffMembersResponse>
Errors
SortingWixErrorclass
Did this help?