---
schema_version: "1"
id: 7cf65c0d1ff9f3c283d6309451746016f6abe3a68f4907279023fe04fe736953
title: Get Appointment Candidates
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/salesforce-scheduler-dev-guide/guides/salesforce-scheduler/uc3-get-appointment-candidates.md
canonical_url: https://developer.salesforce.com/docs/service/salesforce-scheduler-dev-guide/guide/uc3-get-appointment-candidates.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7c057b473a154ab8fef6a549139453db935b76def01746b0eb20a9cad899b37f
products:
  - Salesforce Scheduler Developer Guide
  - Service Cloud Developer Content
---

# Get Appointment Candidates

A service resource represents an employee from your organization, such as a loan officer, investment advisor, doctor, nurse practitioner, or retail store specialist, who attends appointments with clients. Use the `getAppointmentCandidates` REST API to fetch the available service resources based on work type group and service territory.

1.  Create a page in your app where you can show the available service resources based on the work type group and service territory.

2.  Make a POST request on the [`getAppointmentCandidates`](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/requests_ls_getappointmentcandidates.htm) REST API by passing the required `workTypeGroupId` and `territoryIds` parameters.

    **Resource URI**

    ```nolang
    https://yourInstance.salesforce.com/services/data/vXX.X/scheduling/getAppointmentCandidates
    ```

    **For an Existing User (Account)**

    To consider an existing user’s preferred visiting hours, pass `accountId` in the input request body. The preference is enforced when the Include Only Required Service Resources and Ignore Excluded Service Resources policy rules are enabled. See [Scheduling Policy Rules in Salesforce Scheduler](https://help.salesforce.com/s/articleView?id=platform.ls_scheduling_policies.htm&type=5).

    **Sample Request**

    ```nolang
    {
       "startTime" : "2023-11-01T09:00:00.000+0000",
       "endTime" : "2023-11-25T19:00:00.000+0000",
       "accountId" : "001S7000001pFlJIAU",
       "workTypeGroupId" : "0VSS700000000sVOAQ",
       "territoryIds" : ["0HhS700000001DYKAY"],
       "engagementChannelTypeIds": [
        "0eFS70000004CG5MAM"
      ]
    }
    ```

    **Sample Response**

    The API returns the available time slots and service resources.

    ```nolang
    {
      "candidates": [
        {
          "endTime": "2023-11-24T18:00:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:00:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:15:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:15:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:30:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:30:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:45:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:45:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:00:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:00:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:15:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:15:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:30:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:30:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        }
      ]
    }
    ```

    **For a Guest User (Lead)**

    **Sample Request**

    ```nolang
    {
       "startTime" : "2023-11-01T09:00:00.000+0000",
       "endTime" : "2023-11-25T19:00:00.000+0000",
       "workTypeGroupId" : "0VSS700000000sVOAQ",
       "territoryIds" : ["0HhS700000001DYKAY"],
       "engagementChannelTypeIds": [
        "0eFS70000004CG5MAM"
      ]
    }
    ```

    **Sample Response**

    The API returns the available time slots and service resources.

    ```nolang
    {
      "candidates": [
        {
          "endTime": "2023-11-24T18:00:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:00:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:15:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:15:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:30:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:30:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T18:45:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T17:45:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:00:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:00:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:15:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:15:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        },
        {
          "endTime": "2023-11-24T19:30:00.000+0000",
          "engagementChannelTypeIds": [
            "0eFS70000004CG5MAM"
          ],
          "resources": [
            "0HnS700000002jAKAQ"
          ],
          "startTime": "2023-11-24T18:30:00.000+0000",
          "territoryId": "0HhS700000001DYKAY"
        }
      ]
    }
    ```

3.  Parse the JSON response, and show the available service resources on the page so that the user can select a primary service resource.

    Here’s how a Select Service Resource page can look.

    ![A representation of the Select Service Resource screen.](https://developer.salesforce.com/media/salesforce-scheduler-dev-guide/screen_primary_resource.png)

    Here’s how a page can look when the user selects a primary service resource.

    ![A representation of the Select Service Resource screen with the primary resource selected.](https://developer.salesforce.com/media/salesforce-scheduler-dev-guide/screen_select_primary_resource.png)


On the next page in your app, show the selected primary resource. You can also show the other service resources, including assets, so that users can add them as required resources. Then, show the consolidated time slots for all the selected resources.

