Build Territories from Assignments
direct_buildBuilds territories from known part-to-territory assignments (a ZIP-to-territory sheet or file, including a three-level region/district/territory hierarchy via territory_path) and adds them to the Territory Solution as a new alignment (TAL). Assignments come only as an assignments_handle (aup_...) from request_assignment_upload (the file, csv_text, or assignment rows). Sheets with Postal Code plus Territory/Region/Division columns are mapped automatically. Duplicate part_ids follow duplicate_part_policy (default keep_first). Returns a task; the result carries tal_id and ts_handle and paints the open map. Location points load with ingest_accounts; balanced partitions come from auto_build; grouping by a column is account_build.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"part_layer": "<part_layer>",
"tal_label": "<tal_label>"
},
"name": "direct_build"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tal_id | No | Optional caller-supplied TAL identifier. When omitted, the server derives a stable ID from tal_label. Supplied IDs must not collide with an existing TAL in the input TS. | |
| tal_label | Yes | ||
| ts_handle | No | Territory Solution reference (tsh_...) from a build, ingest_accounts, import_geojson, import_designer_project, or get_map_visualization; Territory Solutions are not accepted inline. | |
| part_layer | Yes | ||
| repair_policy | No | Topology repair for dissolved territories. default fills interior holes in the dissolved geometry (no part is added or reassigned; repair_summary.changed_part_ids lists the territories' own parts). report_only detects holes and changes nothing (warning REPAIR_AVAILABLE). strict fails with REPAIR_REQUIRED when a hole is found. | default |
| map_session_id | No | Open map session (msess_...) from get_map_visualization. Its Territory Solution is the input; omit ts_handle when set. | |
| expected_revision | No | ||
| assignments_handle | No | Required. upload_handle (aup_...) from request_assignment_upload. Single-use: the build claims it. | |
| missing_part_policy | No | Controls assigned part IDs that are absent from the selected polygon part layer. fail returns UNKNOWN_PART_ID. drop_with_warning omits them, lists them in invalid_parts, and proceeds with geometry-covered assignments. | fail |
| duplicate_part_policy | No | When the same part_id maps to different territory_path values, keep_first (default) keeps the first row and skips the rest with a warning; keep_last keeps the last row; fail aborts with CLARIFICATION_REQUIRED. | keep_first |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| error | No | Present when ok is false. | |
| result | No | Present when ok is true. A submission returns the task reference (task_id, next_action, sleep_ms); the completed task result carries the remaining fields. | |
| warnings | No |