Skip to content

Update Product

Description

This API allows users to update an existing product's details. Users can modify attributes such as name, description, summary, price, images, specifications, and more.

Endpoint

  • URL: /v1/products/{productId}
  • Method: PATCH

Required Headers

  • Authorization: Bearer JWT_TOKEN
  • X-MerchantApiKey: MERCHANT_API_KEY
  • Content-Type: application/json

📥 Request Body

Field NameTypeRequiredDescription
nameStringYes (Min: 1 character)The name of the product.
slugStringNoThe slug of the product (not recommended for updates).
descriptionStringYes (Min: 50 characters)The product's full description.
summaryStringYes (Min: 10, Max: 255 characters)A short summary of the product.
imageStringNoThe main image URL of the product.
thumbnailStringNoThe thumbnail image URL of the product.
imageListList(string)NoA list of additional product images.
featuresList(string)NoA list of product features.
priceDoubleYes (Min: 1)The price of the product.
ramSizeStringNoRAM size format: 4GB, 512MB, 12KB, or 1TB.
storageStringNoStorage capacity of the product.
sizeStringNoThe size of the product.
skuStringYes (Min: 2 characters)The Stock Keeping Unit (SKU) of the product.
quantityInStockIntegerYes (Min: 0)The available stock quantity.
brandIdStringNoThe ID of the product's brand.
discountDoubleNo (Min: 0, Max: 100)The discount percentage applied.
categoryIdStringNoThe category ID of the product.
colorIdStringNoThe color ID of the product.
customColorStringNoCustom color name, if applicable.
specificationsListYes (Min: 1)List of product specifications. Each specification must have a key and value. More Info

ProductSpecification DTO

Available specifications can be found here.

Product Specification
FieldTypeRequiredDescription
keystringYesThe specification key (e.g., "Battery Capacity").
valuestringYesThe specification value (e.g., "4000mAh").

Example API Call (Using Fetch)

javascript
fetch("https://api.shopsynch.com/v1/products/679f8f5a3b5f2173201c2582", {
  method: "PATCH",
  headers: {
    "Authorization": "Bearer JWT_TOKEN",
    "X-MerchantApiKey": "MERCHANT_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "name": "Updated Product Name",
    "description": "This is an updated description of the product, which provides all necessary details.",
    "summary": "Short summary about the product.",
    "price": 150.00,
    "sku": "PROD-001",
    "quantityInStock": 20,
    "discount": 10,
    "brandId": "brand-123",
    "categoryId": "category-456",
    "specifications": [{ "key": "Material", "value": "Leather" }]
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

✅ Sample 200 Response (Success)

json
{
  "id": "679f8f5a3b5f2173201c2582",
  "name": "Updated Product Name",
  "slug": "updated-product-name",
  "description": "This is an updated description of the product, which provides all necessary details.",
  "summary": "Short summary about the product.",
  "image": "https://example.com/images/product-main.jpg",
  "thumbnail": "https://example.com/images/product-thumb.jpg",
  "price": 150.00,
  "quantityInStock": 20,
  "brand": "Brand Name",
  "discount": 10,
  "category": "Category Name",
  "color": "Red",
  "specifications": [
    { "key": "Material", "value": "Leather" }
  ],
  "features": ["Waterproof", "Durable"]
}

❌ Sample 422 Response (Validation Error)

json
{
  "status": 422,
  "message": "Validation Error",
  "errors": {
    "name": "Product name must have at least 1 character",
    "description": "Description must be at least 50 characters long",
    "summary": "Summary must be at least 10 characters long"
  }
}

Next Steps

Build with joy