Update Product
This endpoint allows you to update an existing product's details, including its variants, options, and other properties.
πΉ Endpoint Detailsβ
PUT /api/v1/products/{productId}
Path Parametersβ
Parameter | Type | Required | Description |
---|---|---|---|
productId | string | Yes | The unique identifier of the product to update |
π Authenticationβ
Header | Required | Description |
---|---|---|
Content-Type | Yes | Must be application/json |
Authorization | Yes | Format: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature |
π Request Structureβ
All fields are optional in the update request. Only provided fields will be updated.
π Update Strategiesβ
-
Partial Updates
- Send only fields that need to change
- Omitted fields remain unchanged
- Arrays are replaced, not merged
-
Variant Updates
- Include variant
id
to update existing - Omit
id
to create new variant - Variants not included remain unchanged
- Include variant
-
Option Updates
- Can add new values to options
- Cannot remove values in use
- Full option array required when updating
π― Request Examplesβ
Basic Field Updateβ
{
"name": "Updated T-Shirt Name",
"descriptionHtml": "<p>New description</p>",
"active": false
}
Price Update Across Variantsβ
{
"variants": [
{
"id": "789e0123-c45b-67d8-e901-234567890000",
"price": 34.99
},
{
"id": "890f1234-d56c-78e9-f012-345678901111",
"price": 34.99
}
]
}
Add New Option and Variantβ
{
"name": "Updated Premium T-Shirt",
"descriptionHtml": "<p>Updated product description</p>",
"images": [
"https://example.com/new-image1.webp"
],
"options": [
{
"name": "Size",
"values": ["Small", "Medium", "Large", "XLarge"]
},
{
"name": "Color",
"values": ["Black", "White", "Red"]
}
],
"variants": [
{
"id": "789e0123-c45b-67d8-e901-234567890000",
"sku": "TS-BLK-S",
"price": 34.99,
"stock": 75,
"selectedOptions": [
{
"name": "Size",
"value": "Small"
},
{
"name": "Color",
"value": "Black"
}
]
},
{
"sku": "TS-RED-XL",
"price": 34.99,
"currency": "EUR",
"stock": 25,
"selectedOptions": [
{
"name": "Size",
"value": "XLarge"
},
{
"name": "Color",
"value": "Red"
}
],
"images": [
"https://example.com/shirt-red-xl.webp"
]
}
],
"active": true,
"tags": ["premium", "apparel", "updated"]
}
Stock Managementβ
{
"variants": [
{
"id": "789e0123-c45b-67d8-e901-234567890000",
"stock": 75
}
]
}
π€ Response Formatβ
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Updated Premium T-Shirt",
"descriptionHtml": "<p>Updated product description</p>",
"images": [
"https://example.com/new-image1.webp"
],
"options": [
{
"name": "Size",
"values": ["Small", "Medium", "Large", "XLarge"]
},
{
"name": "Color",
"values": ["Black", "White", "Red"]
}
],
"variants": [
{
"id": "789e0123-c45b-67d8-e901-234567890000",
"sku": "TS-BLK-S",
"price": 34.99,
"currency": "EUR",
"stock": 75,
"selectedOptions": [
{
"name": "Size",
"value": "Small"
},
{
"name": "Color",
"value": "Black"
}
]
},
{
"id": "890f1234-d56c-78e9-f012-345678901111",
"sku": "TS-RED-XL",
"price": 34.99,
"currency": "EUR",
"stock": 25,
"selectedOptions": [
{
"name": "Size",
"value": "XLarge"
},
{
"name": "Color",
"value": "Red"
}
],
"images": [
"https://example.com/shirt-red-xl.webp"
]
}
],
"price": 34.99,
"stock": 100,
"active": true,
"tags": ["premium", "apparel", "updated"],
"updatedAt": "2025-05-22T10:30:00Z"
}
π Response Interpretationβ
-
Updated Fields
- Only modified fields are shown
updatedAt
reflects latest change- Price/stock recalculated automatically
-
Variant Changes
- Updated variants show new values
- New variants get assigned IDs
- Unchanged variants remain as is
π Notesβ
- Only provided fields will be updated
- Omitted fields retain their current values
- Existing variants can be updated by providing their
id
- New variants can be added without an
id
- Options can be extended with new values
- Each variant must maintain a unique combination of options
- The product's total stock and price are automatically recalculated
β Common Use Casesβ
- π° Price Updates: Modify prices across variants
- π¦ Stock Management: Update inventory levels
- π¨ New Options: Add new size or color options
- π New Variants: Add variants for new option combinations
- β‘ Status Changes: Activate or deactivate products
- π Content Updates: Modify descriptions and images
- π·οΈ Categorization: Update product tags or category
π Validation Rulesβ
-
Product Updates
- All fields are optional
- New values must pass the same validation as create
- Cannot remove options that are in use by variants
- Must maintain at least one variant
-
Variant Updates
- Price must be positive
- Stock must be non-negative
- Option combinations must be unique
- SKUs must be unique across all variants
-
Option Updates
- Can add new values to existing options
- Cannot remove values used by existing variants
- Option names must remain unique
β Error Responsesβ
400 Bad Requestβ
{
"statusCode": 400,
"message": "Invalid input",
"errors": [
{
"field": "price",
"message": "Price must be a positive number"
}
]
}
401 Unauthorizedβ
{
"statusCode": 401,
"message": "Invalid or missing authorization credentials"
}
403 Forbiddenβ
{
"statusCode": 403,
"message": "Insufficient permissions to update this product"
}
404 Not Foundβ
{
"statusCode": 404,
"message": "Product not found"
}
409 Conflict - Duplicate SKUβ
{
"statusCode": 409,
"message": "A variant with this SKU already exists"
}
409 Conflict - Option In Useβ
{
"statusCode": 409,
"message": "Cannot remove option that is in use by variants"
}
422 Validation Errorβ
{
"statusCode": 422,
"message": "Validation failed",
"errors": [
{
"field": "variants",
"message": "Product must have at least one variant"
}
]
}
π Update Scenariosβ
1. Price Changesβ
{
"variants": [
{
"id": "variant-id",
"price": 39.99
}
]
}
Effect: Updates single variant price
2. Add Option Valueβ
{
"options": [
{
"name": "Size",
"values": ["Small", "Medium", "Large", "XLarge"]
}
]
}
Effect: Adds new size option
3. Stock Adjustmentβ
{
"variants": [
{
"id": "variant-id",
"stock": 100
}
]
}
Effect: Updates variant stock level
4. Product Statusβ
{
"active": false
}
Effect: Deactivates product