These endpoints power commercial territory balancing across Sales Teams (sales_teams), Level 3 Zones (sales_team_groups), Portfolios (portfolios.code), Sellers (sellers), and Level 4 Routes (territories.level = 4) visited in a single journal day (portfolio_schedules), as well as the Standalone Python MCP Server (goal-mcp).
Authorization: Bearer <token>
x-app-stage: dev|test|prod
x-app-uid: <client-uid>
Accept: application/json
Content-Type: application/json
GET /v1/sales/master/portfolio-schedules/reports/route-workload-balance)PORTFOLIO_SCHEDULE.LIST (AuthorizesModelActions)companyId (int, required)salesTeamId (int, optional)salesTeamGroupId (int, optional)zoneTerritoryId (int, optional)portfolioId (int, optional)sellerId (int, optional)dayCode (string, optional: 1..7)target_daily_customers (int, default 40)tolerance_pct (float, default 25.0)ActionResult):
summary: total_routes, scheduled_routes_count, unscheduled_routes_count, total_active_customers, assigned_to_route_customers, unassigned_to_route_customers, balanced_routes_count, overloaded_routes_count, underloaded_routes_count, by_journal_day.routes: array of L4 routes with territory_id, route_code, route_name, zone_code, portfolio_code, seller_name, day_name, active_customers_count, utilization_pct, workload_status (BALANCED | OVERLOADED | UNDERLOADED | UNSCHEDULED | EMPTY), and has_draft_polygon.GET /v1/sales/master/portfolio-assignments/reports/seller-workload)PORTFOLIO_ASSIGNMENT.LISTcompanyId (required), salesTeamId, salesTeamGroupId, portfolioId, sellerId.ActionResult): Summary of assigned/unassigned portfolios plus per-portfolio weekly breakdown (days 1..7 with routes_count, route_codes, active_customers_count) and assignments_history_count.PUT /v1/sales/master/territories/{id}/draft-polygon)TERRITORY.DRAWING_UPDATEterritories.draft_paths (polygon type). Never mutates productive territories.paths.{
"geojson": {
"type": "Polygon",
"coordinates": [[[-77.05, -12.05], [-77.04, -12.05], [-77.04, -12.04], [-77.05, -12.04], [-77.05, -12.05]]]
},
"color": "#1976D2"
}
/v1/sales/master/route-rebalance-scenarios)| Method | Path | Permission | Description |
|---|---|---|---|
GET |
/ |
ROUTE_REBALANCE_SCENARIO.LIST |
List scenarios (sales_team_id, sales_team_group_id, scenario_status). |
POST |
/ |
ROUTE_REBALANCE_SCENARIO.INSERT |
Create a scenario (DRAFT or PENDING_APPROVAL) with before/after metrics. |
GET |
/{id} |
ROUTE_REBALANCE_SCENARIO.DETAILS |
Get scenario detail, before/after route comparison, and items. |
POST |
/{id}/approve |
ROUTE_REBALANCE_SCENARIO.APPROVE |
Approve and apply changes transactionally (apply_draft_polygons optional bool). |
POST |
/{id}/reject |
ROUTE_REBALANCE_SCENARIO.REJECT |
Reject scenario with rejection_reason. |
DELETE |
/{id} |
ROUTE_REBALANCE_SCENARIO.SOFT_DELETE |
Soft-delete scenario. |
POST /v1/sales/master/route-rebalance-scenarios){
"sales_team_id": 1,
"sales_team_group_id": 10,
"name": "Balanceo Zona Norte - Lunes",
"source": "MCP_AI",
"target_daily_customers": 40,
"tolerance_pct": 25,
"submit_for_approval": true,
"items": [
{
"item_type": "MOVE_CUSTOMER",
"sales_team_customer_id": 1045,
"target_territory_id": 502,
"reason": "Reducir sobrecarga de ruta R01 (58 -> 42)"
}
]
}