Newer Version Available

This content describes an older version of this product. View Latest

Service Appointments

Create and update service appointments.
Resource
1/connect/scheduling/service-appointments
Available version
48.0
Requires Chatter
No
HTTP methods
POST, PATCH

PATCH is available in version 51.0 and later.

Request body for POST
JSON example
1{
2  "serviceAppointment": {
3    "parentRecordId": "0012w000004oZXgAAM",
4    "workTypeId": "08q2w000000XmniAAC",
5    "serviceTerritoryId": "0Hh2w000000XmoXCAS",
6    "schedStartTime": "2020-02-26T15:00:00.000Z",
7    "schedEndTime": "2020-02-26T16:00:00.000Z",
8    "street": "1 Market Street",
9    "city": "San Francisco",
10    "state": "CA",
11    "postalCode": "94105",
12    "country": "USA",
13    "appointmentType": "In Person",
14    "extendedFields": [
15 {
16                "name": "Email",
17                "value": "rachel.adams@salesforce.com"
18            },
19            {
20                "name": "Phone",
21                "value": "111111111"
22            },
23            {
24                "name": "Description",
25                "value": "Test Description"
26 }
27]
28  },
29  "assignedResources": [
30    {
31      "serviceResourceId": "0Hn2w000000gDWDCA2",
32      "isRequiredResource": true,
33      "isPrimaryResource": true,
34      "extendedFields": []
35    },
36    {
37      "serviceResourceId": "0Hn2w000000gCqnCAE",
38      "isRequiredResource": true,
39      "isPrimaryResource": false,
40      "extendedFields": []
41    }
42  ]
43}
JSON example for unauthenticated user
1{
2  "serviceAppointment": {
3    "workTypeId": "08q2w000000XmniAAC",
4    "serviceTerritoryId": "0Hh2w000000XmoXCAS",
5    "schedStartTime": "2020-02-26T15:00:00.000Z",
6    "schedEndTime": "2020-02-26T16:00:00.000Z",
7    "street": "1 Market Street",
8    "city": "San Francisco",
9    "state": "CA",
10    "postalCode": "94105",
11    "country": "USA",
12    "appointmentType": "In Person",
13    "extendedFields": []
14  },
15  "assignedResources": [
16    {
17      "serviceResourceId": "0Hn2w000000gDWDCA2",
18      "isRequiredResource": true,
19      "isPrimaryResource": true,
20      "extendedFields": []
21    }
22  ],
23  "lead": {
24        "firstName": "Rachel",
25        "lastName": "Adams",       
26        "phone": "012-345-6789",            
27        "email": "rachel.adams@salesforce.com",
28        "company": "Salesforce",
29        "extendedFields": []
30    }
31}
Properties
Name Type Description Required or Optional Available Version
assignedResources Assigned Resource Input[] Service resource who is assigned to a service appointment.

When creating an appointment, you can use extendedFields to add values to any of the fields, including custom fields, in assignedResources as long as you have edit access to those fields.

Note

Optional 48.0
lead Lead Input[] Prospect or lead. Required if serviceAppointment isn’t provided

Required to create a service appointment with unauthenticated guest users.

Note

48.0
schedulingPolicyId String 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. Optional 48.0
serviceAppointment Service Appointment Input[] Appointment to complete a service work for a customer.

When creating an appointment, you can use extendedFields to add values to any of the fields, including custom fields, in serviceAppointment as long as you have edit access to those fields.

Note

Required if lead isn’t provided 48.0
Request body for PATCH
JSON example
1{
2  "serviceAppointmentId": "08pxx0000004C92AAE",
3  "serviceAppointment": {
4    "workTypeId": "08pxx0000004C92AAE",
5    "serviceTerritoryId": "0Hh2xx0000004CAeCAM",
6    "schedStartTime": "2020-09-15T16:00:00+0000",
7    "schedEndTime": "2020-09-22T16:45:00+0000",
8    "street": "1 Market Street",
9    "city": "San Francisco",
10    "state": "CA",
11    "postalCode": "94105",
12    "country": "USA",
13    "appointmentType": "In Person",
14    "extendedFields": [
15      {
16        "name": "Email",
17        "value": "rachel.adams@salesforce.com"
18      },
19      {
20        "name": "Phone",
21        "value": "111111111"
22      },
23      {
24        "name": "Description",
25        "value": "Test Description"
26      }
27    ],
28  "assignedResources": [
29    {
30      "serviceResourceId": "0Hnxx0000004CAeCAM",
31      "isRequiredResource": true,
32      "isPrimaryResource": false,
33      "extendedFields": []
34    },
35  ]
36}
Request example to update the scheduled time

The API updates the equivalent Salesforce calendar events and block times when the scheduled time is updated.

Note

1{
2  "serviceAppointmentId": "08pxx0000004C92AAE",
3  "serviceAppointment": {
4    "schedStartTime": "2020-09-15T16:00:00+0000",
5    "schedEndTime": "2020-09-22T16:45:00+0000",
6}
Request example to update the work type
1{
2  "serviceAppointmentId": "08pxx0000004C92AAE",
3  "serviceAppointment": {
4    "workTypeId": "08qxx0000004C92AAE",
5}
Request example to update the service territory
1{
2  "serviceAppointmentId": "08pxx0000004C92AAE",
3  "serviceAppointment": {
4    "serviceTerritoryId": "0Hhxx0000004CAeCAM"
5}
Properties
Name Type Description Required or Optional Available Version
assignedResources Assigned Resource Input[] Service resource who is assigned to a service appointment.

When updating an appointment, pass the complete list of resources needed.

If you don’t pass a resource that is assigned to a service appointment, the API deletes that assigned resource. For example, suppose that an existing service appointment has assigned resources: A and B and if you pass assigned resources: B and C. The API checks the resource availability of B and C for existing work type and service territory, and if both are available, the service appointment gets updated with:
  • Resource A—Deleted
  • Resource B—Updated
  • Resource C—Created

However, if you don’t pass any of the assigned resources, the API assumes there is no change.

When updating an appointment, you can use extendedFields to add values to any of the fields, including custom fields, in assignedResources as long as you have edit access to those fields.

Note

Optional 51.0
schedulingPolicyId String 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. Optional 51.0
serviceAppointment Service Appointment Input[] Appointment to complete a service work for a customer.

When updating an appointment, pass only the fields that need to be updated.

When updating an appointment, you can use extendedFields to add values to any of the fields, including custom fields, in serviceAppointment as long as you have edit access to those fields.

Note

Required 51.0
serviceAppointmentId String ID of the service appointment that you want to update. Required 51.0
Response body for POST and PATCH
Service Appointment Output