Create variant
Adds a new variant to an existing product. Requires admin scope.
POST
/products/{product_id}/variantsAuthorization
AuthorizationBearer token (JWT) · headerrequiredOAuth 2.0 Bearer token. Obtain via `POST https://auth.onbolder.com/oauth/token`.
Scopes:
adminPath parameters
product_idstringrequiredProduct ID or slug
Request body
requiredapplication/jsontitlestringRequired on create
skustringMust be unique within the shop
stockintegerdefault: 1
available_if_no_stockinteger`1` = always available, `0` = unavailable when out of stock
default: 1
Allowed:
01weight_in_gramsintegerpriceintegerOverride product price for this variant (cents)
price_comparisonintegerOverride comparison price for this variant (cents)
Responses
201Variant created
idintegertitlestringskustring | nullpriceintegerprice_comparisoninteger | nullstockintegeravailable_if_no_stockbooleanweight_in_gramsinteger_linksobject422Validation errors
_classstring[]_embeddedobjectShow propertiesHide properties
errorsobject[]Show propertiesHide properties
Array of
object_classstring[]fieldstringmessagesstring[]Request
curl -X POST "https://api.onbolder.com/v1/products/string/variants" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "string",
"sku": "string",
"stock": 1,
"available_if_no_stock": 0,
"weight_in_grams": 0,
"price": 0,
"price_comparison": 0
}'const response = await fetch("https://api.onbolder.com/v1/products/string/variants", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"title": "string",
"sku": "string",
"stock": 1,
"available_if_no_stock": 0,
"weight_in_grams": 0,
"price": 0,
"price_comparison": 0
})
});import requests
response = requests.post(
"https://api.onbolder.com/v1/products/string/variants",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"title": "string",
"sku": "string",
"stock": 1,
"available_if_no_stock": 0,
"weight_in_grams": 0,
"price": 0,
"price_comparison": 0
},
)Response
{
"id": 0,
"title": "string",
"sku": "string",
"price": 0,
"price_comparison": 0,
"stock": 0,
"available_if_no_stock": true,
"weight_in_grams": 0,
"_links": {}
}{
"_class": [
"string"
],
"_embedded": {
"errors": [
{
"_class": [
"string"
],
"field": "string",
"messages": [
"string"
]
}
]
}
}