Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery/llms.txt

Use this file to discover all available pages before exploring further.

The update endpoint allows administrators to modify any field of an existing product. All fields are optional — only the values provided in the request body will overwrite the stored data. If new images are uploaded they replace the existing set; if no image files are sent the current images are preserved. When a discount percentage is supplied, a priceDiscount is automatically calculated and stored alongside the raw percentage value.
This endpoint requires both a user token (Token) and an admin token (TokenAdmin). Requests authenticated with a user-only token will be rejected.

POST /api/product/update/:productId

Auth: Token + TokenAdmin required
Content-Type: multipart/form-data

Path parameters

productId
string
required
The MongoDB ObjectId of the product to update.

Request fields

title
string
New display name for the product.
description
string
Updated product description.
price
number
Updated base price. Required when discount is also provided, as priceDiscount is derived from this value.
minCant
number
Updated minimum stock quantity. Defaults to 0 if omitted.
colorsSize
string
Updated color options. Accepts a JSON array of { label, value } objects or a comma-separated string of known color labels. If omitted, the stored colors are replaced with an empty array.Known color labels: Blanco, Negro, Gris oscuro, Gris claro, Azul celeste, Azul marino, Azul rey, Beige, Cafe claro, Cafe oscuro, Verde militar, Verde bosque, Verde menta, Rojo, Vino, Rosa pastel, Fucsia, Amarillo mostaza, Amarillo crema, Naranja, Lila, Morado, Turquesa, Amarillo.
sizes
string
Updated size options. Accepts a JSON array of { label, value } objects or a comma-separated string of known size labels. If omitted, the stored sizes are replaced with an empty array.Known size labels: XS, S, M, L, XL, XXL/2XL, XXXL/3XL.
typeShirt
string
Updated shirt type. Must be one of: Overside, CropTop, Regular Fit, Semi-Overside, Hoodie.
discount
string
Discount as a percentage value supplied as a string (e.g. "20" for 20%). When this field is present and price is a finite number, the server computes:
priceDiscount = price × (1 − discount / 100)
The computed priceDiscount is stored on the product. The raw discount string is also persisted.
The discount field on the Product schema stores the raw percentage string sent here. priceDiscount holds the calculated numeric result as a string.
productImg
file[]
Replacement product images. Upload one or more files under the productImg field key. If no files are uploaded, the existing images are kept unchanged.

Responses

msj
string
"Producto actualizado correctamente" on success.
status
boolean
true on success.
productUpdate
object
The full updated product document fetched after the update is applied.

Error responses

StatusmsjCause
403"Sin parametro de producto"productId path parameter is missing.
404"Producto no encontrado"No product exists for the given productId.
400(validation error message)One or more resolved color or size values is invalid.
500(error object)Unexpected server error.

Example

curl -X POST https://your-domain.com/api/product/update/664a1f2e8b3c4d001e2f3a4b \
  -H "Authorization: Bearer <token>" \
  -F "title=Classic Logo Tee — Summer Edition" \
  -F "description=Lightweight version for the warmer months." \
  -F "price=29.99" \
  -F "discount=20" \
  -F 'colorsSize=[{"label":"Blanco","value":"1"},{"label":"Azul celeste","value":"5"}]' \
  -F 'sizes=[{"label":"S","value":"2"},{"label":"M","value":"3"},{"label":"L","value":"4"},{"label":"XL","value":"5"}]' \
  -F "typeShirt=Regular Fit" \
  -F "minCant=100" \
  -F "productImg=@/path/to/new-image.jpg"
Success response (200):
{
  "msj": "Producto actualizado correctamente",
  "status": true,
  "productUpdate": {
    "_id": "664a1f2e8b3c4d001e2f3a4b",
    "userId": "663f0e1d7a2b3c000d1e2f3a",
    "title": "Classic Logo Tee — Summer Edition",
    "description": "Lightweight version for the warmer months.",
    "price": 29.99,
    "minCant": 100,
    "discount": "20",
    "priceDiscount": "23.992",
    "colorsSize": [
      { "label": "Blanco", "value": "1" },
      { "label": "Azul celeste", "value": "5" }
    ],
    "sizes": [
      { "label": "S", "value": "2" },
      { "label": "M", "value": "3" },
      { "label": "L", "value": "4" },
      { "label": "XL", "value": "5" }
    ],
    "typeShirt": "Regular Fit",
    "productImg": ["storage/product/34new-image.jpg"],
    "points": { "cant": 12, "users": ["663f...", "664b..."] },
    "createdAt": "2024-05-20T14:32:00.000Z",
    "updatedAt": "2024-05-21T09:15:00.000Z"
  }
}

Build docs developers (and LLMs) love