Products
Update Product
Update an existing product (admin only)
PUT
Update Product
Overview
This endpoint allows administrators to update an existing product in the catalog. All fields are optional, and you can optionally upload a new image.Endpoint
Path Parameters
The unique identifier of the product to update
Authentication
Required: Admin role This endpoint requires a valid JWT token with admin privileges. Include the token in the Authorization header:Request Body
This endpoint acceptsmultipart/form-data format if uploading a new image, or application/json for other updates.
Product name
Product description
Product price (maximum 2 decimal places)
Product image URL (can be set directly)
ID of the category this product belongs to (must be >= 1 if provided)
New product image file (uploaded as multipart/form-data with field name ‘image’)
Validation Rules
name: If provided, must be a valid stringdescription: If provided, must be a valid stringprice: If provided, must be a number with maximum 2 decimal placescategoryId: If provided, must be an integer >= 1image: Optional file field - if provided, will replace the existing image
Response
Returns the updated product object.Unique identifier for the product
Product name
Product description
Product price (decimal with 2 decimal places)
URL to the product image
Available stock quantity
ID of the category this product belongs to
Timestamp when the product was created
Timestamp when the product was last updated
Example Request (JSON)
Example Request (With Image Upload)
Example Response
200 OK
Error Responses
Product Not Found
404 Not Found
Validation Error
400 Bad Request
Unauthorized
401 Unauthorized
Forbidden (Non-Admin User)
403 Forbidden
Invalid Category ID
400 Bad RequestUpdate Product