Skip to main content

Documentation Index

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

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

The Update Product endpoint lets an admin partially or fully overwrite an existing marketplace product. All body fields and file fields are optional — only the values you include are applied, and any file you upload replaces the corresponding stored file on the server. The endpoint first checks that the product exists, then verifies admin level 2 authorization before making any changes. If a numeric discount value is supplied, the endpoint automatically recalculates and persists discountPrice as price * (1 - discount / 100). POST /api/product/update/:productId

Authentication

Every request must include a valid JWT in the token-access header. The authenticated user must also hold the admin level 2 role (name: "admin", value: "2"). Requests from non-admin users return HTTP 203.
HeaderValueRequired
token-access<your JWT token>✅ Yes

Path Parameters

productId
string
required
The MongoDB ObjectId of the product to update. Returned as _id when the product was created or listed.

Request Body

This endpoint accepts multipart/form-data. All fields are optional; omitted fields retain their existing values.

Text Fields

title
string
New display name for the product.
description
string
New long-form description.
category
string
Product category. Allowed values: "Uniforme" | "Tipografía".
price
number
Updated base price. If discount is also provided, discountPrice is recalculated from this value.
format
string
Updated design file format string, e.g. "AI", "PNG", "PSD".
typeProduct
string
Updated payment type. Allowed values: "Pago" | "Gratuito".
discount
string
Discount percentage expressed as a numeric string, e.g. "10" for a 10% discount. When provided alongside price, the server calculates discountPrice = price * (1 - discount / 100) and stores both values.

File Fields

Each file field accepts at most 1 file. A new file is only written to the product document if the processed result differs from the currently stored value — if the uploaded file produces a path identical to the one already saved, the field is left unchanged.
archivoUrl
file
Replacement design file. Replaces the previously stored design file.
imageUrl
file
Replacement preview image.
shirtGif
file
Replacement shirt demonstration GIF or image.
shortsGif
file
Replacement shorts demonstration GIF or image.

Response

200 — Product Updated

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

Discount Calculation

The server calculates and stores discountPrice only when all three conditions in the controller are met:
typeof discount === 'string' && !isNaN(parseFloat(discount)) && isFinite(price)
In practice this means: discount must be sent as a numeric string (e.g. "10", "25.5"), and a finite numeric price must also be included in the same request body. When both are present, the server sets:
discountPrice = price × (1 − discount / 100)
For example, price=20 and discount="10" yields discountPrice=18. The discountPrice field is stored as a String in the database.

Error Responses

StatusConditionstatus
404No product found with the given IDfalse
203Authenticated user is not admin level 2false
500Unexpected server error
404 — Product Not Found
{
  "msj": "Producto no encontrado",
  "status": false
}
203 — Not Authorized
{
  "msj": "No estás autorizado para agregar productos",
  "status": false
}

Example

Replace <YOUR_TOKEN> with a valid JWT for an admin level 2 user, and <PRODUCT_ID> with the target product’s _id.
cURL
curl -X POST https://your-api-domain.com/api/product/update/665a1f2e8c4b2a001e3d9f01 \
  -H "token-access: <YOUR_TOKEN>" \
  -F "price=15.99" \
  -F "discount=10" \
  -F "typeProduct=Pago"
Success Response
{
  "msj": "Producto actualizado correctamente",
  "status": true,
  "productUpdate": {
    "_id": "665a1f2e8c4b2a001e3d9f01",
    "title": "Club Deportivo Tigres 2025 — Edición Especial",
    "description": "Kit completo de uniforme para temporada 2025.",
    "category": "Uniforme",
    "price": 15.99,
    "format": "AI",
    "typeProduct": "Pago",
    "archivoUrl": ["storage/product/23design.ai"],
    "imageUrl": ["storage/product/3new-preview.png"],
    "shirtGif": ["storage/product/12shirt.gif"],
    "shortsGif": ["storage/product/45shorts.gif"],
    "discount": "10",
    "discountPrice": "14.391",
    "minCant": 1,
    "date": "2025-06-01T14:30:00.000Z",
    "user": {
      "_id": "664f0a1c3b2e1a001d2c8e00",
      "userName": "adminuser",
      "email": "admin@tukit.com",
      "roles": [{ "name": "admin", "value": "2" }],
      "activate": [{ "name": "active", "value": "true" }]
    },
    "createdAt": "2025-06-01T14:30:00.000Z",
    "updatedAt": "2025-06-02T09:15:00.000Z"
  }
}

Build docs developers (and LLMs) love