Get Appointment Time Slots
A time slot is a period in a day when an appointment can be scheduled. Use the available-territory-slots Connect API to fetch the consolidated availability of each service resource within the selected territory.
-
Create a page in your app where you can show the available time slots based on the work type group and service territory.
-
Make a POST request on the
available-territory-slotsConnect API by passing the requiredworkTypeandterritoryIdsparameters. -
Restrict the number of service resources returned by the request by passing a finite, integer value to the
resourceLimitApptDistributionparameter.When appointment distribution is enabled, Salesforce Scheduler fetches and shows a list of appointment time slots based on the resource utilisation calculation frequency: monthly, parameter-based, or weekly. The Salesforce Scheduler uses the service resources’ utilization score for a specific period to suggest time slots for the least occupied resources. For more information, see How Appointment Distribution Works.
In the custom app, you can hard code most of the parameters, including
territoryIdsandresourceLimitApptDistribution. Set theterritoryIdsparameter to the ID of the new virtual territory that you created in the beginning of this procedure. If the new territory is assigned to multiple work types, you can let your end user select a value forworkType -
Parse the JSON response, and show only the available time slots on the page so that users can select a time slot for their appointment. To ensure privacy, don’t show the service resources.
Here’s how a page showing the available time slots can look.

-
Write custom code to select the least utilized resource or to randomly select a service resource for the appointment based on the time slot that the user selects.
This sample code automatically selects the least utilized resource from the list available for the selected time slot.
This sample code automatically selects a service resource and stores it in
serviceResourceId. Pass the list of service resources available for the selected time slot inresources.
Resource URI
Where YOUR_INSTANCE is a variable.
For an Existing User (Account)
To consider an existing user’s preferred visiting hours, pass accountId in the input request body.
You can also specify the startTime and endTime parameters with the request.
The preference is enforced when the Enforce Account’s Visiting Hours policy rule is enabled.
Sample Request
Sample Response
The API returns the available time slots and service resources based on resource utilization. The response returns only 10 least consumed resources, as specified by the resourceLimitApptDistribution parameter.
Setting a maximum number of resources you want to show for scheduling makes it possible to optimise performance for large territories, such as virtual or tele scenarios.
For a Guest User (Lead)
Sample Request
Sample Response
The API returns the available time slots and service resources based on resource utilization. The response returns only 10 least consumed resources, as specified by the resourceLimitApptDistribution parameter.
Setting a maximum number of resources you want to show for scheduling makes it possible to optimise performance for large territories, such as virtual or tele scenarios.
On the next page, you can show the appointment details for the user to review and create the appointment.