Skip to main content

Documentation 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.

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 valid token-access header and an authenticated user with the Admin role (name: "Admin", value: "2").
Deletion is permanent. The remove endpoint hard-deletes the product document from the database. There is no soft-delete, trash, or recovery mechanism. Always verify the productId before calling this endpoint in production.

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 new discount, discountPrice is automatically recalculated from the current or updated price.
PropertyValue
MethodPOST
Path/api/product/update/:productId/product
Authtoken-access: <jwt-token> — Admin role required
Content-Typemultipart/form-data

Path Parameters

productId
string
required
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.
title
string
Updated display name for the product.
description
string
Updated description text.
sizes
array of strings
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:
sizes=M&sizes=L&sizes=XL
price
number
Updated base retail price. If discount is also provided, discountPrice is recalculated using the new price.
discount
string
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).
minCant
number
Updated stock quantity.
imageUrlIp
file
Replacement principal image (1500×2000 WebP after processing).
imageUrlMn
file
Replacement thumbnail image (500×666 WebP after processing).
imageUrlIdz
file
Replacement detail/zoom image (2000×2667 WebP after processing).
imageUrlIc
file
Replacement square catalog image (1080×1080 WebP after processing).

Discount Calculation

When a discount value is included in the request, the controller automatically computes discountPrice before saving:
discountPrice = price × (1 − discount / 100)
pricediscountdiscountPrice
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

msj
string
Human-readable confirmation. Value: "Producto actualizado correctamente".
status
boolean
Always true on success.
updatedProduct
object
The full product document after the update has been applied.

Error Responses

StatusMeaning
404No product found with the provided productId.
203Authenticated user does not have the Admin role.
500Internal server error.

Examples

curl -X POST https://api.example.com/api/product/update/664a1f2e8b3c2a001f4e8d01/product \
  -H "token-access: <jwt-token>" \
  -F "price=49.99" \
  -F "discount=20"

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.
PropertyValue
MethodPOST
Path/api/product/remove/:productId
Authtoken-access: <jwt-token> — Admin role required
This operation is irreversible. Once deleted, the product and all associated metadata are removed from the database permanently. Associated images stored in GCS are not automatically deleted by this endpoint.

Path Parameters

productId
string
required
The MongoDB ObjectId of the product to permanently delete.

Response — 200 OK

msj
string
Human-readable confirmation. Value: "Producto eliminado correctamente".
status
boolean
false on a successful deletion (reflects that the product is no longer active).
removeProduct
object
The full product document as it existed immediately before deletion. Useful for audit logs or confirming the correct record was removed.

Error Responses

StatusMeaning
404No product found with the provided productId.
203Authenticated user does not have the Admin role.
500Internal server error.

Examples

curl -X POST https://api.example.com/api/product/remove/664a1f2e8b3c2a001f4e8d01 \
  -H "token-access: <jwt-token>"

Build docs developers (and LLMs) love