Update product
PATCH/product/:productId
Update an existing product
To update an existing variant, send its _id and only the fields that change:
{
"variants": [
{ "_id": "507f1f77bcf86cd799439011", "quantity": 20 }
]
}
A list containing an _id merges by default: omitted fields and other variants
are preserved. IDs must belong to this product and cannot repeat in a request.
Entries without _id in a merge append new variants and require price and
optionCombination. Set variantsMode: "merge" when appending only new variants.
For compatibility, lists containing no IDs still replace the complete list.
Set variantsMode: "replace" to explicitly replace a list containing IDs;
every entry then requires price and optionCombination. Omitted variants are
removed. To remove all variants, send variantsMode: "replace", variants: [],
and the product's simple-product price and quantity.
Setting isDefault: true on one variant clears it on the previous default.
Marking two variants as default in one request returns 400
MULTIPLE_DEFAULT_VARIANTS.
An unknown variant ID in merge mode returns 404 VARIANT_NOT_FOUND; a repeated
ID returns 400 VARIANT_PATCH_DUPLICATE. If the stored variants or options
change while the request is processed, it returns 409
PRODUCT_CHANGED_CONCURRENTLY and nothing is written; read the product and
retry. When every entry has an _id, concurrent stock movements (orders,
reservations) are not a conflict: only the fields you send are written, so they
are kept. A request that also appends variants rewrites the list and conflicts
with any concurrent change, including stock.
Request
Responses
- 200
Product details