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 creation endpoint lets authenticated administrators add new shirts to the catalog. Because it accepts image uploads alongside text fields, every request must be sent as multipart/form-data. Uploaded images are automatically resized via Sharp and stored in Google Cloud Storage as WebP files before the product document is persisted to the database.

Endpoint

PropertyValue
MethodPOST
Path/api/product/agregate
Authtoken-access: <jwt-token> — Admin role required (name: "Admin", value: "2")
Content-Typemultipart/form-data
Only users whose role satisfies roles.some(r => r.name === "Admin" && r.value === "2") can create products. Requests from non-admin tokens receive a 203 response.

Request Fields

Text fields

title
string
required
Display name of the product (e.g. "Classic Oxford Shirt"). Shown in catalog listings and search results.
description
string
required
Full-length product description including material, fit notes, and care instructions.
sizes
array of strings
required
Available sizes for this product. Each element must be one of the accepted enum values.Allowed values: "XS" "S" "M" "L" "XL" "XXL"When submitting via multipart/form-data, repeat the field key for each size:
sizes=S&sizes=M&sizes=L
price
number
required
Base retail price in the store’s currency unit (e.g. 49.99). Used as the reference value when calculating discounted prices later via the update endpoint.
minCant
number
Initial stock quantity. Defaults to 0 when omitted. Tracks the minimum available inventory count for the listing.

Image file fields

All four image slots are optional but recommended for a complete listing. Each field accepts a single file upload. Images are processed by Sharp on the server before being uploaded to GCS — you do not need to resize locally.
imageUrlIp
file
Principal image — the primary hero shot displayed on the product detail page. Processed to 1500 × 2000 px WebP.
imageUrlMn
file
Thumbnail image — used in catalog grid cards and search results. Processed to 500 × 666 px WebP.
imageUrlIdz
file
Detail / zoom image — high-resolution version for the image zoom viewer. Processed to 2000 × 2667 px WebP.
imageUrlIc
file
Square catalog image — used in square-format promotional grids and social previews. Processed to 1080 × 1080 px WebP.
Upload images at the largest reasonable resolution you have — Sharp will down-sample to the target dimensions. Sending images that are already smaller than the target size may result in upscaled artifacts.

Image Processing

Uploaded files go through the following pipeline before the product is saved:
1

Receive multipart upload

Multer accepts up to one file per field (imageUrlIp, imageUrlMn, imageUrlIdz, imageUrlIc) held in memory.
2

Resize with Sharp

Each buffer is resized to its target dimensions and converted to WebP format for optimal compression.
3

Store in GCS

The WebP buffer is written to a Google Cloud Storage bucket. The resulting public URL is stored in the corresponding array field on the product document.
4

Persist product document

The full product object — including embedded user info from the decoded JWT — is saved to MongoDB and returned in the response.

Response

Success — 200 OK

message
string
Human-readable confirmation. Value: "Producto creado correctamente".
status
boolean
Always true on a successful creation.
data
object
The newly created product document.

Error responses

StatusMeaning
200Missing required fields (title, description, sizes, price) — status: false, uses message key.
203Authenticated user does not have the Admin role — status: false, uses msj key.
500Internal server error (e.g. GCS upload failure, database error).
The missing-fields check returns HTTP 200 (not 400 or 422) with status: false and a message field. The no-admin response returns 203 with a msj field — note the different key names.

Examples

curl -X POST https://api.example.com/api/product/agregate \
  -H "token-access: <jwt-token>" \
  -F "title=Classic Oxford Shirt" \
  -F "description=100% cotton Oxford weave, relaxed fit, button-down collar." \
  -F "sizes=S" \
  -F "sizes=M" \
  -F "sizes=L" \
  -F "sizes=XL" \
  -F "price=49.99" \
  -F "minCant=120" \
  -F "imageUrlIp=@/path/to/principal.jpg" \
  -F "imageUrlMn=@/path/to/thumbnail.jpg" \
  -F "imageUrlIdz=@/path/to/zoom.jpg" \
  -F "imageUrlIc=@/path/to/catalog.jpg"

Build docs developers (and LLMs) love