curl --request POST \
--url https://api.example.com/api/products \
--header 'Content-Type: application/json' \
--data '
{
"nombre": "<string>",
"descripcion": "<string>",
"precio": 123,
"precioOriginal": 123,
"stock": 123,
"categoriaId": 123,
"marcaId": 123,
"peso": 123,
"alto": 123,
"ancho": 123,
"profundidad": 123,
"isFeatured": true
}
'{
"success": true,
"data": {
"id": 123,
"nombre": "<string>",
"descripcion": "<string>",
"precio": 123,
"precioOriginal": 123,
"stock": 123,
"foto": "<string>",
"isFeatured": true,
"peso": 123,
"alto": 123,
"ancho": 123,
"profundidad": 123,
"categoriaId": 123,
"marcaId": 123,
"createdAt": {},
"updatedAt": {}
}
}Create a new product in the catalog
curl --request POST \
--url https://api.example.com/api/products \
--header 'Content-Type: application/json' \
--data '
{
"nombre": "<string>",
"descripcion": "<string>",
"precio": 123,
"precioOriginal": 123,
"stock": 123,
"categoriaId": 123,
"marcaId": 123,
"peso": 123,
"alto": 123,
"ancho": 123,
"profundidad": 123,
"isFeatured": true
}
'{
"success": true,
"data": {
"id": 123,
"nombre": "<string>",
"descripcion": "<string>",
"precio": 123,
"precioOriginal": 123,
"stock": 123,
"foto": "<string>",
"isFeatured": true,
"peso": 123,
"alto": 123,
"ancho": 123,
"profundidad": 123,
"categoriaId": 123,
"marcaId": 123,
"createdAt": {},
"updatedAt": {}
}
}POST /api/products
ADMIN role can create products.
Content-Type: multipart/form-data
Authorization: Bearer <access_token>
multipart/form-data to support image upload.
curl -X POST "https://api.pcfix.com/api/products" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-F "nombre=Gaming Mouse Pro" \
-F "descripcion=High-precision gaming mouse with RGB lighting and customizable buttons" \
-F "precio=79.99" \
-F "stock=50" \
-F "categoriaId=8" \
-F "marcaId=3" \
-F "peso=0.15" \
-F "alto=5" \
-F "ancho=8" \
-F "profundidad=12" \
-F "isFeatured=true" \
-F "foto=@/path/to/mouse-image.jpg"
{
"success": true,
"data": {
"id": 42,
"nombre": "Gaming Mouse Pro",
"descripcion": "High-precision gaming mouse with RGB lighting and customizable buttons",
"precio": "79.99",
"precioOriginal": null,
"stock": 50,
"foto": "https://cdn.pcfix.com/uploads/mouse-image-1234567890.jpg",
"isFeatured": true,
"peso": "0.15",
"alto": 5,
"ancho": 8,
"profundidad": 12,
"categoriaId": 8,
"marcaId": 3,
"createdAt": "2024-03-05T10:30:00Z",
"updatedAt": "2024-03-05T10:30:00Z"
}
}
{
"success": false,
"error": "Datos inválidos",
"details": [
{
"field": "nombre",
"message": "El nombre debe tener al menos 3 caracteres"
},
{
"field": "precio",
"message": "El precio debe ser positivo"
}
]
}
{
"success": false,
"error": "Unauthorized - Admin access required"
}
{
"success": false,
"error": "Error message description"
}