List All Products
Response
Example Request
curl -X GET https://api.example.com/producto \
-H "Content-Type: application/json"
Example Response
[
{
"id": 1,
"codigo": "PROD001",
"nombre": "Wireless Mouse",
"descripcion": "Ergonomic wireless mouse with USB receiver",
"cantidad": 50,
"precioVenta": 29.99,
"costoCompra": 15.00,
"estado": true,
"fechaCreacion": "2026-03-06T10:00:00",
"fechaActualizacion": "2026-03-06T10:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/prod001.jpg"
}
]
Get Product by ID
Path Parameters
The unique identifier of the product
Response
Returns a single product object with all fields.
Example Request
curl -X GET https://api.example.com/producto/1 \
-H "Content-Type: application/json"
Example Response
{
"id": 1,
"codigo": "PROD001",
"nombre": "Wireless Mouse",
"descripcion": "Ergonomic wireless mouse with USB receiver",
"cantidad": 50,
"precioVenta": 29.99,
"costoCompra": 15.00,
"estado": true,
"fechaCreacion": "2026-03-06T10:00:00",
"fechaActualizacion": "2026-03-06T10:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/prod001.jpg"
}
Error Responses
- 404 Not Found: Product with the specified ID does not exist
Search Product by Code
Path Parameters
The unique product code to search for
Response
Returns a single product object matching the code.
Example Request
curl -X GET https://api.example.com/producto/buscar/codigo/PROD001 \
-H "Content-Type: application/json"
Example Response
{
"id": 1,
"codigo": "PROD001",
"nombre": "Wireless Mouse",
"descripcion": "Ergonomic wireless mouse with USB receiver",
"cantidad": 50,
"precioVenta": 29.99,
"costoCompra": 15.00,
"estado": true,
"fechaCreacion": "2026-03-06T10:00:00",
"fechaActualizacion": "2026-03-06T10:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/prod001.jpg"
}
Error Responses
- 404 Not Found: No product found with the specified code
Create Product with Image
Content-Type: multipart/form-data
Product name (must be unique)
Product description (optional)
Available quantity in stock
ID of the category this product belongs to
Product image file (optional)
Response
Returns the created product object with auto-generated fields.
Example Request
curl -X POST https://api.example.com/producto/crear-con-imagen \
-H "Content-Type: multipart/form-data" \
-F "codigo=PROD002" \
-F "nombre=Mechanical Keyboard" \
-F "descripcion=RGB mechanical keyboard with blue switches" \
-F "cantidad=30" \
-F "precioVenta=89.99" \
-F "costoCompra=45.00" \
-F "categoriaId=1" \
-F "[email protected]"
Example Response
{
"id": 2,
"codigo": "PROD002",
"nombre": "Mechanical Keyboard",
"descripcion": "RGB mechanical keyboard with blue switches",
"cantidad": 30,
"precioVenta": 89.99,
"costoCompra": 45.00,
"estado": true,
"fechaCreacion": "2026-03-06T16:00:00",
"fechaActualizacion": "2026-03-06T16:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/uuid-keyboard.jpg"
}
Error Responses
- 500 Internal Server Error: Error processing the request or saving the image
Update Product
Path Parameters
The unique identifier of the product to update
Request Body
Updated product description
Updated category object with id
Response
Returns the updated product object.
Example Request
curl -X PUT https://api.example.com/producto/2 \
-H "Content-Type: application/json" \
-d '{
"codigo": "PROD002",
"nombre": "Mechanical Keyboard RGB",
"descripcion": "Premium RGB mechanical keyboard",
"cantidad": 25,
"precioVenta": 99.99,
"costoCompra": 45.00,
"estado": true,
"categoria": {
"id": 1
}
}'
Example Response
{
"id": 2,
"codigo": "PROD002",
"nombre": "Mechanical Keyboard RGB",
"descripcion": "Premium RGB mechanical keyboard",
"cantidad": 25,
"precioVenta": 99.99,
"costoCompra": 45.00,
"estado": true,
"fechaCreacion": "2026-03-06T16:00:00",
"fechaActualizacion": "2026-03-06T17:30:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/uuid-keyboard.jpg"
}
Error Responses
- 404 Not Found: Product with the specified ID does not exist
Update Product with Image
Path Parameters
The unique identifier of the product to update
Content-Type: multipart/form-data
Updated product description (optional)
New product image file (optional - if not provided, keeps existing image)
Response
Returns the updated product object with the new image path.
Example Request
curl -X PUT https://api.example.com/producto/2/actualizar-con-imagen \
-H "Content-Type: multipart/form-data" \
-F "codigo=PROD002" \
-F "nombre=Premium Mechanical Keyboard" \
-F "descripcion=Premium RGB mechanical keyboard with wrist rest" \
-F "cantidad=20" \
-F "precioVenta=119.99" \
-F "costoCompra=50.00" \
-F "estado=true" \
-F "categoriaId=1" \
-F "[email protected]"
Example Response
{
"id": 2,
"codigo": "PROD002",
"nombre": "Premium Mechanical Keyboard",
"descripcion": "Premium RGB mechanical keyboard with wrist rest",
"cantidad": 20,
"precioVenta": 119.99,
"costoCompra": 50.00,
"estado": true,
"fechaCreacion": "2026-03-06T16:00:00",
"fechaActualizacion": "2026-03-06T18:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/new-uuid-keyboard.jpg"
}
Error Responses
- 500 Internal Server Error: Error processing the request or saving the image
Update Product Quantity
Path Parameters
The unique identifier of the product
Request Body
Response
Returns the updated product object.
Example Request
curl -X PUT https://api.example.com/producto/2/cantidad \
-H "Content-Type: application/json" \
-d '15'
Example Response
{
"id": 2,
"codigo": "PROD002",
"nombre": "Premium Mechanical Keyboard",
"descripcion": "Premium RGB mechanical keyboard with wrist rest",
"cantidad": 15,
"precioVenta": 119.99,
"costoCompra": 50.00,
"estado": true,
"fechaCreacion": "2026-03-06T16:00:00",
"fechaActualizacion": "2026-03-06T19:00:00",
"categoria": {
"id": 1,
"nombre": "Electronics"
},
"imagen": "/images/new-uuid-keyboard.jpg"
}
Deactivate Product
Path Parameters
The unique identifier of the product to deactivate
Response
Returns a 200 OK status on success.
Example Request
curl -X PUT https://api.example.com/producto/2/desactivar \
-H "Content-Type: application/json"
Response
Error Responses
- 404 Not Found: Product with the specified ID does not exist
Delete Product
Path Parameters
The unique identifier of the product to delete
Response
Returns a 204 No Content status on success.
Example Request
curl -X DELETE https://api.example.com/producto/2 \
-H "Content-Type: application/json"
Response
This is a permanent deletion. Consider using the deactivate endpoint for soft deletes instead.
Image Handling
The catalog service supports image uploads for products through multipart/form-data requests.
Image Upload Details
- Images are uploaded as
multipart/form-data files
- The service generates unique filenames using UUIDs to prevent conflicts
- Images are stored in the server’s file system
- The
imagen field in the response contains the path/URL to the stored image
- When updating a product with a new image, the old image is replaced
Supported Endpoints
POST /producto/crear-con-imagen - Create product with image
PUT /producto/{id}/actualizar-con-imagen - Update product with new image
Best Practices
- Always use the
imagen parameter name for file uploads
- Image upload is optional - you can create/update products without images
- Supported image formats typically include JPG, PNG, and other common formats
- Consider implementing image size and format validation on the client side