Create a variant
Creates a new variant for a product.
POST
/products/{product_id}/variantsAuthorization
AuthorizationBearer token (JWT) · headerrequiredPath parameters
product_idstringrequiredRequest body
requiredapplication/jsonidintegerPre-assign a specific variant ID (rarely used; usually omitted).
option1stringoption2stringoption3stringoption_valuesobjectCustom variant option values, keyed by `option1`/`option2`/`option3`.
option_asset_idsobjectAsset IDs to associate with each option value.
product_asset_idsinteger[]Product image asset IDs to associate with this variant.
skustringbarcode_numberstringregular_priceintegerIn cents. Required if the product has per-variant prices.
sale_priceintegerIn cents
costintegerweight_in_gramsintegerunit_quantitynumbercolorstringavailable_if_no_stockbooleandefault: false
online_stockintegerstatusstringAllowed:
visiblehiddenstocksobject[]Show propertiesHide properties
Array of
objectlocation_idintegerunitsintegerResponses
201Variant created
_linksHalLinksidintegerproduct_idintegernamestringDisplay name, computed from option1/option2/option3.
statusstringAllowed:
visiblehiddenskustringbarcode_numberstringoption1stringoption2stringoption3stringcurrency_codestringregular_priceintegerRegular price in cents
sale_priceinteger | nullSale price in cents
priceintegerEffective price in cents (sale_price if set, else regular_price)
online_stockintegerall_stockintegeravailable_if_no_stockbooleanweight_in_gramsintegerunit_quantitynumbercolorstringcostintegerprofitintegerstocksobject[]Per-location stock breakdown
Show propertiesHide properties
Array of
objectlocation_idintegeravailable_unitsintegertotal_unitsintegerRequest
curl -X POST "https://api.onbolder.com/v2/products/string/variants" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"option1": "Large",
"sku": "WH-001-L",
"regular_price": 8999,
"stocks": [
{
"location_id": 1,
"units": 15
}
]
}'const response = await fetch("https://api.onbolder.com/v2/products/string/variants", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"option1": "Large",
"sku": "WH-001-L",
"regular_price": 8999,
"stocks": [
{
"location_id": 1,
"units": 15
}
]
})
});import requests
response = requests.post(
"https://api.onbolder.com/v2/products/string/variants",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"option1": "Large",
"sku": "WH-001-L",
"regular_price": 8999,
"stocks": [
{
"location_id": 1,
"units": 15
}
]
},
)Response
{
"id": 202,
"product_id": 101,
"name": "Large",
"sku": "WH-001-L",
"regular_price": 8999,
"price": 8999
}