Creating a product is a fully atomic operation. The controller opens a dedicated database connection and issues aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/MateoNavarroMN/Balsamoa-Backend/llms.txt
Use this file to discover all available pages before exploring further.
BEGIN statement before writing anything. The product row is inserted first into the productos table; if imagenes are provided, they are inserted into producto_imagenes one by one; if variantes are provided, they are inserted into the variantes table. Only when all writes succeed does the controller issue COMMIT. If any step fails — for example because a categoria_id, talle_id, or color_id does not exist — the connection is rolled back with ROLLBACK and no partial data is left in the database.
Request
Method:POSTPath:
/api/v1/admin/productosContent-Type:
application/json
Body Parameters
Product display name. Must be a non-empty string. Maximum 150 characters (enforced by the database column definition).
Optional free-text product description. Stored as
TEXT in PostgreSQL; no length limit is enforced at the API level.Product price in Argentine Pesos (ARS). Must be a positive number greater than zero. Stored as
DECIMAL(10,2).ID of the product category. Must reference an existing row in the
categorias table. Retrieve valid IDs from GET /api/v1/admin/categorias. Current seed values: 1 (Hoodie), 2 (Remera).Whether to mark this product as featured. Defaults to
false if omitted. Featured products appear in highlighted sections of the storefront.Whether the product should be immediately visible in the public store. Defaults to
true if omitted. Set to false to create a product in draft state.Optional array of image objects to associate with the product. Each element must have a
url field. Upload images first using POST /api/v1/admin/imagenes/subir and include the returned URL here.Optional array of size/color/stock combinations. Each combination must include
talle_id and color_id, which must reference existing rows in their respective tables. The combination of (producto_id, talle_id, color_id) must be unique per product — duplicate combinations in this array will cause the transaction to fail.Example Request Body
Response
201 — Created
Returns amensaje string and a producto object containing the row inserted into the productos table (the output of RETURNING *). Note that the returned producto is the raw table row, not the enriched view object — it does not include imagenes, variantes, or stock_total. Use GET /api/v1/admin/productos/:id to retrieve the full denormalized record after creation.
Human-readable confirmation string.
The raw row inserted into
productos as returned by PostgreSQL’s RETURNING *. Contains id, nombre, descripcion, precio, categoria_id, destacado, activo, and fecha_creacion. Does not include joined or aggregated fields from the view.Error Cases
| Status | Condition | Response body |
|---|---|---|
400 | nombre is missing or empty | {"mensaje": "El nombre es obligatorio y debe ser un texto válido"} |
400 | precio is missing, non-numeric, or ≤ 0 | {"mensaje": "El precio es obligatorio y debe ser un número positivo"} |
400 | categoria_id is missing or non-numeric | {"mensaje": "La categoría (categoria_id) es obligatoria y debe ser un número"} |
400 | imagenes is not an array | {"mensaje": "El campo \"imagenes\" debe ser un arreglo"} |
400 | An image object is missing its url | {"mensaje": "Cada imagen debe tener un campo \"url\" válido"} |
400 | variantes is not an array | {"mensaje": "El campo \"variantes\" debe ser un arreglo"} |
400 | A variant is missing talle_id or color_id | {"mensaje": "Cada variante debe tener obligatoriamente \"talle_id\" y \"color_id\""} |
400 | A variant’s stock is negative | {"mensaje": "El stock de cada variante debe ser un número no negativo"} |
400 | categoria_id, talle_id, or color_id does not exist in its table (PostgreSQL error 23503) | {"mensaje": "Error de consistencia: La categoría, talle o color especificado no existen"} |
500 | Unexpected database or server error | {"mensaje": "Error interno en el servidor al intentar crear el producto"} |