Get Service Territories

Changed on

Lists service territories. Role-based auto-scoping applies: a Team Leader only sees territories owned/created by users on their teams; a Field Executive only sees their own owned/created territories.

get/territory

Request

  • Base URL
    https://dc-region.zuperpro.com/api
  • URL
    https://dc-region.zuperpro.com/api/territory
  • Auth
    API key in header x-api-key

Query parameters

pageinteger
countinteger
sort'DESC' | 'ASC'
sort_by'territory_name' | 'created_at'
filter.keywordstring

For search (includes only territory_name)

filter.is_activeboolean
filter.typestring

created_at

filter.updated_at_fromstring

Must be sent together with the other updated_at bound. Strict format: YYYY-MM-DDTHH:mm:ssZ, YYYY-MM-DD HH:mm:ss, YYYY-MM-DDTHH:mm:ss.SSSZ, or YYYY-MM-DD HH:mm:ss.SSS.

filter.updated_at_toboolean

Must be sent together with the other updated_at bound. Strict format: YYYY-MM-DDTHH:mm:ssZ, YYYY-MM-DD HH:mm:ss, YYYY-MM-DDTHH:mm:ss.SSSZ, or YYYY-MM-DD HH:mm:ss.SSS.

filter.zip_codestring
filter.locationstring

"<latitude>,<longitude>" — applied as an in-memory geo filter (point-in-radius for RADIUS territories, point-in-polygon for GEOFENCE) after the DB query, so pagination totals reflect the post-filter count.

filter.territory_uidstring
filter.user_uidstring
filter.team_uidstring
populate_ownersboolean

If true, populates owners with user details.

populate_teamsboolean

If true, populates teams with team details.

filter.ownedboolean

If true, restricts to territories where the requesting user is listed in owners.

Response

200

typestring
total_recordsinteger
current_pagestring
total_pagesinteger

Example response

{
  "type": "success",
  "data": [
    {
      "territory_uid": "0f4ee337-85c6-472b-a0c9-f471b67f8ea5",
      "territory_name": "check 2",
      "territory_description": "check",
      "territory_color": "#4960a0",
      "territory_type": "ZIPCODE",
      "territory_zipcodes": [
        "600028"
      ],
      "created_by": {
        "user_uid": "48625036-fef6-4637-99e7-f09377a4f9ba",
        "first_name": "Hariharan",
        "last_name": "M",
        "email": "hariharan.m@zuper.co",
        "designation": "Tech",
        "emp_code": "1234",
        "prefix": "Z22",
        "profile_picture": "https://s3.ap-south-1.amazonaws.com/prod.app.zuperpro/assets/profile_picture.jpg",
        "hourly_labor_charge": 20,
        "is_active": true,
        "created_at": "2024-07-05T06:42:02.000Z",
        "updated_at": "2024-07-05T06:42:02.000Z"
      },
      "is_active": true,
      "created_at": "2024-09-19T10:39:36.663Z",
      "updated_at": "2024-09-19T10:39:36.667Z"
    }
  ],
  "total_records": 3,
  "current_page": "1",
  "total_pages": 1
}

Changes