Create Service Appointments

A service appointment represents an appointment booked through Salesforce Scheduler. Make a POST request on the service-appointments Connect API to create the appointment.

  1. Create a page where the user can review the appointment details and create the appointment.

    Here’s how a Review Service Appointment page can look.

    A representation of the Review Service Appointment screen.

  2. Link the Next button to a POST request on the service-appointments Connect API to create the service appointment.

    Resource URI

    1https://yourInstance.salesforce.com/services/data/vXX.X/connect/scheduling/service-appointments

    For an Existing User (Account)

    Sample Request

    Pass the account ID as parentRecordId in the input request body.

    Set status to Scheduled to indicate that the appointment is scheduled.

    1{
    2   "serviceAppointment": {
    3      "serviceTerritoryId": "0HhS700000001DYKAY",
    4      "parentRecordId" : "001S7000001pFlJIAU",
    5      "schedStartTime" : "2023-11-30T17:00:00.000+0000",
    6      "schedEndTime": "2023-11-30T18:00:00.000+0000",
    7      "street": "121 Spear Street",
    8      "city": "Charlotte",
    9      "state": "VT",
    10      "postalCode": "05445",
    11      "country": "United States",
    12      "engagementChannelTypeId" : "0eFS70000004CG5MAM",
    13      "extendedFields" : [{
    14        "name": "status",
    15        "value": "Scheduled"
    16      }]
    17   },
    18   "assignedResources": [
    19      {
    20        "serviceResourceId": "0HnS700000002jAKAQ",
    21        "isRequiredResource": true,
    22        "isPrimaryResource": true,
    23        "extendedFields" : []
    24      }, {
    25        "serviceResourceId": "0HnS700000002jKKAQ",
    26        "isRequiredResource": true,
    27        "isPrimaryResource": false,
    28        "extendedFields" : []
    29      }
    30   ]
    31}

    Sample Response

    The API returns the service appointment ID and the assigned service resources.

    1{
    2  "result": {
    3    "assignedResourceIds": [
    4      "03rS700000000ogIAA",
    5      "03rS700000000ohIAA"
    6    ],
    7    "serviceAppointmentId": "08pS700000001GIIAY"
    8  }
    9}

    For a Guest User (Lead)

    Sample Request

    Pass the required lead details in the input request body.

    Set status to Scheduled to indicate that the appointment is scheduled.

    1{
    2   "serviceAppointment": {
    3      "serviceTerritoryId": "0HhS700000001DYKAY",
    4      "schedStartTime" : "2023-11-30T17:00:00.000+0000",
    5      "schedEndTime": "2023-11-30T18:00:00.000+0000",
    6      "street": "121 Spear Street",
    7      "city": "Charlotte",
    8      "state": "VT",
    9      "postalCode": "05445",
    10      "country": "United States",
    11      "engagementChannelTypeId" : "0eFS70000004CG5MAM",
    12      "extendedFields" : [{
    13        "name": "status",
    14        "value": "Scheduled"
    15      }]
    16   },
    17   "assignedResources": [
    18      {
    19        "serviceResourceId": "0HnS700000002jAKAQ",
    20        "isRequiredResource": true,
    21        "isPrimaryResource": true,
    22        "extendedFields" : []
    23      }, {
    24        "serviceResourceId": "0HnS700000002jKKAQ",
    25        "isRequiredResource": true,
    26        "isPrimaryResource": false,
    27        "extendedFields" : []
    28      }
    29   ] ,
    30    "lead": {
    31      "firstName": "Philip",
    32      "lastName": "Taylor",
    33      "phone": "012-345-6789",
    34      "email": "pmtaylor@company.com",
    35      "company": "Philip&Taylor Company",
    36      "extendedFields" : []
    37   }
    38}

    Sample Response

    The API returns the service appointment ID and the assigned service resources.

    1{
    2  "result": {
    3    "assignedResourceIds": [
    4      "03rS700000000oqIAA",
    5      "03rS700000000orIAA"
    6    ],
    7    "parentRecordId": "00QS7000000sfcxMAA",
    8    "serviceAppointmentId": "08pS700000001GSIAY"
    9  }
    10}

Create a page to show confirmation when the service appointment is created successfully.

Here’s how a sample confirmation page can look.

A representation of the confirmation screen.