The Classifications API (/v1/inventory/master/product-clasifications) structures catalog navigation for B2B/B2C storefronts, sales reps, and warehouse picking lines. It supports 4-level category trees (Class, Family, Subfamily, Line), autocomplete search, media tags, and a high-volume bulk import/upsert engine tailored for automation platforms like n8n, Zapier, ERP synchronizers, or custom webhooks.
/v1/inventory/master/product-clasificationsApp\Http\Controllers\V1\Backend\Inventory\Master\ProductClasificationControllerDomain\Inventory\Master\Clasification\BulkImportProductClasificationActionDomain\Inventory\Master\Clasification\SimpleListProductClasificationActionDomain\Inventory\Master\Clasification\UpdateProductClasificationImageCodesActionDomain\Inventory\Master\Clasification\GetClassificationByIdActionApp\Models\Inventory\Master\ProductClasification (product_clasifications)App\Models\Inventory\Master\ProductClasificationListItem (v_product_clasifications_list)Authorization: Bearer <jwt-token>
x-app-stage: <stage-identifier>
x-app-uid: <application-uuid>
Content-Type: application/json
Accept: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId |
integer |
Yes | Active operating company ID (company-validator). |
view |
string |
No | State filter: A (Active, default), I (Inactive), D (Trashed), ALL. |
| Method | Endpoint | Description |
|---|---|---|
GET |
/v1/inventory/master/product-clasifications |
Flat listing of root classifications with pagination and search |
GET |
/v1/inventory/master/product-clasifications/list-items |
Plain Mode Listing from read-only model ProductClasificationView (v_product_clasification) |
GET |
/v1/inventory/master/product-clasifications/plain-list |
Route alias for list-items |
GET |
/v1/inventory/master/product-clasifications/with-children |
Hierarchical recursive tree structure with nested children |
GET |
/v1/inventory/master/product-clasifications/autocomplete |
Fast predictive search for selectors and dropdowns |
GET |
/v1/inventory/master/product-clasifications/simple-list |
Lightweight list filtered by level for forms and pickers |
POST |
/v1/inventory/master/product-clasifications |
Create a single product classification |
GET |
/v1/inventory/master/product-clasifications/{id} |
Get classification details by ID |
PUT |
/v1/inventory/master/product-clasifications/{id} |
Update classification attributes |
DELETE |
/v1/inventory/master/product-clasifications/{id} |
Soft delete a classification |
PUT |
/v1/inventory/master/product-clasifications/{id}/restore |
Restore a soft-deleted classification |
POST |
/v1/inventory/master/product-clasifications/{id}/image-codes |
Assign or update gallery image codes |
GET |
/v1/inventory/master/product-clasifications/{id}/children |
Get direct child classifications |
POST |
/v1/inventory/master/product-clasifications/bulk-import |
Massive Import / Upsert from n8n, webhooks, or third-party tools |
POST |
/v1/inventory/master/product-clasifications/import |
Route alias for bulk-import |
POST /v1/inventory/master/product-clasifications/bulk-import
POST /v1/inventory/master/product-clasifications/import
This endpoint enables high-volume creation and updating (upsert) of product classifications from external integration engines such as n8n, Zapier, Make, AWS EventBridge, or batch CSV/Excel loaders.
level ASC (1 -> 2 -> 3 -> 4) to ensure parent nodes exist before child nodes are processed.parent_code):
id). They can reference parents using parent_code (e.g. parent_code: "01" for a family in level 2 whose parent is class "01" in level 1).(company_id, level, code) and (company_id, level, name).restore_trashed: true and incoming status: "A".v_product_clasifications_list is refreshed automatically, immediately updating frontend navigations without requiring artisan maintenance commands."dry_run": true to test a payload against unique constraints and parent linkages without writing any rows to PostgreSQL.The engine accepts JSON payloads in flexible formats:
items, clasifications, or data key.[ { ... }, { ... } ]).POST /v1/inventory/master/product-clasifications/bulk-import?companyId=10
Content-Type: application/json
{
"company_id": 10,
"dry_run": false,
"update_existing": true,
"restore_trashed": true,
"stop_on_error": false,
"items": [
{
"code": "01",
"name": "BEBIDAS Y REFRESCOS",
"level": 1,
"parent_code": null,
"status": "A",
"display_in_catalog": true,
"image_code": "img_cat_bebidas"
},
{
"code": "0101",
"name": "CERVEZAS",
"level": 2,
"parent_code": "01",
"status": "A",
"display_in_catalog": true
},
{
"code": "010101",
"name": "CERVEZAS NACIONALES RETORNABLES",
"level": 3,
"parent_code": "0101",
"status": "A",
"display_in_catalog": true
},
{
"code": "01010101",
"name": "CERVEZA CRISTAL 650ML",
"level": 4,
"parent_code": "010101",
"status": "A",
"display_in_catalog": true
}
]
}
| Field | Type | Default | Description |
|---|---|---|---|
company_id |
integer |
From query | Target operating company ID. |
dry_run |
boolean |
false |
When true, simulates the import, reports errors and statistics, but rolls back database changes. |
update_existing |
boolean |
true |
When true, updates attributes for existing (level, code) records. When false, skips them. |
restore_trashed |
boolean |
true |
When true, automatically restores previously deleted records if status is 'A'. |
stop_on_error |
boolean |
false |
When false, logs item errors and continues processing remaining items. When true, aborts on the first error. |
items |
array |
Required | Array of classification rows to create or update. |
| Attribute | Type | Required | Description |
|---|---|---|---|
code |
string |
Yes | Unique classification code within the level and company (max 20 characters). |
name |
string |
Yes | Descriptive name (max 255 characters, must be unique within level). |
level |
integer |
Recommended | Classification depth: 1 (Clase), 2 (Familia), 3 (Subfamilia), 4 (Línea). Defaults to 1 if root, otherwise 2. |
parent_code |
string |
No | Code of the parent classification. Recommended for automated n8n pipelines. |
parent_id |
integer |
No | Internal integer database ID of the parent classification. |
status |
string |
No | Record state: 'A' (Active), 'I' (Inactive), 'D' (Deleted). Default: 'A'. |
display_in_catalog |
boolean |
No | Toggle visibility in B2B storefront navigation. |
image_code |
string |
No | Gallery image identifier for desktop banners. |
image_code_mobile |
string |
No | Gallery image identifier for mobile apps. |
image_codes |
array |
No | Array of supplementary image code strings. |
use_in_companies |
array |
No | Array of integer company IDs allowed to use this classification. |
200 OK{
"success": true,
"message": "Importación masiva completada: 4 creados, 0 actualizados, 0 omitidos, 0 errores.",
"data": {
"total": 4,
"created": 4,
"updated": 0,
"skipped": 0,
"errors": 0,
"error_details": []
}
}
If some rows contained validation or constraint errors (and stop_on_error: false):
{
"success": true,
"message": "Importación masiva completada: 3 creados, 1 actualizados, 0 omitidos, 1 errores.",
"data": {
"total": 5,
"created": 3,
"updated": 1,
"skipped": 0,
"errors": 1,
"error_details": [
{
"index": 4,
"code": "09999",
"level": 3,
"error": "Clasificación padre con código '99' no encontrada."
}
]
}
}
product-clasifications-massAlternativa oficial al JSON de bulk-import para usuarios del Importador (POST /v1/importer/runs).
| Campo | Valor |
|---|---|
| Código plantilla | product-clasifications-mass |
| Ejecución | ImportTemplateExecutionRegistry → BulkImportProductClasificationsFromExcelAction |
| Empresa | company_id del runner (upsert solo en esa empresa) |
| Permiso ejecución | PRODUCT_CLASIFICATION → INSERT (UUID en plantilla) |
| Motor persistencia | Mismo BulkImportProductClasificationAction (JSON items) |
Columnas Excel (fila de datos = una línea nivel 4): class_code, class_name, family_code, family_name, subfamily_code, subfamily_name, line_code, line_name. Fila de ayuda opcional (template_has_comments).
Unicidad en archivo (antes de escribir): por nivel, cada code debe tener un solo name y un solo parent_code (familias–líneas). Si hay conflictos, no se persiste nada. En base de datos se mantiene unicidad (company_id, level, code) y (company_id, level, name).
Respuesta runner: arreglo por fila Excel (id, code = line_code, success, message).
Operaciones: php artisan goal:importer:seed-product-clasifications-template (opcional --company-ids=8).
Ver también: Plantilla product-clasifications-mass.
When configuring an HTTP Request node in n8n:
POSThttps://api.goal.pe/v1/inventory/master/product-clasifications/bulk-importcompanyId: ={{ $json.company_id }}Header Auth (Authorization: Bearer <token>)x-app-stage: {{ $env.APP_STAGE }}x-app-uid: {{ $env.APP_UID }}Content-Type: application/json{
"dry_run": false,
"update_existing": true,
"items": $json.categories.map(c => ({
"code": c.codigo,
"name": c.descripcion,
"level": c.nivel,
"parent_code": c.codigo_padre || null,
"status": c.activo ? "A" : "I",
"display_in_catalog": true
}))
}
GET /v1/inventory/master/product-clasifications/with-children
Returns root classifications (Level 1) with all recursive nested child branches.
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 1,
"company_id": 10,
"code": "01",
"name": "BEBIDAS Y REFRESCOS",
"level": 1,
"parent_id": null,
"has_children": true,
"children": [
{
"id": 2,
"company_id": 10,
"code": "0101",
"name": "CERVEZAS",
"level": 2,
"parent_id": 1,
"has_children": true,
"children": []
}
]
}
]
}
ProductClasificationView)GET /v1/inventory/master/product-clasifications/list-items
GET /v1/inventory/master/product-clasifications/plain-list
Retrieves a flat/plain listing of product classifications directly from the PostgreSQL materialized view v_product_clasification via the read-only model ProductClasificationView. Each record projects the flattened 4-level classification hierarchy (Class -> Family -> Subfamily -> Line) for the specified company.
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId |
integer |
Yes | Active operating company ID. |
view |
string |
No | State filter: A (Active, default), I (Inactive), ALL. Filters by line_status. |
class_id |
integer |
No | Filter by Class (Level 1) ID. |
family_id |
integer |
No | Filter by Family (Level 2) ID. |
subfamily_id |
integer |
No | Filter by Subfamily (Level 3) ID. |
line_id |
integer |
No | Filter by Line (Level 4) ID. |
search |
string |
No | Search text matching code or name across line, subfamily, family, or class. |
sort_field |
string |
No | Sorting column (Default: line_name). |
sort_type |
string |
No | asc (default) or desc. |
limit |
integer |
No | Maximum rows to return (Default: 10000). |
skip |
integer |
No | Rows offset for pagination. |
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": [
{
"id": 4,
"company_id": 10,
"line_id": 4,
"line_code": "01010101",
"line_name": "CERVEZA CRISTAL 650ML",
"line_status": "A",
"subfamily_id": 3,
"subfamily_code": "010101",
"subfamily_name": "CERVEZAS NACIONALES RETORNABLES",
"subfamily_status": "A",
"family_id": 2,
"family_code": "0101",
"family_name": "CERVEZAS",
"family_status": "A",
"class_id": 1,
"class_code": "01",
"class_name": "BEBIDAS Y REFRESCOS",
"class_status": "A"
}
]
}
GET /v1/inventory/master/product-clasifications/autocomplete
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId |
integer |
Yes | Company ID. |
search |
string |
No | Search string matching classification name or code. |
level |
integer |
No | Target level filter (e.g. 4 for line picking). |
POST /v1/inventory/master/product-clasifications
{
"code": "0102",
"name": "GASEOSAS Y SODA",
"level": 2,
"parent_id": 1,
"status": "A"
}
200 OK{
"success": true,
"message": "Proceso realizado correctamente",
"data": {
"id": 15,
"company_id": 10,
"code": "0102",
"name": "GASEOSAS Y SODA",
"level": 2,
"parent_id": 1,
"status": "A"
}
}
POST /v1/inventory/master/product-clasifications/{id}/image-codes
{
"field": "image_codes",
"image_code": ["banner_gaseosas_hero", "thumbnail_gaseosas_app"]
}
| Status Code | Meaning | Reason & Remediation |
|---|---|---|
401 Unauthorized |
Invalid / expired token | Provide a valid Bearer token in the Authorization header. |
403 Forbidden |
Access denied | User does not have authorization for the requested companyId. |
404 Not Found |
Resource not found | Classification {id} does not exist or belongs to another company. |
422 Unprocessable |
Validation failed | Missing required code or name, or invalid parent identifier. |
500 Server Error |
Execution error | Database connection failure or unhandled transaction exception. |