Zoho: Run territory assignment rules
Zoho territories.runTerritoryRules: arguments, response, policy and SDK examples.
← Territories operations · Get started
Operation zoho.runterritoryrules
Provider route: POST /crm/v8/settings/territories/actions/run_rules. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/zoho with npm, or alter-sdk-zoho with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { ZohoIntegration } from "@alter-ai/zoho";
async function execute(input: Parameters<ZohoIntegration["territories"]["runTerritoryRules"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new ZohoIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.territories.runTerritoryRules(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_zoho import ZohoIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = ZohoIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.territories.run_territory_rules(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
body | object | Required within parent | Specify the configuration for scheduling territory rule execution. The schema supports three execution methods: criteria-based, Custom View-based, and territory-based. Additional keys: not allowed |
body.run_rules | JSON | Required within parent | Specify the configuration for territory rule execution. The run_rules object must match one of three execution methods: criteria-based, Custom View-based, or territory-based. |
body.run_rules (anyOf 1) | object | Alternative | Specify the criteria-based configuration for territory rule execution. Use this option to run territory assignment rules against records matching a filter criterion. Additional keys: not allowed |
body.run_rules (anyOf 1).based_on | string | Required within parent | Specify the execution method for territory assignment rules. Possible values: criteria - Runs territory rules against records matching a specified filter criterion. One of: criteria |
body.run_rules (anyOf 1).criteria | Model | Required within parent | Expand Related Records — request body — query filters Filter criteria for territory rule execution. |
body.run_rules (anyOf 1).module | Model | Required within parent | Expand Run territory assignment rules — request body — body / run_rules / based_on: criteria module Specify the API name of the module for which to run territory assignment rules. |
body.run_rules (anyOf 2) | object | Alternative | Specify the Custom View-based configuration for territory rule execution. Use this option to run territory assignment rules against records in a specified Custom View. Additional keys: not allowed |
body.run_rules (anyOf 2).based_on | string | Required within parent | Specify the execution method for territory assignment rules. Possible values: custom_view - Runs territory rules against records included in a specified Custom View. One of: custom_view |
body.run_rules (anyOf 2).custom_view | object | Required within parent | Specify the Custom View for which the territory assignment rules apply. Provide either the ID or the api_name of the Custom View. Additional keys: not allowed |
body.run_rules (anyOf 2).custom_view.api_name | string | Optional | Specify the API name of the Custom View for which the territory assignment rules apply. Maximum length: 100 |
body.run_rules (anyOf 2).custom_view.id | string | Optional | Specify the unique identifier of the Custom View for which the territory assignment rules apply. Format: int64 Maximum length: 25 |
body.run_rules (anyOf 2).custom_view (anyOf 1) | JSON | Alternative | Specify the Custom View using its unique identifier. Provide the id field to identify the Custom View by its numeric ID. |
body.run_rules (anyOf 2).custom_view (anyOf 2) | JSON | Alternative | Specify the Custom View using its API name. Provide the api_name field to identify the Custom View by its string identifier. |
body.run_rules (anyOf 2).module | Model | Required within parent | Expand Run territory assignment rules — request body — body / run_rules / based_on: criteria module Specify the API name of the module for which to run territory assignment rules. |
body.run_rules (anyOf 3) | object | Alternative | Specify the territory-based configuration for territory rule execution. Use this option to run territory assignment rules against records associated with one or more specific territories. Additional keys: not allowed |
body.run_rules (anyOf 3).based_on | string | Required within parent | Specify the execution method for territory assignment rules. Possible values: territory - Runs territory rules against records associated with specified territories. One of: territory |
body.run_rules (anyOf 3).include_child | boolean | Optional | Specify whether to include child territories when running the territory assignment rules. Possible values: true - Includes child territories of the specified territories in the rule execution. false - Runs rules only for the specified territories, without their child territories. |
body.run_rules (anyOf 3).module | Model | Required within parent | Expand Run territory assignment rules — request body — body / run_rules / based_on: criteria module Specify the API name of the module for which to run territory assignment rules. |
body.run_rules (anyOf 3).territories | array | Required within parent | Specify the list of territories for which the territory assignment rules apply. Maximum items: 100 Minimum items: 1 |
body.run_rules (anyOf 3).territories[] | object | Each item | Specify a territory for which the assignment rules apply. Provide the ID of the territory. Additional keys: not allowed |
body.run_rules (anyOf 3).territories[].id | string | Required within parent | Specify the unique identifier of the territory for which the assignment rules apply. Format: int64 |
Referenced models: Related Records — request body — query filters, Run territory assignment rules — request body — body / run_rules / based_on: criteria module
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Run territory assignment rules — response body |
Referenced models: Run territory assignment rules — response body
Schemas
Section titled “Schemas”10 more schemas are linked from the tables above, on the schema pages.
Related Records — request body — query filters
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | Represents the top-level filter criterion for data selection, supporting both simple field-based filters and complex grouped filters with logical operators. |
$ (anyOf 1) | Model | Alternative | Expand Related Records — request body — query filters value |
$ (anyOf 2) | Model | Alternative | Expand Related Records — request body — query / filters / group_operator: AND, OR, and, or |
Referenced models: Related Records — request body — query / filters / group_operator: AND, OR, and, or, Related Records — request body — query filters value
Run territory assignment rules — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents the response returned when territory rules execution has been scheduled. Additional keys: not allowed |
run_rules | object | Required within parent | Represents the result of the scheduled territory rules execution. Additional keys: not allowed |
run_rules.code | string | Required within parent | Represents the result code for the scheduled territory rules execution. Possible values: **SCHEDULED**. Known values: SCHEDULED |
run_rules.details | object | Required within parent | Represents additional details about the scheduled execution, including the job identifier. Additional keys: not allowed |
run_rules.details.job_id | string | Required within parent | Represents the unique identifier of the scheduled territory rules execution job. Format: int64 |
run_rules.message | string | Required within parent | Represents the success message returned when territory rules execution is scheduled. Possible values: **Territory rules scheduled successfully.Once done, completion email is sent.**, **Territory rules Scheduled successfully.Once done Completion email will sent**. Known values: Territory rules scheduled successfully.Once done, completion email will be sent., Territory rules Scheduled successfully.Once done Completion email will sent Maximum length: 100 |
run_rules.status | string | Required within parent | Represents the status of the scheduled territory rules execution. Possible values: **success**. Known values: success |
Run territory assignment rules — request body — body / run_rules / based_on: criteria module
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents the CRM module associated with the territory rule, identified by either its unique ID or API name. Additional keys: not allowed |
api_name | string | Optional | Represents the API name of the module associated with the territory rule. Maximum length: 50 |
id | string | Optional | Represents the unique identifier of the module associated with the territory rule. Format: int64 |
$ (anyOf 1) | JSON | Alternative | Represents the module identified by its unique ID. |
$ (anyOf 2) | JSON | Alternative | Represents the module identified by its API name. |
Related Records — request body — query / filters / group_operator: AND, OR, and, or
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a grouped filter criterion containing multiple filter conditions evaluated with a logical operator. Supports recursive nesting for complex filtering logic. Additional keys: not allowed |
group | array | Required within parent | Contains an array of filter conditions grouped together and evaluated with the specified logical operator. Maximum items: 25 Minimum items: 2 |
group[] | JSON | Each item | |
group[] (anyOf 1) | Model | Alternative | Expand Related Records — request body — query filters value |
group[] (anyOf 2) | Model | Alternative | Expand Related Records — request body — query / filters / group_operator: AND, OR, and, or |
group_operator | string | Required within parent | Represents the logical operator applied between the filter conditions in the group. Possible values: AND - All conditions in the group must be satisfied. OR - At least one condition in the group must be satisfied. and - Equivalent to AND; all conditions in the group must be satisfied. or - Equivalent to OR; at least one condition in the group must be satisfied. One of: AND, OR, and, or |
Referenced models: Related Records — request body — query / filters / group_operator: AND, OR, and, or, Related Records — request body — query filters value
Related Records — request body — query filters value
Referenced models: Related Records — request body — query / filters / value / comparator: between, not between, type: merge field, pre defined, value, field, Related Records — request body — query filters value value, Related Records — request body — query / filters / value / comparator: include all, include any, exclude all, exclude any, type: merge field, pre defined, value, field, Related Records — request body — query / filters / value / comparator: less than, less equal, greater than, greater equal, type: merge field, pre defined, value, field, Related Records — request body — query / filters / value / comparator: in, not in, type: merge field, pre defined, value, field, Related Records — request body — query / filters / value / comparator: like, not like, starts with, ends with, contains, not contains, type: merge field, pre defined, value, field
Related Records — request body — query filters value value
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | Represents an equality filter criterion that dispatches to either the EqualFilterCriterionRequest or NotEqualFilterCriterionRequest schema based on the comparator value. |
$ (anyOf 1) | Model | Alternative | Expand Related Records — request body — query / filters / value / value / comparator: equal, type: merge field, pre defined, value, field |
$ (anyOf 2) | Model | Alternative | Expand Related Records — request body — query / filters / value / value / comparator: not equal, type: merge field, pre defined, value, field |
Referenced models: Related Records — request body — query / filters / value / value / comparator: equal, type: merge field, pre defined, value, field, Related Records — request body — query / filters / value / value / comparator: not equal, type: merge field, pre defined, value, field
Related Records — request body — query / filters / value / comparator: in, not in, type: merge field, pre defined, value, field field api name, id
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents the base field reference used in filter operations, containing minimal required properties. The field's data_type is not part of this object; resolve it from the corresponding FieldSchema. For formula fields, use formula.return_type as the effective data_type; for rollup_summary fields, use rollup_summary.return_type. Additional keys: allowed |
api_name | string | Optional | Represents the API name of the field used for filter application. Supports relationship notation, for example, Deals__r.Stage. |
id | string | Optional | Represents the unique ID of the field used for filter operations. Format: int64 |
Related Records — request body — query / filters / value / comparator: less than, less equal, greater than, greater equal, type: merge field, pre defined, value, field value string
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | string | Root | Represents a predefined age or due-in-days placeholder value applicable only when the field's data_type is date or datetime. Follows the pattern ${AGEINDAYS}+<n> for records where the date field was exactly n days in the past, or ${DUEINDAYS}+<n> for records where the date field is exactly n days in the future. Supported comparators are equal, not_equal, less_than, greater_than, less_equal, and greater_equal. Maximum length: 255 Pattern: ^\$\{(AGEINDAYS|DUEINDAYS)\}\+[0-9]+$ |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: zoho.runterritoryrules. Catalog operation: runTerritoryRules. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.