Territory
Territory protocol schemas
Territory Management Protocol
Defines a matrix reporting structure that exists parallel to the Role Hierarchy.
USE CASE:
-
Enterprise Sales Teams (Geo-based: "EMEA", "APAC")
-
Industry Verticals (Industry-based: "Healthcare", "Financial")
-
Strategic Accounts (Account-based: "Strategic Accounts")
DIFFERENCE FROM ROLE:
-
Role: Hierarchy of PEOPLE (Who reports to whom). Stable. HR-driven.
-
Territory: Hierarchy of ACCOUNTS/REVENUE (Who owns which market). Flexible. Sales-driven.
-
One User can be assigned to MANY Territories (Matrix).
-
One User has only ONE Role (Tree).
Source: packages/spec/src/security/territory.zod.ts
TypeScript Usage
import { Territory, TerritoryModel, TerritoryType } from '@objectstack/spec/security';
import type { Territory, TerritoryModel, TerritoryType } from '@objectstack/spec/security';
// Validate data
const result = Territory.parse(data);Territory
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Territory unique name (lowercase snake_case) |
| label | string | ✅ | Territory Label (e.g. "West Coast") |
| modelId | string | ✅ | Belongs to which Territory Model |
| parent | string | optional | Parent Territory |
| type | Enum<'geography' | 'industry' | 'named_account' | 'product_line'> | ✅ | |
| assignmentRule | string | optional | Criteria based assignment rule |
| assignedUsers | string[] | optional | |
| accountAccess | Enum<'read' | 'edit'> | ✅ | |
| opportunityAccess | Enum<'read' | 'edit'> | ✅ | |
| caseAccess | Enum<'read' | 'edit'> | ✅ |
TerritoryModel
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Model Name (e.g. FY24 Planning) |
| state | Enum<'planning' | 'active' | 'archived'> | ✅ | |
| startDate | string | optional | |
| endDate | string | optional |
TerritoryType
Allowed Values
geographyindustrynamed_accountproduct_line