---
title: "Update product"
method: PATCH
path: "/ecommerce/products/{productId}"
tags: ["🛒 Ecommerce"]
---

# Update product

`PATCH /ecommerce/products/{productId}`

The API enables an authenticated user with the role of `ADMIN` to update a product's information.

By passing the `productId` as a path variable, the API allows the user to modify the product's attributes such as name, description, price, stock, category (referenced by categoryId), mainImage (the primary image), and subImages (up to four additional images displayed in a carousel on the frontend).

All of these fields can be included in the request body as form data, and they are optional, meaning that only the provided fields will be updated.

## Response `200`

Update product

- object
  - `data` object
    - `__v` number
    - `_id` string
    - `category` string
    - `createdAt` string
    - `description` string
    - `mainImage` object
      - `_id` string
      - `localPath` string
      - `url` string
    - `name` string
    - `owner` string
    - `price` number
    - `stock` number
    - `subImages` object[]
      - `_id` string
      - `localPath` string
      - `url` string
    - `updatedAt` string
  - `message` string
  - `statusCode` number
  - `success` boolean

---

[API](https://skmtc.net/hiteshchoudhary-ssesph/apis/freeapi.md) · [All operations](https://skmtc.net/hiteshchoudhary-ssesph/apis/freeapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/hiteshchoudhary-ssesph/freeapi/versions/a9f3a290e4dc/schema)
