Crear varios insumos de una vez
POST /api/inventory-items/create-inventory-items
Descripción
Registra hasta 100 insumos nuevos en una sola llamada, con su código generado automáticamente.
Detalles
Valida todo el lote antes de guardar: si un solo insumo tiene un problema no se crea ninguno y la respuesta indica la posición y el campo de cada error. Las tres unidades de cada insumo deben ser de la misma dimensión. Permite una prueba previa que valida sin guardar nada.
Permisos requeridos
catalog.module
Request
| Nombre | Tipo | Requerido | Reglas |
|---|---|---|---|
| dryRun | bool | No |
default:0
|
| items | array | Sí | — |
| items[].ref | string | No |
max:60
|
| items[].name | string | Sí |
min:2
max:150
|
| items[].internalName | string | No |
max:150
|
| items[].description | string | No |
max:1000
|
| items[].categoryUuid | string | Sí |
min:36
max:36
|
| items[].unitId | int | Sí |
min_value:1
|
| items[].countingDefaultUnitId | int | Sí |
min_value:1
|
| items[].purchaseDefaultUnitId | int | Sí |
min_value:1
|
| items[].defaultConsumptionLocationId | int | Sí |
min_value:1
|
| items[].costCents | int | Sí |
min_value:0
|
| items[].reorderPoint | string | No |
decimal
min_value:0
default:0
|
| items[].isActive | int | No |
enum:0,1
default:1
|
Ejemplo de request
curl -X POST https://restofy.pro/api/inventory-items/create-inventory-items \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <accessToken>" \
-d '{
"items": [
{
"name": "string",
"categoryUuid": "string",
"unitId": 1,
"countingDefaultUnitId": 1,
"purchaseDefaultUnitId": 1,
"defaultConsumptionLocationId": 1,
"costCents": 1
}
]
}'
Los valores son demo: reemplázalos por datos reales del negocio.
Ejemplo de respuesta
Actualizado: 2026-10-09T02:12:12Z
HTTP 200
Request
{
"items": [
{
"name": "Tomate chonto 6ac84d3360899",
"categoryUuid": "9e49f91e-39f7-4043-b030-12e107c859a3",
"unitId": 9,
"countingDefaultUnitId": 9,
"purchaseDefaultUnitId": 9,
"defaultConsumptionLocationId": 4,
"costCents": 350000,
"ref": "tomate"
},
{
"name": "Cebolla cabezona 6ac84d3459817",
"categoryUuid": "47116d25-1f74-48b9-a08c-b08d9393dc3b",
"unitId": 9,
"countingDefaultUnitId": 9,
"purchaseDefaultUnitId": 9,
"defaultConsumptionLocationId": 4,
"costCents": 350000,
"ref": "cebolla"
}
]
}
Response
{
"success": true,
"message": "Insumos creados",
"data": {
"dryRun": false,
"items": [
{
"index": 0,
"ref": "tomate",
"inventoryItemId": 27,
"inventoryItemUuid": "692c908d-00be-4c04-8d45-c30ebe5e69b4"
},
{
"index": 1,
"ref": "cebolla",
"inventoryItemId": 28,
"inventoryItemUuid": "cb9bf118-7a55-41f8-964d-2725f1d18bd4"
}
]
}
}