> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/martin-ratti/PCFIX-Baru/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Product

> Update an existing product's information

## Endpoint

```
PUT /api/products/:id
```

## Authentication

**Admin access required.** Only users with the `ADMIN` role can update products.

## Path Parameters

<ParamField path="id" type="number" required>
  The unique identifier of the product to update
</ParamField>

## Request Headers

```
Content-Type: multipart/form-data
Authorization: Bearer <access_token>
```

## Request Body

This endpoint accepts `multipart/form-data` to support image upload. All fields are optional - only include fields you want to update.

<ParamField body="nombre" type="string">
  Product name (minimum 3 characters)
</ParamField>

<ParamField body="descripcion" type="string">
  Product description (minimum 10 characters)
</ParamField>

<ParamField body="precio" type="number">
  Product price (must be positive)
</ParamField>

<ParamField body="precioOriginal" type="number">
  Original price (for displaying discounts)
</ParamField>

<ParamField body="stock" type="number">
  Stock quantity (must be non-negative integer)
</ParamField>

<ParamField body="categoriaId" type="number">
  Category ID to associate with this product
</ParamField>

<ParamField body="marcaId" type="number">
  Brand ID to associate with this product
</ParamField>

<ParamField body="peso" type="number">
  Product weight in kg
</ParamField>

<ParamField body="alto" type="number">
  Product height in cm
</ParamField>

<ParamField body="ancho" type="number">
  Product width in cm
</ParamField>

<ParamField body="profundidad" type="number">
  Product depth in cm
</ParamField>

<ParamField body="isFeatured" type="boolean">
  Whether this product should be featured
</ParamField>

<ParamField body="foto" type="file">
  Product image file (uploaded as multipart form data). If provided, replaces the existing image.
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the product was updated successfully
</ResponseField>

<ResponseField name="data" type="object">
  The updated product object

  <ResponseField name="id" type="number">
    Unique product identifier
  </ResponseField>

  <ResponseField name="nombre" type="string">
    Product name
  </ResponseField>

  <ResponseField name="descripcion" type="string">
    Product description
  </ResponseField>

  <ResponseField name="precio" type="decimal">
    Product price
  </ResponseField>

  <ResponseField name="precioOriginal" type="decimal" optional>
    Original price
  </ResponseField>

  <ResponseField name="stock" type="number">
    Stock quantity
  </ResponseField>

  <ResponseField name="foto" type="string" optional>
    Product image URL
  </ResponseField>

  <ResponseField name="isFeatured" type="boolean">
    Featured status
  </ResponseField>

  <ResponseField name="peso" type="decimal">
    Weight in kg
  </ResponseField>

  <ResponseField name="alto" type="number">
    Height in cm
  </ResponseField>

  <ResponseField name="ancho" type="number">
    Width in cm
  </ResponseField>

  <ResponseField name="profundidad" type="number">
    Depth in cm
  </ResponseField>

  <ResponseField name="categoriaId" type="number">
    Category ID
  </ResponseField>

  <ResponseField name="marcaId" type="number" optional>
    Brand ID
  </ResponseField>

  <ResponseField name="createdAt" type="datetime">
    Creation timestamp
  </ResponseField>

  <ResponseField name="updatedAt" type="datetime">
    Last update timestamp
  </ResponseField>
</ResponseField>

## Example Request

```bash theme={null}
curl -X PUT "https://api.pcfix.com/api/products/42" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -F "precio=69.99" \
  -F "stock=75" \
  -F "isFeatured=false"
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "id": 42,
    "nombre": "Gaming Mouse Pro",
    "descripcion": "High-precision gaming mouse with RGB lighting and customizable buttons",
    "precio": "69.99",
    "precioOriginal": "79.99",
    "stock": 75,
    "foto": "https://cdn.pcfix.com/uploads/mouse-image-1234567890.jpg",
    "isFeatured": false,
    "peso": "0.15",
    "alto": 5,
    "ancho": 8,
    "profundidad": 12,
    "categoriaId": 8,
    "marcaId": 3,
    "createdAt": "2024-03-05T10:30:00Z",
    "updatedAt": "2024-03-05T15:45:00Z"
  }
}
```

## Error Responses

### Invalid Product ID

```json theme={null}
{
  "success": false,
  "error": "Product not found"
}
```

### Validation Error

```json theme={null}
{
  "success": false,
  "error": "Datos inválidos",
  "details": [
    {
      "field": "precio",
      "message": "El precio debe ser positivo"
    }
  ]
}
```

### Unauthorized

```json theme={null}
{
  "success": false,
  "error": "Unauthorized - Admin access required"
}
```

### Server Error

```json theme={null}
{
  "success": false,
  "error": "Error message description"
}
```

## Notes

* Only include fields you want to update in the request body
* If a new image is uploaded, it will replace the existing image
* The `updatedAt` timestamp is automatically updated
* Product dimensions and weight are important for shipping calculations
