# Get Appointment Candidates

Get a list of service resources based on the work type group or work type, and service territory that are selected in the previous step. 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.

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.

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://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.

**Sample Request**

Using `workTypeGroupId`:

```nolang

{
   "accountId" : "001B000001McLhMIAV",
   "startTime" : "2021-10-29T08:00:00.000+0000",
   "endTime" : "2021-10-29T18:00:00.000+0000",
   "allowConcurrentScheduling" : true,
   "workTypeGroupId" : "0VSB0000000TbhWOAS",
   "territoryIds" : ["0HhB00000001P0PKAU"]
}
```

Using `workTypeId`:

```nolang

{
   "accountId" : "001B000001McLhMIAV",
   "startTime" : "2021-10-29T08:00:00.000+0000",
   "endTime" : "2021-10-29T18:00:00.000+0000",
   "allowConcurrentScheduling" : true,
   "workType" : {
                 "id" : "08qB00000002ocgIAA"
   },
   "territoryIds" : ["0HhB00000001P0PKAU"]
}
```

**Sample Response**

The API returns the available time slots and service resources.

```nolang

{
  "candidates" : [ {
    "endTime" : "2021-10-29T16:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T15:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:30:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T15:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T16:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:30:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T16:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T18:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T17:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T15:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:30:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T15:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T16:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:30:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T16:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T18:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T17:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  } ]
}
```

**For a Guest User (Lead)**

**Sample Request**

Using `workTypeGroupId`:

```nolang

{
   "startTime" : "2021-10-13T08:00:00.000+0000",
   "endTime" : "2021-10-13T18:00:00.000+0000",
   "allowConcurrentScheduling" : true,
   "workTypeGroupId" : "0VSB0000000TbhWOAS",
   "territoryIds" : ["0HhB00000001P0PKAU"],
}
```

Using `workTypeId`:

```nolang

{
   "accountId" : "001B000001McLhMIAV",
   "startTime" : "2021-10-29T08:00:00.000+0000",
   "endTime" : "2021-10-29T18:00:00.000+0000",
   "allowConcurrentScheduling" : true,
   "workType" : {
                 "id" : "08qB00000002ocgIAA"
   },
   "territoryIds" : ["0HhB00000001P0PKAU"]
}
```

**Sample Response**

The API returns the available time slots and service resources.

```nolang
{
  "candidates" : [ {
    "endTime" : "2021-10-29T16:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T15:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:30:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T15:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T16:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:30:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T16:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T18:00:00.000+0000",
    "resources" : [ "0HnB00000001SJxKAM" ],
    "startTime" : "2021-10-29T17:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T15:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T16:30:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T15:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T16:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T17:30:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T16:30:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  }, {
    "endTime" : "2021-10-29T18:00:00.000+0000",
    "resources" : [ "0HnB00000001SOUKA2" ],
    "startTime" : "2021-10-29T17:00:00.000+0000",
    "territoryId" : "0HhB00000001P0PKAU"
  } ]
}
```

Parse the JSON response, and show the available resources on the page so that the user can select a resource for the appointment.

Here’s how a page showing the available service resources can look.

![A representation of the Select Service Resource screen.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/concurrent-serviceResource.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/concurrent_timeSlot.png)

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