Backend API
Create a new product variant. Normally, variants are automatically created when product options are set.
Arguments
Human-friendly name of the variant. Defaults to the combined name of all options, for example, "Blue, Large" in the case of 2 options; color and size.
The id of the parent product.
An object containing custom attribute values. Overrides product attributes. See attributes for more details.
List of option value IDs that constitute the variant.
List price used by default when sale=false or sale_price is not defined. Overrides product price.
An active variant is visible to customers in a storefront. Otherwise, it will be hidden from view.
A variant is automatically archived when it has been sold in the past and product options are changed in a way that would cause the variant to be removed.
Cost of goods used to calculate gross margins. Overrides product cost.
List of images depicting the variant.
Unique identifier for the object.
A brief description of the image.
An object representing the image file.
Unique identifier for the file.
MIME content type of the file.
data
Date the file was uploaded.
Optional file name.
Image height in pixels, if applicable.
Size of the file in bytes.
An MD5 hash of the file contents. This can be used to uniquely identify the file for caching purposes.
A public URL to reference the file. Updated automatically if file content changes.
Image width in pixels, if applicable.
Indicates the image is not visible to customers.
Arbitrary image data, typically used to store custom values. See Frontend API for more details.
Price rules to override price and sale_price when conditions match quantity or account group in a cart. Overrides product prices
Price applied when conditions are met.
Customer account group as a condition to apply price.
Maximum quantity as a condition to apply price.
Minimum quantity as a condition to apply price.
Indicates the variant is on sale and sale_price is used by default when the product is added to a cart. Overrides product sale.
Sale price used by default when sale=true, overriding price. Overrides product sale price.
If specified, shipping is calculated based on this shipping weight. Otherwise, it will assume 1 lb/oz/kg depending on your default weight unit. Overrides product shipping weight.
Stock keeping unit (SKU) used to track inventory in a warehouse.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.post('/products:variants', {
parent_id: '5ca24abb9c077817e5fe2b36',
name: 'Blue, Small',
});
Response
{
"id": "5c8fb5e1ed2faf8c79da492a",
"parent_id": "5ca24abb9c077817e5fe2b36",
"name": "Blue, Small",
"active": true,
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z"
}