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

   :::note
   To keep the service resource private, hide the resource’s name on the review appointment page.
   :::

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

2. Link the Next 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 to create the service appointment.

   **Resource URI**

   ```nolang
   https://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 `IsAnonymousBooking` to `true` to indicate that the appointment is anonymous.

   ```nolang
   {
      "serviceAppointment": {
         "serviceTerritoryId": "0HhS700000001DYKAY",
         "parentRecordId" : "001S7000001pFlJIAU", 
         "schedStartTime" : "2023-11-29T20:00:00.000Z",
         "schedEndTime": "2023-11-29T21:00:00.000Z",
         "street": "121 Spear Street",
         "city": "Charlotte",
         "state": "VT",
         "postalCode": "05445",
         "country": "United States",
         "engagementChannelTypeId" : "0eFS70000004CG5MAM",
         "extendedFields" : [ {
           "name": "IsAnonymousBooking", 
           "value": "true"
         } ]
      },
      "assignedResources": [
         {
           "serviceResourceId": "0HnS700000002jAKAQ",
           "isRequiredResource": true,
           "extendedFields" : []
         }
      ]
   }
   ```

   **Sample Response**

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

   ```nolang
   {
     "result" : {
       "assignedResourceIds" : [ "03rS700000000oMIAQ" ],
       "serviceAppointmentId" : "08pS700000001G3IAI"
     }
   }
   ```

   **For a Guest User (Lead)**

   **Sample Request**

   Pass the required lead details in the input request body.

   Set `IsAnonymousBooking` to `true` to indicate that the appointment is anonymous.

   ```nolang
   {
      "serviceAppointment": {
         "serviceTerritoryId": "0HhS700000001DYKAY",
         "schedStartTime" : "2023-11-29T22:15:00.000Z",
         "schedEndTime": "2023-11-29T23:15:00.000Z",
         "street": "121 Spear Street",
         "city": "Charlotte",
         "state": "VT",
         "postalCode": "05445",
         "country": "United States",
         "engagementChannelTypeId" : "0eFS70000004CG5MAM",
         "extendedFields" : [ {
           "name": "IsAnonymousBooking", 
           "value": "true"
         } ]
      },
      "assignedResources": [
         {
           "serviceResourceId": "0HnS700000002jGKAQ",
           "isRequiredResource": true,
           "extendedFields" : []
         }
      ],
       "lead": {
           "firstName": "Tom",
           "lastName": "Smith",
           "phone": "(555) 555-1234",
           "email": "info@salesforce.com",
           "company": "MedLife, Inc.",
           "extendedFields" : []
      }
   }
   ```

   **Sample Response**

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

   ```nolang
   {
     "result" : {
       "assignedResourceIds" : [ "03rS700000000oRIAQ" ],
       "parentRecordId" : "00QS7000000sfcnMAA",
       "serviceAppointmentId" : "08pS700000001G8IAI"
     }
   }
   ```

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.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/screen_appointment_creation.png)
