The Sales Master Data Module (/v1/sales/master) serves as the operational backbone for sales force automation (SFA), geographic territory hierarchy, delivery zones, portfolio customer assignments, commercial price tiers, and catalog restriction rules.
/v1/sales/master
routes/v1/backend/sales/master/master.php under routes/v1/backend/sales/sales.php.company-validator is enforced on all master endpoints.Authorization: Bearer <access_token>
x-app-stage: <stage>
x-app-uid: <application_uuid>
Content-Type: application/json
Accept: application/json
All requests require companyId passed either via query string (?companyId={id}) or in JSON request bodies.
The 22 sub-routes in sales/master/master.php are organized into 6 functional clusters:
| Cluster | Sub-Routes & Prefixes | Key Functionality |
|---|---|---|
| 1. Geographic & Territories | territories, delivery-zones, sales-zones |
4-tier territory trees, GIS polygons, draft-to-productive staging, delivery windows, child routes. |
| 2. Sales Teams & Organization | sales-teams, sales-team-groups, business-types |
Sales teams CRUD, channel bindings, territory mapping, business categories. |
| 3. Portfolios & Customer Assignments | portfolios, portfolio-assignments, portfolio-schedules |
Customer portfolio engine, mass assign/unassign, weekly visit schedules, reassignments. |
| 4. Sellers & Commercial Reps | sellers, sales-routes, sales-schedules |
Commercial sellers, assigned territories, orders history, non-order reasons, route definitions. |
| 5. Catalog & Assortment Rules | sales-team-product-catalogs, ...-excludes, ...-suppliers |
Hierarchical catalog pivots (global → dc / branch → zone / group); exclusions/suppliers by sales_team_id; materialize into sales_team_products / sales_team_group_products. |
| 6. Channels, Prices & Relations | sales-teams-channels, customer-channels, order-sources, sales-team-prices, sales-customers, sales-team-customers |
Sales channels, order sources, team price lists, customer links, activation and ERP sync. |
/v1/sales/master/territories)Manages hierarchical commercial territories (Region → SubRegion → Zone → Territory) with GIS boundary support.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/territories |
List paginated territories |
POST |
/v1/sales/master/territories |
Create territory record |
GET |
/v1/sales/master/territories/tree |
Full nested territory tree (L1 to L4) |
GET |
/v1/sales/master/territories/with-children |
Flat list including immediate children |
GET |
/v1/sales/master/territories/search |
Search territories by code or name |
GET |
/v1/sales/master/territories/ancestors |
Retrieve breadcrumb path of parent territories |
GET |
/v1/sales/master/territories/config |
Retrieve territory module configuration & limits |
GET |
/v1/sales/master/territories/trasheds |
List soft-deleted territories |
GET |
/v1/sales/master/territories/{id} |
Retrieve single territory |
PUT |
/v1/sales/master/territories/{id} |
Update territory details |
DELETE |
/v1/sales/master/territories/{id} |
Soft delete territory |
PUT |
/v1/sales/master/territories/{id}/restore |
Restore soft-deleted territory |
GET |
/v1/sales/master/territories/{id}/children |
Immediate children of a territory |
GET |
/v1/sales/master/territories/{id}/territories |
Sub-territories by parent ID |
GET |
/v1/sales/master/territories/{id}/polygon |
Retrieve primary GeoJSON polygon coordinates |
GET |
/v1/sales/master/territories/{id}/polygon-list |
List multi-polygon coordinate arrays |
POST |
/v1/sales/master/territories/geojson |
Bulk import territory boundaries via GeoJSON payload |
PUT |
/v1/sales/master/territories/{id}/location |
Update centroid latitude/longitude coordinates |
PUT |
/v1/sales/master/territories/{id}/status |
Update active status (A / I) |
POST |
/v1/sales/master/territories/{id}/propagate-color |
Cascade territory theme color to child nodes |
POST |
/v1/sales/master/territories/{id}/copy-children |
Copy child territories from another territory of the same level |
POST |
/v1/sales/master/territories/sync |
Import territory hierarchy from SB1 into GOAL |
POST |
/v1/sales/master/territories/sync-routes-to-erp |
Export selected GOAL level-4 routes (rutas) into SB1 gproc.rutas |
POST |
/v1/sales/master/territories/sync-zones-to-erp |
Export selected GOAL level-3 zones (zonas) into SB1 gproc.zonas |
POST |
/v1/sales/master/territories/sync-regions-to-erp |
Export GOAL level-1 territories into SB1 gproc.regions (optional territoryIds[]) |
POST |
/v1/sales/master/territories/sync-sub-regions-to-erp |
Export GOAL level-2 territories into SB1 gproc.sub_regions (optional territoryIds[]) |
ERP push on save: Creating or updating a CUSTOM territory at level 1 or 2 upserts the matching SB1 row by code and refreshes territories.erp_id. The API response may include erp_sync when warnings apply.
Request example (bulk regions):
POST /v1/sales/master/territories/sync-regions-to-erp
{
"companyId": 19,
"territoryIds": [101, 102]
}
Response (ActionResult):
{
"success": true,
"message": "Sincronización de regiones: 1 creadas, 1 actualizadas",
"data": {
"created": ["R01"],
"updated": ["R02"],
"errors": [],
"ids": { "R01": 5, "R02": 6 }
},
"stage": "dev"
}
| POST | /v1/sales/master/territories/import-polygons | Ingest external polygon files |
| POST | /v1/sales/master/territories/import-all-polygons| Force full company polygon re-import |
| POST | /v1/sales/master/territories/clone-to-draft | Copy productive territory boundaries to staging draft |
| POST | /v1/sales/master/territories/confirm-draft | Publish verified draft boundaries into productive SFA |
| GET | /v1/sales/master/territories/{id}/versions | List historical boundary version snapshots |
| PUT | /v1/sales/master/territories/versions/{id}/restore| Rollback territory to an earlier version snapshot |
POST /v1/sales/master/territories/sync-routes-to-erp)Exports one or more level-4 territory records (sales routes) from GOAL into the company SB1 database table gproc.rutas. This is the inverse direction of POST /v1/sales/master/territories/sync (which imports hierarchy from SB1 into GOAL).
Mandatory Headers:
Authorization: Bearer <token>x-app-stage: <stage>x-app-uid: <uid>Content-Type: application/jsonRequest Body:
| Field | Type | Required | Description |
|---|---|---|---|
companyId |
integer | Yes | Company context |
territoryIds |
integer[] | Yes | GOAL territory IDs; each must be level = 4 with parent level = 3 (zone) |
Example request:
{
"companyId": 8,
"territoryIds": [12045, 12046]
}
Success response (200):
{
"success": true,
"message": "Sincronización de rutas completada: 1 creadas, 1 actualizadas",
"data": {
"created": 1,
"updated": 1,
"errors": [],
"details": [
{ "territory_id": 12045, "code": "RTAY501" },
{ "territory_id": 12046, "code": "RTAY502" }
]
}
}
HTTP status codes: 200 (full or partial success), 400 (validation), 404 (company/territory not found), 422 (invalid level or parent), 500 (ERP error).
ERP mapping (GOAL → gproc.rutas): code, name, zone_code (parent L3 code), foreign_code (territory foreign_code or uuid), ubigeo_ruta, visit_day / customer_count / route_type from properties, status.
Adapter note: Full upsert (create + update) is implemented on SB1 Legacy adapter; SB1 10 adapter creates missing routes only.
POST /v1/sales/master/territories/sync-zones-to-erp)Exports one or more level-3 territory records (sales zones) from GOAL into the company SB1 database table gproc.zonas.
Mandatory Headers: same as sync routes.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
companyId |
integer | Yes | Company context |
territoryIds |
integer[] | Yes | GOAL territory IDs; each must be level = 3 with parent level = 2 (sub-región) |
Example request:
{
"companyId": 8,
"territoryIds": [11020, 11021]
}
Success response (200): same envelope as sync routes (created, updated, errors, details).
ERP mapping (minimal core → gproc.zonas): code, name, U_BKP_CODZON, U_BKP_NOMZON, U_BKP_ESTZON (status), division, sucursal, sub_region_id (from parent L2 code in gproc.sub_regions), colorPreference. Warehouse, series, and accounting columns are left to SB1 defaults until configured in ERP.
Adapter note: Full upsert on SB1 Legacy; SB1 10 returns per-row “not supported” errors.
POST /v1/sales/master/territories/{id}/copy-children)[!TIP]
Generación Automática de Códigos (Sequence):
Cuandocode,code_prefixycode_suffixse omiten durante la copia o creación de un territorio, el backend utiliza la plantilla de secuencia particionada de la entidadTERRITORY. Dicha secuencia toma el prefijo fijo'R', particiona por el código del territorio padre (parent.code), y genera un correlativo de 2 dígitos (ej.RTAY501,RTAY502para un padre con códigoTAY5).
Copies child territories from a source territory of the same level (level < 4) to the target territory ({id}). Supports customizable code/name prefixes and suffixes, individual custom mappings, optional GIS polygon cloning (paths, draft_paths, centroids), and recursive duplication for multi-tier branch hierarchies.
Mandatory Headers:
Authorization: Bearer <token>x-app-stage: <stage>x-app-uid: <uid>Path Parameters:
id (integer, required): Target parent territory ID receiving the copied children. Must have level < 4.Request Body Schema:
| Field | Type | Required | Description |
|---|---|---|---|
company_id |
integer | Yes | Target company ID. |
source_territory_id |
integer | Yes | Source territory ID to copy children from. Must match target.level. |
child_ids |
array[int] | No | Specific child IDs to copy. If omitted, copies all active children. |
code_prefix |
string | No | Prefix prepended to copied child codes (e.g. Z1-). |
code_suffix |
string | No | Suffix appended to copied child codes (e.g. -A). |
name_prefix |
string | No | Prefix prepended to copied child names. |
name_suffix |
string | No | Suffix appended to copied child names (e.g. (Zona Norte)). |
custom_mappings |
array[object] | No | Explicit mapping objects: [{"source_id": 12, "code": "R-101", "name": "Ruta 101"}]. |
copy_polygons |
boolean | No | Whether to copy GeoJSON/GIS polygon boundaries (paths, draft_paths). Default: true. |
recursive |
boolean | No | Whether to recursively copy sub-children (for L1/L2 territories). Default: false. |
Request Example:
{
"company_id": 8,
"source_territory_id": 4120,
"child_ids": [4121, 4122],
"code_prefix": "Z2-",
"name_suffix": " (Zona 2)",
"copy_polygons": true,
"recursive": false
}
Success Response (201 Created):
{
"success": true,
"code": 201,
"message": "Se copiaron 2 territorios hijos correctamente a ZONA SUR 2.",
"data": [
{
"id": 4250,
"company_id": 8,
"level": 4,
"parent_id": 4150,
"code": "Z2-R01",
"name": "Ruta 01 (Zona 2)",
"status": "A",
"color": "#336699"
}
]
}
HTTP Status Codes:
201 Created: Children copied successfully.400 Bad Request: Validation failure on request body.401 Unauthorized: Missing or invalid bearer token.403 Forbidden: Insufficient permissions.404 Not Found: Target or source territory not found.422 Unprocessable Entity: Source and target level mismatch, target level is 4, or duplicate code/name collision.500 Internal Server Error: Unhandled database exception./v1/sales/master/delivery-zones)Bridges commercial sales territories to physical warehouse delivery planning, route dispatch, and BEES delivery windows v2.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/delivery-zones |
List delivery zones |
POST |
/v1/sales/master/delivery-zones |
Create delivery zone |
GET |
/v1/sales/master/delivery-zones/config |
Retrieve delivery zone configuration parameters |
POST |
/v1/sales/master/delivery-zones/bootstrap-from-territories |
Bootstrap L3 CUSTOM delivery zones from sales territories |
POST |
/v1/sales/master/delivery-zones/generate-for-children |
Automatically generate L4 dispatch routes for child zones |
GET |
/v1/sales/master/delivery-zones/trasheds |
List soft-deleted delivery zones |
GET |
/v1/sales/master/delivery-zones/{id} |
Show delivery zone details |
PUT |
/v1/sales/master/delivery-zones/{id} |
Update delivery zone |
DELETE |
/v1/sales/master/delivery-zones/{id} |
Soft delete delivery zone |
PUT |
/v1/sales/master/delivery-zones/{id}/restore |
Restore soft-deleted zone |
GET |
/v1/sales/master/delivery-zones/{id}/route-planning |
Get route planning calendar and schedules |
PUT |
/v1/sales/master/delivery-zones/{id}/route-planning |
Synchronize route planning matrix and delivery windows |
GET |
/v1/sales/master/delivery-zones/{id}/child-routes |
Retrieve active child delivery routes |
/v1/sales/master/sales-zones)Macro sales grouping zones connecting branches to territories.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/sales-zones |
List sales zones |
POST |
/v1/sales/master/sales-zones |
Create sales zone |
GET |
/v1/sales/master/sales-zones/simple-list-with-like-filter |
Fast lookup filter for UI selectors |
GET |
/v1/sales/master/sales-zones/list-by-supplier |
Filter zones assigned to specific suppliers |
GET |
/v1/sales/master/sales-zones/config |
Configuration attributes |
GET |
/v1/sales/master/sales-zones/trasheds |
List soft-deleted zones |
GET |
/v1/sales/master/sales-zones/{id} |
Show sales zone |
PUT |
/v1/sales/master/sales-zones/{id} |
Update sales zone |
DELETE |
/v1/sales/master/sales-zones/{id} |
Delete sales zone |
PUT |
/v1/sales/master/sales-zones/{id}/restore |
Restore sales zone |
GET |
/v1/sales/master/sales-zones/{id}/children |
Child zones |
/v1/sales/master/sales-teams)Primary commercial unit representing a sales force, pre-sale team, or wholesale distributor unit.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/sales-teams |
Paginated listing of sales teams |
POST |
/v1/sales/master/sales-teams |
Create a sales team |
GET |
/v1/sales/master/sales-teams/simple-list-with-like-filter |
Fast autocomplete list |
GET |
/v1/sales/master/sales-teams/list-by-supplier |
Filter teams by commercial supplier |
GET |
/v1/sales/master/sales-teams/config |
Configuration parameters |
GET |
/v1/sales/master/sales-teams/trasheds |
List soft-deleted teams |
GET |
/v1/sales/master/sales-teams/{id} |
Retrieve sales team details |
PUT |
/v1/sales/master/sales-teams/{id} |
Update sales team |
DELETE |
/v1/sales/master/sales-teams/{id} |
Delete sales team |
PUT |
/v1/sales/master/sales-teams/{id}/restore |
Restore sales team |
GET |
/v1/sales/master/sales-teams/{id}/children |
Child teams |
POST |
/v1/sales/master/sales-teams/{id}/upload-image |
Upload team logo or banner image |
GET |
/v1/sales/master/sales-teams/{id}/sales-team |
Sub-teams by parent ID |
GET |
/v1/sales/master/sales-teams/{id}/channels |
List assigned customer channels |
POST |
/v1/sales/master/sales-teams/{id}/channels |
Associate channel to sales team |
GET |
/v1/sales/master/sales-teams/{id}/zones |
List associated sales zones |
GET |
/v1/sales/master/sales-teams/{id}/groups |
List associated customer groups |
GET |
/v1/sales/master/sales-teams/{id}/territories |
List territories covered by this team |
GET |
/v1/sales/master/sales-teams/{id}/territories-with-polygons |
List territories with full GIS polygons |
GET |
/v1/sales/master/sales-teams/{id}/portfolios |
List commercial portfolios under this team |
GET |
/v1/sales/master/sales-teams/{id}/sellers |
List sellers assigned to this team's portfolios |
GET |
/v1/sales/master/sales-teams/{id}/routes |
List scheduled portfolio routes |
GET |
/v1/sales/master/sales-teams/{id}/prices |
List team-specific price lists |
POST |
/v1/sales/master/sales-teams/{id}/prices |
Attach price list to sales team |
DELETE |
/v1/sales/master/sales-teams/{id}/prices/{priceId} |
Detach price list from sales team |
POST |
/v1/sales/master/sales-teams/{id}/prices/autofill |
Autofill missing price list lines from defaults |
GET |
/v1/sales/master/sales-teams/{id}/products |
List materialized products for the team (catalog merge + manual) |
POST |
/v1/sales/master/sales-teams/{id}/products |
Manually add a product to the team assortment |
DELETE |
/v1/sales/master/sales-teams/{id}/products/{productId} |
Deactivate a manual product on the team assortment (422 when inclusion_type=catalog) |
GET |
/v1/sales/master/sales-teams/{id}/catalog/assortment-suppliers |
Distinct suppliers from active materialized assortment (read-only master-data drill-down) |
POST |
/v1/sales/master/sales-teams/{id}/catalog/sync-products |
Materialize catalog assignments by scope or full team orchestration |
GET |
/v1/sales/master/sales-teams/{id}/catalog/dimension-stats |
Scoped KPI snapshot and dimension breakdown (kpi-db) |
GET |
/v1/sales/master/sales-teams/{id}/catalog/dimension-products |
Products in scoped assortment for a dimension value (drill-down) |
GET |
/v1/sales/master/sales-teams/{id}/catalog/sync-status |
Per-scope KPI status for a full-sync build_token |
GET /v1/sales/master/sales-teams/{id}/portfolios)Query: companyId (required); optional view (A | I | ALL | D, default A); group_id (single sales team group); sales_team_group_ids (comma-separated group ids, ignored when both are sent and sales_team_group_ids is non-empty).
Success (200): collection of PortfolioResource rows (code, name, seller_name, sales_team_group_name, territory_name, customer_channel_name, assigned, seller_assigned_at, status, color, …). Omit group_id / sales_team_group_ids to return all portfolios for the team (subject to view). Used by sales team Asig. Cartera (read-only) and portfolio management UI.
When sales_teams.inherit_parent_catalog = true for a child with a top-level parent:
sales_team_id (effective_catalog_sales_team_id); each row may include inherited_from_parent: true.POST/PUT/DELETE on sales-team-product-catalogs, POST …/sales-teams/{id}/catalog/sync-products) return 422 on the inheriting child. Row-level POST …/sales-team-product-catalogs/{id}/sync-products also rejects when viewing_sales_team_id in the body/query refers to an inheriting child.sales_team_products on the child are updated when the parent syncs (including cascade from SyncSalesTeamCatalogFullAction).POST /v1/sales/master/sales-teams/{id}/catalog/sync-products)Requires one or more active rows in sales_team_product_catalogs linking the team to inventory product_catalogs with catalog_type = sales_team.
Inheriting child: returns 422 if {id} is a team with inherit_parent_catalog = true.
Query: companyId (required)
Body (optional):
| Field | Type | Default | Description |
|---|---|---|---|
mode |
string | — | When full, runs global sync plus every active group (see below) |
async |
boolean | true when mode=full |
Enqueue SyncSalesTeamCatalogFullJob and return 202 |
catalog_scope_level |
string | global |
global | dc | zone when mode is omitted |
branch_id |
integer | — | Required when catalog_scope_level=dc |
sales_team_group_id |
integer | — | Required when catalog_scope_level=zone |
rebuild_lines |
boolean | false |
Re-run BuildProductCatalogLinesAction per assigned catalog when true or when lines are empty |
prune_removed |
boolean | true |
Deactivate catalog-sourced rows no longer in the merged set |
Full sync (mode=full, async=1) — Success (202):
{
"success": true,
"message": "Sincronización completa en cola.",
"data": {
"async": true,
"build_token": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"queue_id": 9012,
"scopes": [
{ "catalog_scope_level": "global", "branch_id": null, "sales_team_group_id": null }
]
}
}
Before dispatching the job, all rows in kpi-db sales_team_catalog_scope_snapshots for the team are set to stats_status=pending with the same build_token. After materialization completes, EnqueueSalesTeamCatalogScopeDimensionStatsAction::enqueueAllForTeam rebuilds scoped dimension stats.
Scoped sync (no mode=full) — Success (200): returns merge counters (catalogs_processed, total_active, …). Enqueues KPI rebuild for that scope only (async on kpi-db).
Only products with products.status = A and products.for_sale = Y are included. Manual rows (inclusion_type = manual) are not pruned.
GET /v1/sales/master/sales-teams/{id}/products)Query: companyId (required); optional view, pagination, search, and sort per SalesTeamProduct list rules.
Success (200): each row includes master-data fields for UI links: product_uuid, code, name, supplier_id, supplier_code, supplier_name, supplier_uuid, provider_name (alias of supplier_name), catalog_managed (boolean, true when inclusion_type=catalog), inherited_from_parent_team (boolean, row materialized on the effective catalog parent while viewing an inheriting child), read_only (boolean, catalog-managed or inherited from parent), and inclusion_type (catalog | manual).
When the viewing team has inherit_parent_catalog=true, the list aggregates active rows from the child and its effective catalog parent (effective_catalog_sales_team_id), deduping by product_id (child row wins when both exist).
GET /v1/sales/master/sales-teams/{id}/catalog/assortment-suppliers)Query: companyId (required)
Success (200):
{
"success": true,
"data": {
"sales_team_id": 12,
"inherits_parent_catalog": true,
"source_sales_team_ids": [12, 5],
"total": 3,
"items": [
{
"id": 10,
"code": "PRV001",
"name": "Proveedor Ejemplo S.A.C.",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"status": "A",
"product_count": 85
}
]
}
}
Distinct active suppliers derived from sales_team_products joined to products.supplier_id. For inheriting children, supplier counts include the child's and parent's materialized assortment (source_sales_team_ids). Used by the sales team Proveedores tab (read-only links to purchases supplier master).
GET /v1/sales/master/sales-teams/{id}/catalog/sync-status)Query: companyId (required), build_token (required)
Success (200): data.scopes[] with catalog_scope_level, optional branch_id / sales_team_group_id, and stats_status (pending | processing | ready | failed).
GET /v1/sales/master/sales-teams/{id}/catalog/dimension-stats)Query: companyId (required); for non-global scopes also catalog_scope_level, and branch_id (when dc) or sales_team_group_id (when zone). Omitting scope params returns global scope (legacy path may fall back to sales_team_catalog_snapshots until cutover).
Success (200):
{
"success": true,
"data": {
"snapshot": {
"active_product_count": 417,
"catalogs_assigned": 2,
"stats_status": "ready",
"stats_built_at": "2026-11-17T12:00:00Z"
},
"dimensions": {
"supplier": [{ "dimension_id": 10, "product_count": 120 }],
"brand": [{ "dimension_id": 5, "product_count": 80 }]
},
"scope": {
"catalog_scope_level": "global",
"winning_level": "global",
"branch_id": null,
"sales_team_group_id": null
}
}
}
KPI tables (kpi-db): sales_team_catalog_scope_snapshots, sales_team_scope_dimension_stats (per scope). Legacy sales_team_catalog_snapshots / sales_team_dimension_stats remain for one release.
GET /v1/sales/master/sales-teams/{id}/catalog/dimension-products)Query: companyId (required); same scope params as dimension-stats; plus dimension_type, dimension_id; optional limit (max 500), offset.
Success (200): data.items[] with product_id, code, name, table_code, and data.total.
Ops: php artisan sales-team:manage sync-catalog-full -c {companyId} -t {teamId}; php artisan sales-team:manage sync-product-measures -c {companyId} [-t {teamId}] [--group={groupId}] [--product={productId}] [--no-prune] [--json]; php artisan sales-team:manage rebuild-catalog-scope-stats -c {companyId} -t {teamId} [--scope=global|dc|zone] [--branch=] [--group=].
/v1/sales/master/business-types)Customer trade categories (e.g. Bodega, Minimarket, Restaurante, Mayorista).
GET /v1/sales/master/business-types: List business typesPOST /v1/sales/master/business-types: Create business typeGET /v1/sales/master/business-types/with-children: Tree view with child classificationsGET /v1/sales/master/business-types/config: Configuration metadataGET /v1/sales/master/business-types/trasheds: List soft-deleted typesGET /v1/sales/master/business-types/{id}: Show detailsPUT /v1/sales/master/business-types/{id}: UpdateDELETE /v1/sales/master/business-types/{id}: Soft deletePUT /v1/sales/master/business-types/{id}/restore: RestoreGET /v1/sales/master/business-types/{id}/children: Child business typesGET /v1/sales/master/business-types/{id}/business-types: Sub-types by parent ID/v1/sales/master/portfolios)Represents an operational commercial portfolio (client route book).
GET /v1/sales/master/portfolios: List portfoliosPOST /v1/sales/master/portfolios: Create portfolioGET /v1/sales/master/portfolios/trasheds: List soft-deletedGET /v1/sales/master/portfolios/{id}: Show portfolioPUT /v1/sales/master/portfolios/{id}: Update portfolioDELETE /v1/sales/master/portfolios/{id}: Delete portfolioPUT /v1/sales/master/portfolios/{id}/restore: Restore portfolioPOST /v1/sales/master/portfolios/{id}/assign: Assign seller to portfolio
{"seller_id": 42}POST /v1/sales/master/portfolios/{id}/unassign: Unassign seller from portfolio/v1/sales/master/portfolio-assignments)Engine for allocating business partners to portfolios.
GET /v1/sales/master/portfolio-assignments: List customer assignmentsPOST /v1/sales/master/portfolio-assignments: Create assignmentGET /v1/sales/master/portfolio-assignments/trasheds: Trashed assignmentsGET /v1/sales/master/portfolio-assignments/reports/assigned-unassigned: Summary report of covered vs unassigned clientsGET /v1/sales/master/portfolio-assignments/assignable-customers: Query clients available for portfolio assignmentGET /v1/sales/master/portfolio-assignments/customers-in-portfolios: Query clients currently allocated to portfoliosPOST /v1/sales/master/portfolio-assignments/assign-customers: Bulk assign customers to portfolio
{"portfolio_id": 12, "customer_ids": [101, 102, 105]}POST /v1/sales/master/portfolio-assignments/unassign-customers: Bulk remove customers from portfolio
{"portfolio_id": 12, "customer_ids": [101, 102]}GET /v1/sales/master/portfolio-assignments/{id}: Show assignmentPUT /v1/sales/master/portfolio-assignments/{id}: Update assignmentDELETE /v1/sales/master/portfolio-assignments/{id}: Remove assignmentPUT /v1/sales/master/portfolio-assignments/{id}/restore: Restore assignment/v1/sales/master/portfolio-schedules)Weekly calendar schedules (Lunes, Martes, etc.) determining visit frequency.
GET /v1/sales/master/portfolio-schedules: List schedulesPOST /v1/sales/master/portfolio-schedules: Create scheduleGET /v1/sales/master/portfolio-schedules/trasheds: Trashed schedulesGET /v1/sales/master/portfolio-schedules/reports/routes-today: Real-time report of active routes scheduled for todayGET /v1/sales/master/portfolio-schedules/{id}: Show schedulePUT /v1/sales/master/portfolio-schedules/{id}: Update scheduleDELETE /v1/sales/master/portfolio-schedules/{id}: Delete schedulePUT /v1/sales/master/portfolio-schedules/{id}/restore: Restore schedulePUT /v1/sales/master/portfolio-schedules/{id}/reassign: Reassign schedule to another portfolio or day
{"new_portfolio_id": 15, "day_of_week": 2}/v1/sales/master/sellers)Commercial sales representatives, field agents, and supervisors.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/sellers |
List sellers |
POST |
/v1/sales/master/sellers |
Create seller |
GET |
/v1/sales/master/sellers/trasheds |
Trashed sellers |
GET |
/v1/sales/master/sellers/{id} |
Show seller profile |
PUT |
/v1/sales/master/sellers/{id} |
Update seller |
DELETE |
/v1/sales/master/sellers/{id} |
Delete seller |
PUT |
/v1/sales/master/sellers/{id}/restore |
Restore seller |
GET |
/v1/sales/master/sellers/{id}/portfolios |
Portfolios assigned to seller |
GET |
/v1/sales/master/sellers/{id}/customers |
Customers covered by seller's portfolios |
GET |
/v1/sales/master/sellers/{id}/products |
Assortment catalog of products seller can sell |
GET |
/v1/sales/master/sellers/{id}/territories |
Geographic territories covered by seller |
GET |
/v1/sales/master/sellers/{id}/territories-with-polygons |
Territories with GeoJSON boundaries |
GET |
/v1/sales/master/sellers/{id}/orders |
Historical sales orders taken by seller |
GET |
/v1/sales/master/sellers/{id}/non-orders |
Non-order visit reports (e.g. Local Cerrado, Stock Lleno) |
/v1/sales/master/sales-routes):
GET /, POST /, GET /trasheds, GET /{id}, PUT /{id}, DELETE /{id}, PUT /{id}/restore./v1/sales/master/sales-schedules):
GET /, POST /, GET /trasheds, POST /seed, GET /{id}, PUT /{id}, DELETE /{id}, PUT /{id}/restore.POST /seed: Upserts canonical Mon–Sat catalog rows for the company (SeedCompanySalesSchedulesAction). Query/body: companyId (required), optional dry_run (boolean, default false). Response data: sync counters (created, updated, total, …).Determines which SKUs and product lines a sales team is authorized to commercialize.
| Endpoint Prefix | Description |
|---|---|
/v1/sales/master/sales-team-product-catalogs |
Pivot assignments: catalog_scope_level + sales_team_id + optional branch_id / sales_team_group_id + product_catalog_id (inheriting child teams return parent assignments read-only and reject writes with 422) |
/v1/sales/master/sales-team-group-product-measures |
Per-group sellable product presentations (for_sale, mobile_app, web_app); see sales-team-group-product-measures.md |
/v1/sales/master/sales-teams-catalogs-excludes |
Product exclusions scoped by sales_team_id (source_type e.g. PRODUCT); inheriting children receive parent active exclusions by default (inherited_from_parent, parent_exclude_id) and can inactivate inherited rows or add custom exclusions |
/v1/sales/master/sales-teams-catalogs-suppliers |
Supplier filter rules scoped by sales_team_id |
sales_teams.inherit_parent_catalog (boolean, default false) enables a child team (parent_id set on a top-level parent) to inherit its parent's global / matching dc catalog assignments and default exclusions.SyncSalesTeamCatalogFullAction / SyncSalesTeamCatalogFullJob / sales-team:manage sync-catalog-full) automatically cascades to all active inheriting children, materializing each child's sales_team_products, sales_team_group_products, and sales_team_group_product_measures.SalesTeam inheritance toggle, SalesTeamProductCatalog, SalesTeamCatalogExclude, or SalesTeamGroup branch_id/status) automatically dispatches DispatchSalesTeamCatalogSyncAction.All three resources support standard CRUD: GET /, POST /, GET /trasheds, GET /{id}, PUT /{id}, DELETE /{id}, PUT /{id}/restore.
/v1/sales/master/sales-team-product-catalogs)| Method | Path | Description |
|---|---|---|
GET |
/ |
List assignments; filter sales_team_id, catalog_scope_level, branch_id, sales_team_group_id, product_catalog_id, view, search; optional context_branch_id / context_sales_team_group_id for is_effective_for_context |
POST |
/ |
Create assignment; catalog_scope_level required (global | dc | zone); sync_products (default true) |
GET |
/available-catalogs |
Active inventory catalogs with catalog_type = sales_team |
POST |
/{id}/sync-products |
Rebuild lines for that catalog; refresh sales_team_products or sales_team_group_products by scope |
GET/PUT/DELETE/restore |
/{id} |
Standard row lifecycle |
Query: companyId (required on list/create/sync). sales_team_id accepts numeric id or team UUID.
List filters:
| Query | Effect |
|---|---|
view=A (default) |
Active assignments only |
view=I |
Inactive only |
view=ALL |
Active + inactive; excludes soft-deleted rows |
view=D |
Soft-deleted only (GET /trasheds equivalent) |
catalog_scope_level |
Filter list by scope: global, dc, or zone |
branch_id |
Filter DC-scope rows for a branch |
sales_team_group_id |
Filter zone-scope rows for a group |
Scope levels (override rule): If active assignments exist at a higher level for a sales context, lower-level assignments are ignored for assortment resolution (no cross-level merge).
| Level | catalog_scope_level |
Required fields |
|---|---|---|
| Global | global |
sales_team_id |
| CD / sucursal | dc |
sales_team_id, branch_id |
| Zona (grupo) | zone |
sales_team_id, sales_team_group_id |
Create examples:
{
"company_id": 8,
"sales_team_id": 42,
"catalog_scope_level": "global",
"product_catalog_id": 55,
"status": "A",
"sync_products": true
}
{
"company_id": 8,
"sales_team_id": 42,
"catalog_scope_level": "zone",
"sales_team_group_id": 7,
"product_catalog_id": 55,
"status": "A",
"sync_products": true
}
Update / status: PUT /{id} accepts status and optional sync_products: true. Scope fields are immutable after create.
Materialization:
sales_team_products: merged SKUs from global scope assignments only (POST …/catalog/sync-products?catalog_scope_level=global).sales_team_group_products: per-group merged SKUs resolved by ResolveSalesTeamCatalogAssignments (global wins over DC; DC wins over zone for that group’s branch).Team catalog endpoints (/v1/sales/master/sales-teams):
| Method | Path | Description |
|---|---|---|
GET |
/{id}/catalog/effective-scope |
Query branch_id, sales_team_group_id — returns winning_level, blocked_lower_levels, assignments_count |
POST |
/{id}/catalog/sync-products |
Scoped sync or mode=full (+ async, default true) |
GET |
/{id}/catalog/dimension-stats |
Scoped KPI (catalog_scope_level, optional branch_id / sales_team_group_id) |
GET |
/{id}/catalog/sync-status |
build_token from async full sync |
KPI: After any materialization path, EnqueueSalesTeamCatalogScopeDimensionStatsAction queues scoped rebuilds on kpi-db. Full sync batches all scopes in one RebuildSalesTeamCatalogScopeDimensionStatsJob.
/v1/sales/master/sales-team-groups)| Method | Path | Description |
|---|---|---|
POST |
/{id}/catalog/sync-products |
Rebuild merged assortment for that group into sales_team_group_products |
GET |
/{id}/products |
List materialized products for the group |
Creating, updating, deleting, or restoring a pivot row triggers the appropriate scope sync when sync_products is enabled.
Excludes / suppliers list filter: GET ...?companyId={id}&sales_team_id={teamId}
Exclude create example:
{
"sales_team_id": 42,
"source_type": "PRODUCT",
"source_id": 1001,
"status": "A"
}
/v1/sales/master/sales-teams-channels): CRUD for team↔customer-channel linkages. PUT …/sales-teams-channels/{id}/set-default sets sales_teams.customer_channel_id to the link’s customer_channel_id (single default per team; row is_default on list compares to that field). Channel must be status=A./v1/sales/master/customer-channels): Master trade channel definitions (e.g. Tradicional, Moderno, Horeca)./v1/sales/master/order-sources): Commercial origin tagging (e.g. Presale Handheld, B2B Online Store, Televentas, WhatsApp)./v1/sales/master/sales-team-groups): Classification groups for sales teams./v1/sales/master/sales-team-prices): Attaches official price lists (price_lists) to sales teams./v1/sales/master/sales-team-customers)Maintains relational mappings between business partners and sales teams.
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/sales/master/sales-team-customers |
List customer-to-team links |
POST |
/v1/sales/master/sales-team-customers |
Create link |
GET |
/v1/sales/master/sales-team-customers/{id} |
Show link details |
PUT |
/v1/sales/master/sales-team-customers/{id} |
Update link |
POST |
/v1/sales/master/sales-team-customers/activate |
Activate relationship (status = 'A') |
POST |
/v1/sales/master/sales-team-customers/deactivate |
Deactivate relationship (status = 'I') |
POST |
/v1/sales/master/sales-team-customers/sync |
Synchronize customer-team relations with SAP B1 |