Newer Version Available
Get Appointment Slots
Returns a list of available appointment time slots for a resource based on given work
type group and territories.
Syntax
- URI
- /services/data/vXX.X/scheduling/getAppointmentSlots
- Available since release
- 45.0
- Formats
- JSON, XML
- HTTP methods
- POST
- Authentication
- Authorization: Bearer token
- Request body
-
Parameter Required Type Description accountId No String The ID of the associated account. allowConcurrentScheduling No Boolean If true, allows scheduling of concurrent appointments in a time slot. If false, concurrent appointments aren’t allowed. The default is false. Available in API version 47.0 and later.
correlationId No String The ID to pass custom information to the ServiceResourceScheduleHandler Apex interface. For example, you can use the correlation ID to identify the app, website, or any other external system that calls this Apex interface implementation. If you don’t pass a custom value, a randomly generated identifier is passed. Available in API version 53.0 and later.
endTime No String The latest time that a time slot can end (inclusive). primaryResourceId No String The ID of the primary resource in multi-resource scheduling. Available in API version 48.0 and later. requiredResourceIds Yes String[] List of resource IDs that must be available during the time slot. schedulingPolicyId No String The ID of the AppointmentSchedulingPolicy object. If no scheduling policy is passed in the request body, the default configurations are used. The only scheduling policy configuration that is used in determining time slots is the enforcement of account visiting hours. startTime No String The earliest time that a time slot can begin (inclusive). Defaults to the current time of the request, if empty. territoryIds Yes String[] List of IDs of service territories, where the work that is being requested is performed. workType Required if workTypeGroupId isn’t given. Work Type The type of the work to be performed. workTypeGroupId Required if workType isn’t given. String The ID of the work type group containing the work types that are being performed. - Response Body
- Execution of a successful request returns the response body containing a list of available time slots.
-
Parameter Required Type Description timeSlots Yes Time Slots[] List of time slots included in each territory.
Examples
- Request Body Example
- Using workTypeGroupId:
1{ 2 "startTime" : "2019-01-23T00:00:00.000Z", 3 "endTime" : "2019-02-30T00:00:00.000Z", 4 "workTypeGroupId" : "0VSB0000000KyjBOAS", 5 "accountId" : "001B000000qAUAWIA4", 6 "territoryIds" : ["0HhB0000000TO9WKAW"], 7 "schedulingPolicyId" : "0VrB0000000KyjB", 8 "requiredResourceIds" : ["0HnB0000000TO8gKAK"] 9} - Using workType:
1{ 2"startTime" : "2019-01-23T00:00:00.000Z", 3"endTime" : "2019-02-30T00:00:00.000Z", 4"workType" : { 5 "id" : "08qRM00000003fkYAA" 6 }, 7"requiredResourceIds" : ["0HnB0000000TO8gKAK"], 8"territoryIds" : ["0HhRM00000003OZ0AY"] 9"accountId" : "001B000000qAUAWIA4", 10"schedulingPolicyId" : "0VrB0000000KyjB" 11} - Using durationInMinutes and without workTypeGroupId or workType
id
fields:
1{ 2"workType" : { 3 "durationInMinutes" : 60 4 }, 5"territoryIds" : ["0HhRM00000003OZ0AY"], 6"requiredResourceIds" : ["0HnB0000000TO8gKAK"] 7} - Response Body Example
-
1{ 2"timeSlots" : 3[ 4 { 5 "endTime" : "2019-01-21T19:15:00.000+0000", 6 "startTime" : "2019-01-21T16:15:00.000+0000", 7 "territoryId" : "0HhB0000000TO9WKAW" 8 }, { 9 "endTime" : "2019-01-21T19:30:00.000+0000", 10 "startTime" : "2019-01-21T16:30:00.000+0000", 11 "territoryId" : "0HhB0000000TO9WKAW" 12 }, { 13 "endTime" : "2019-01-21T19:45:00.000+0000", 14 "startTime" : "2019-01-21T16:45:00.000+0000", 15 "territoryId" : "0HhB0000000TO9WKAW" 16 } 17] 18}
Prerequisites
The appointment time slots are determined based on your Salesforce Scheduler data model configurations. Here are some prerequisites that you can consider while setting up data.
- Set up Salesforce Scheduler before making your requests. The setup includes creating or configuring Service Resources, Service Territory Members, Work Type Groups, Work Types, Work Type Group Members, and Service Territory Work Types. See Set Up Salesforce Scheduler for more information.
- Configure a work type mapped for each territory in the request body via Service Territory Work Type. Map the same work type to the work type group, via work type group member.
Rules and Guidelines
The following factors affect how time slots are calculated and returned.
- Timezones that differ across operating hours are handled and results are always returned in UTC.
- The resource must be marked as a required resource on the assigned resource object.
- The resource is considered unavailable If the status categories of the resource assigned to service appointments are other than Canceled, Cannot Complete, and Completed.
- Resource Absences of all types are considered unavailable from start to end.
- The following fields of Work Type records, if configured, are used to fine-tune time
slot requirements. For more information, see Create Work Types in Salesforce Scheduler.
Parameter Description Timeframe Start Time slots sooner than current time + Timeframe Start aren’t returned. Timeframe End Time slots later than current time + Timeframe End aren’t returned. Block Time Before Appointment The time period before the appointment is considered as unavailable. Block Time After Appointment The time period after the appointment is considered as unavailable. Operating Hours The overlap of all operating hours from the account, work type, service territory, and service territory member are considered while determining time slots. For more information, see Set Up Operating Hours in Salesforce Scheduler. - Only the time slots within the period of 31 days are returned.
- The earliest and latest appointment slots are calculated using the following guidelines:
- The earliest appointment slot = maximum of
- Service Territory Member Start Date
- current time + Time frame Start
- Start Time passed in the request body
- The latest appointment slot = minimum of
- Service Territory Member End Date
- the earliest appointment slot date + 31 days
- current time + Timeframe End
- The earliest appointment slot = maximum of