# Book Service Appointments

A service appointment is an appointment booked through Salesforce Scheduler. Use the `service-appointments` API to create an appointment.

1. 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.

2. Link the Create button to a POST request on the [`service-appointments`](https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_service_appointments.htm) Connect API.

   **Resource URI**

   ```nolang
   https://YOUR_INSTANCE.salesforce.com/services/data/vXX.X/connect/scheduling/service-appointments
   ```

   Where `YOUR_INSTANCE` is a variable.

   **For an Account User**

   **Sample Request**

   This sample calls the `service-appointments` API to create the appointment record for an account user.

   :::note
   The `parentRecordId` field is required. Pass the account ID as `parentRecordId` in the input request body.
   :::

   ```nolang
   {
     "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.

   ```nolang
   {
     "result": {
       "assignedResourceIds": [
         "03rx0000000252jAAA"
       ],
       "serviceAppointmentId": "08px000000023bdAAA"
     }
   }
   ```

   **For a Guest User**

   **Sample Request**

   This sample calls the `service-appointments` API to create the appointment record for a guest user.

   :::note
   The `lead` field is required. Pass the guest user details, including the first name, last name, email address, and phone number as `lead` in the input request body.
   :::

   ```nolang
   {
     "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.

   ```nolang
   {
     "result": {
       "assignedResourceIds": [
         "03rx0000000252oAAA"
       ],
       "parentRecordId": "00Qx0000001cLwwEAE",
       "serviceAppointmentId": "08px000000023biAAA"
     }
   }
   ```

3. If the service appointment creation is successful, then show the user a confirmation message.

   Here’s a sample confirmation page.

   ![A representation of the confirmation screen.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/screen_appointment_creation.png)
