A service appointment is an appointment booked through Salesforce Scheduler. Use the service-appointments API to create an appointment.
-
On your website, create a page with a Create button on which you can show the appointment details for the user to review and book the appointment.
-
Link the Create button to a POST request on the
service-appointmentsConnect API.Resource URI
https://YOUR_INSTANCE.salesforce.com/services/data/vXX.X/connect/scheduling/service-appointmentsWhere
YOUR_INSTANCEis a variable.For an Account User
Sample Request
This sample calls the
service-appointmentsAPI to create the appointment record for an account user.note: The
parentRecordIdfield is required. Pass the account ID asparentRecordIdin the input request body.{ "serviceAppointment": { "serviceTerritoryId": "0Hhx00000002LzGCAU", "parentRecordId": "001x0000005SEqZAAW", "schedStartTime": "2022-06-29T11:30:00.000+0000", "schedEndTime": "2022-06-29T12:30:00.000+0000", "additionalInformation": "Sharing availability use case using APIs.", "appointmentType": "Book Test Appointment1", "extendedFields": [ { "name": "status", "value": "Scheduled" } ] }, "assignedResources": [ { "serviceResourceId": "0Hnx000000007d7CAA", "isRequiredResource": "true" } ] }Sample Response
The API returns the service appointment ID and the assigned service resources.
{ "result": { "assignedResourceIds": [ "03rx0000000252jAAA" ], "serviceAppointmentId": "08px000000023bdAAA" } }For a Guest User
Sample Request
This sample calls the
service-appointmentsAPI to create the appointment record for a guest user.note: The
leadfield is required. Pass the guest user details, including the first name, last name, email address, and phone number asleadin the input request body.{ "serviceAppointment": { "serviceTerritoryId": "0Hhx00000002LzGCAU", "schedStartTime": "2022-06-29T11:30:00.000+0000", "schedEndTime": "2022-06-29T12:30:00.000+0000", "additionalInformation": "Sharing availability use case using APIs.", "appointmentType": "Book Test Appointment1", "extendedFields": [ { "name": "status", "value": "Scheduled" } ] }, "assignedResources": [ { "serviceResourceId": "0Hnx000000007d7CAA", "isRequiredResource": "true" } ], "lead": { "email": "Test@company.com", "firstName": "FirstName", "lastName": "LastName", "company": "CompanyName" } }Sample Response
The API returns the service appointment ID and the assigned service resources.
{ "result": { "assignedResourceIds": [ "03rx0000000252oAAA" ], "parentRecordId": "00Qx0000001cLwwEAE", "serviceAppointmentId": "08px000000023biAAA" } } -
If the service appointment creation is successful, then show the user a confirmation message.
Here’s a sample confirmation page.
