Assign Territory To User

Purpose

To assign a territory to a user.

Request URL

https://fsm.zoho.com/fsm/v1/users/<user_id>/Territories

user_id - The ID (the value of User in the Service_Resources key present in the List Users API response) of the user.

Request Method

POST

Scope

scope=ZohoFSM.users.CREATE

Input JSON Keys

NameDescriptionType
Territory
(mandatory)
The ID of the territory you want to assign to the user.JSON Object

Start_Date_Time

(mandatory)     

The date/time from which you want the user to be active/available in this territory. The value must be in the ISO format YYYY-MM-DDThh:mm:ssTZD.DateTime
End_Date_TimeThe date/time after which you want the user to be inactive/unavailable in this territory. The value must be in the ISO format YYYY-MM-DDThh:mm:ssTZDDateTime

Sample Request

Copiedcurl --request POST 'https://fsm.zoho.com/fsm/v1/users/6191XXXX7001/Territories' \
--header 'Authorization: Zoho-oauthtoken 1000.26xxxxxxxxxx.xxxxxxxxxx0' \
--header 'content-type: application/json' \
--data "{"field1":"value1","field2":"value2"}"

Sample Input

Copied{
    "data": [
        {
            "Territory": {
                "id": "6191000000371233"
            },
            "Start_Date_Time": "2024-07-23T13:00:00-06:00"
        }
    ]
}

Sample Response

Copied{
    "result": "success",
    "code": "SUCCESS",
    "data": {
        "Territories": [
            {
                "Modified_Time": "2024-07-22T04:17:44-05:00",
                "Modified_By": {
                    "name": "Alicia Florrick",
                    "id": "6191000000227001"
                },
                "Created_Time": "2024-07-22T04:17:44-05:00",
                "id": "6191000000652073",
                "Created_By": {
                    "name": "Alicia Florrick",
                    "id": "6191000000227001"
                }
            }
        ]
    },
    "status": "success"
}

Sample Error Response

Copied//The user is either already present in the territory or is part of a crew.
{
    "code": "INVALID_DATA",
    "details": {
        "info": {
            "Crew": {},
            "Territory": [
                {
                    "End_Date_Time": null,
                    "Territory": {
                        "id": 6191000000227288,
                        "Name": "Zylker"
                    },
                    "Start_Date_Time": "2023-10-05T02:34:05-05:00",
                    "id": "6191000000227298",
                    "Service_Resource": "6191000000227293"
                }
            ]
        }
    },
    "message": "SR is available in crew/territory at requested time ",
    "status": "error"
}

Sample Error Response

Copied//The End_Date_Time provided is before the Start_Date_Time
{
    "code": "INVALID_DATA",
    "details": {
        "Territories": [
            {
                "UID": "Territories_0",
                "code": "INVALID_DATA",
                "details": {},
                "message": "End Date Time must be after Start Date Time",
                "status": "error"
            }
        ]
    },
    "message": "invalid data",
    "status": "error"
}