# Get Service Resources

Retrieve the available service resources based on the selected work type group or work type, and service territory.

A service resource is an employee from your organization, such as a loan officer, investment advisor, doctor, nurse practitioner, or retail store specialist, who attends appointments with clients.

Create a page in your app where you can show the available service resources based on the work type group or work type, and service territory.

1. 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` or `workTypeId`, and `territoryIds` parameters.

   **Resource URI**

   ```nolang
   https://YOUR_INSTANCE.salesforce.com/services/data/vXX.X/scheduling/getAppointmentCandidates
   ```

   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. The preference is enforced when the Include Only Required Service Resources and Ignore Excluded Service Resources policy rules are enabled.

   **Sample Request**

   Using `workTypeGroupId`:

   ```nolang
   {
     "accountId": "001x0000005DLxpAAG",
     "startTime": "2022-04-19T10:30:00.000+0000",
     "endTime": "2022-04-19T10:40:00.000+0000",
     "workTypeGroupId": "0VSx000000014DmGAI",
     "territoryIds": [
       "0Hhx000000012oSCAQ"
     ]
   }
   ```

   Using `workTypeId`:

   ```nolang
   {
      "accountId" : "001x0000005DLxpAAG",
      "startTime" : "2022-04-19T10:30:00.000+0000",
      "endTime" : "2022-04-19T10:40:00.000+0000",
      "workType" : {
                    "id" : "08qx000000014fnAAA"
      },
      "territoryIds" : ["0Hhx000000012oSCAQ"]
   }
   ```

   **Sample Response**

   The API returns the service resources and their available time slots.

   ```nolang
   {
     "candidates": [
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GcCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GfCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GbCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GwCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GyCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GuCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GtCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GsCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GmCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GnCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GlCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H4CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H2CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H3CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       }
     ]
   }
   ```

   **For a Guest User (Lead)**

   **Sample Request**

   Using `workTypeGroupId`:

   ```nolang
   {
     "startTime": "2022-04-19T10:30:00.000+0000",
     "endTime": "2022-04-19T10:40:00.000+0000",
     "workTypeGroupId": "0VSx000000014DmGAI",
     "territoryIds": [
       "0Hhx000000012oSCAQ"
     ]
   }
   ```

   Using `workTypeId`:

   ```nolang
   {
     "startTime": "2022-04-19T10:30:00.000+0000",
     "endTime": "2022-04-19T10:40:00.000+0000",
     "workType": {
       "id": "08qx000000014fnAAA"
     },
     "territoryIds": [
       "0Hhx000000012oSCAQ"
     ]
   }
   ```

   **Sample Response**

   The API returns the service resources and their available time slots.

   ```nolang
   {
     "candidates": [
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GcCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GfCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GbCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GwCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GyCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GuCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GtCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GsCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GmCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GnCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006GlCAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H4CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H2CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       },
       {
         "endTime": "2022-04-19T10:40:00.000+0000",
         "resources": [
           "0Hnx000000006H3CAI"
         ],
         "startTime": "2022-04-19T10:30:00.000+0000",
         "territoryId": "0Hhx000000012oSCAQ"
       }
     ]
   }
   ```

Parse the JSON response, and display the available service resources on web page so that users can select a service resource for the appointment. Here’s how that page can look.

![A representation of the Select Service Resource screen.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/uc9\_select_service_resource.png)

When users select a resource, show the available time slots for the selected resource. Here’s how a page showing the available time slots can look.

![A representation of the Select Service Appointment Time screen.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/uc9\_select_appointment_time.png)

On the next page in your app, you can show the appointment details for the user to review and create the appointment.
