Overview
This endpoint updates an existing product with new information. It supports bothPUT and PATCH methods, allowing for partial updates - only the fields provided in the request body will be updated. The operation is transactional and automatically updates the updatedAt timestamp.
Path Parameters
The unique identifier of the product to update
Request Body
All fields are optional for partial updates. Only include the fields you want to modify.New product name (must not be blank if provided)
New product description (must not be blank if provided)
New product price (BigDecimal format, e.g.,
39.99)New stock quantity (long integer)
Response
Returns the updated product entity with all current values.Product ID (unchanged)
Updated or existing product name
Updated or existing description
Updated or existing price
Updated or existing stock quantity
Product discount (if applicable)
Complete list of category associations
Original creation timestamp (unchanged)
Automatically updated to the current timestamp
Status Codes
Product updated successfully
Product with the specified ID does not exist
Invalid request body or field values (e.g., blank name/description)
Server error occurred while updating the product
Examples
Request Body Example (Partial Update)
Request Body Example (Full Update)
Success Response Example (200 OK)
Error Response Example (404 Not Found)
Error Response Example (400 Bad Request)
Partial Updates: This endpoint implements smart partial updates. Only fields that are present and valid in the request body will be updated. Missing fields remain unchanged.
Automatic Timestamp: The
updatedAt field is automatically set to the current timestamp whenever any field is successfully updated.PUT vs PATCH: While both methods are supported,
PATCH is semantically more correct for partial updates. The implementation treats both identically.