The product management endpoints allow administrators to keep the catalog accurate — updating prices, restocking inventory, applying discounts, swapping images, and removing discontinued items. Both endpoints require a validDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
token-access header and an authenticated user with the Admin role (name: "Admin", value: "2").
1. Update a Product
Modify any combination of a product’s fields. Only the fields you include in the request body are updated — omitted fields are left unchanged. If you provide a newdiscount, discountPrice is automatically recalculated from the current or updated price.
| Property | Value |
|---|---|
| Method | POST |
| Path | /api/product/update/:productId/product |
| Auth | token-access: <jwt-token> — Admin role required |
| Content-Type | multipart/form-data |
Path Parameters
The MongoDB ObjectId of the product to update.
Body Fields (all optional)
Supply only the fields you want to change. Any field omitted from the request will retain its existing value on the product document.Updated display name for the product.
Updated description text.
Replaces the full sizes array. Each element must be one of:
"XS" "S" "M" "L" "XL" "XXL".
Repeat the key for each size in a multipart/form-data request:Updated base retail price. If
discount is also provided, discountPrice is recalculated using the new price.Discount percentage as a string (e.g.
"20" for 20% off). Triggers automatic recalculation of discountPrice.Formula: discountPrice = price × (1 − discount / 100)For example, a price of 50 with a discount of "20" yields a discountPrice of 40 (raw number, no rounding applied).Updated stock quantity.
Replacement principal image (1500×2000 WebP after processing).
Replacement thumbnail image (500×666 WebP after processing).
Replacement detail/zoom image (2000×2667 WebP after processing).
Replacement square catalog image (1080×1080 WebP after processing).
Discount Calculation
When adiscount value is included in the request, the controller automatically computes discountPrice before saving:
price | discount | discountPrice |
|---|---|---|
100 | "10" | 90 |
49.99 | "20" | 39.992 |
75 | "50" | 37.5 |
The discount recalculation only fires when
discount is a valid number string (parseable by parseFloat) and the price value from the request body passes isFinite. Provide both price and discount together to ensure discountPrice is recalculated correctly. The result is stored as a raw JavaScript number — no rounding is applied by the server.Response — 200 OK
Human-readable confirmation. Value:
"Producto actualizado correctamente".Always
true on success.The full product document after the update has been applied.
Error Responses
| Status | Meaning |
|---|---|
404 | No product found with the provided productId. |
203 | Authenticated user does not have the Admin role. |
500 | Internal server error. |
Examples
2. Delete a Product
Permanently remove a product listing from the catalog by its ID. The deleted product object is returned in the response for confirmation logging purposes.| Property | Value |
|---|---|
| Method | POST |
| Path | /api/product/remove/:productId |
| Auth | token-access: <jwt-token> — Admin role required |
Path Parameters
The MongoDB ObjectId of the product to permanently delete.
Response — 200 OK
Human-readable confirmation. Value:
"Producto eliminado correctamente".false on a successful deletion (reflects that the product is no longer active).The full product document as it existed immediately before deletion. Useful for audit logs or confirming the correct record was removed.
Error Responses
| Status | Meaning |
|---|---|
404 | No product found with the provided productId. |
203 | Authenticated user does not have the Admin role. |
500 | Internal server error. |