Get Service Territories

A service territory represents a branch or office location where your service resources (appointment attendees) operate from or meet customers. Use the service-territories Connect API to fetch a list of service territories based on a work type group or work type.
  1. Create a page where you can provide users an option to search for service territories. Here’s how a Select Service Territory page can look.
    A representation of the Select Service Territory screen.
  2. Make a GET request on the service-territories Connect API by passing the user-entered search values and the selected work type group ID as the input parameters in the query string. You can also use a combination of the radius, latitude, longitude, sortBy, and sortOrder parameters to filter and sort the service territories.
    Resource URI
    https://yourInstance.salesforce.com/services/data/vXX.X/connect/scheduling/service-territories
    Sample Request

    This sample GET request specifies the query string on the service territories Connect API.

    https://yourInstance.salesforce.com/services/data/vXX.X/connect/scheduling/service-territories?workTypeGroupId=0VSS700000000sVOAQ
    &latitude=44.357422&longitude=-73.193952&radius=5&radiusUnit=mi&sortBy=Distance&sortOrder=asc
    Sample Response

    The API returns the available service territories based on the passed work type group ID and search criteria.

    {
      "result": {
        "serviceTerritories": [
          {
            "city": "Charlotte",
            "country": "United States",
            "id": "0HhS700000001DYKAY",
            "latitude": 44.357422,
            "longitude": -73.193952,
            "name": "Spear Street Branch",
            "operatingHoursId": "0OHS700000001HlOAI",
            "postalCode": "05445",
            "state": "VT",
            "street": "121 Spear Street"
          }
        ]
      }
    }
  3. Parse the JSON response, and show the available service territories on the Select Service Territory page so that the user can select a service territory.

    Here’s a Select Service Territory page showing the available service territories.

    A representation of the Select Service Territory screen.

    Here’s how the service territory details are displayed when the user selects a service territory.

    A representation of the Select Service Territory screen.

On the next page in your app, you can show the available time slots for the appointment.