Create a product
Creates a product in the specified shop. shop_id must be a shop belonging to the authenticated account.
POST
/productsAuthorization
AuthorizationBearer token (JWT) · headerrequiredRequest body
requiredapplication/jsonshop_idintegerrequiredID of the shop (required on create)
namestringrequiredProduct name.
slugstringURL slug. Auto-generated from name if omitted.
statusstringdefault: "hidden"
Allowed:
visiblehiddenblockedclassstringProduct class. Defaults to `Product`.
default: "Product"
Allowed:
ProductProductBundleSubscriptionGiftCarddescriptionstringshort_descriptionstringdeliverablebooleanWhether the product requires physical delivery. Defaults to `true`. Set to `false` for digital goods, event tickets, subscriptions, etc. Returned as `is_deliverable` in responses.
tracks_stockbooleanWhether stock is tracked for this product's variants.
has_prices_per_variantbooleanRequired when variants have different prices. Must be `true` if any variant sets its own `regular_price`; the API returns 422 otherwise.
has_weights_per_variantbooleanWhether variants carry individual weights.
regular_priceintegerRegular price in cents, applied to all variants (for non-bundle products). Use per-variant `regular_price` inside `variants` when `has_prices_per_variant` is true.
sale_priceintegerSale price in cents, applied to all variants.
sale_price_starts_atstring<date-time>ISO 8601 datetime when the sale price activates.
sale_price_ends_atstring<date-time>ISO 8601 datetime when the sale price expires.
product_type_namestringProduct type name. Created automatically if it doesn't exist.
vendor_namestringVendor name. Created automatically if it doesn't exist.
tagsstring[]Tag names. Replaces all existing tags unless `_policies.keep_attributes` is set.
cart_quantity_multipleintegerEnforces cart quantities to be multiples of this value.
variant_optionsobjectNames for up to 3 variant option axes (e.g. "Color", "Size").
Show propertiesHide properties
option1stringoption2stringoption3stringvariantsVariantInput[]Variant definitions. By default, variants not present in the array are removed; set `_policies.keep_variants: true` to preserve them.
Show propertiesHide properties
Array of
VariantInputidintegerExisting variant ID. Required when updating a specific variant.
skustringoption1stringoption2stringoption3stringregular_priceintegerRegular price in cents. Required per-variant when `has_prices_per_variant` is true.
sale_priceintegerSale price in cents.
online_stockintegerAvailable online stock units.
weight_in_gramsintegerbarcode_numberstringstatusstringAllowed:
visiblehiddenavailable_if_no_stockbooleanAllow purchase even when stock reaches zero.
default: false
collectionsobject[]Collections to assign the product to. Pass `id` to reference an existing collection, or `title` to create/find by name. Replaces all existing collections unless `_policies.keep_collections: true`.
Show propertiesHide properties
Array of
objectidstringCollection ID
titlestringCollection title (used to find or create)
custom_attributesobject[]Custom meta-field attributes.
Show propertiesHide properties
Array of
objectnamestringvaluestringfield_typestringAllowed:
stringintsplit_stringtextfield_groupstringrequiredbooleandefault: false
filterablebooleandefault: true
volume_discount_idintegerAssigns an existing volume discount to this product.
relationsobject[]Related products (e.g. "goes well with"). Replaces all existing relations unless `_policies.keep_relations: true`.
Show propertiesHide properties
Array of
objectidstringRelation ID, when updating an existing relation.
namestringRelation name (e.g. "related", "upsell").
child_idstringRelated product ID or slug.
child_typestringcustom_variant_optionsobjectCustom variant option metadata (id/name/type) for up to 3 option axes, keyed by `option1`/`option2`/`option3`.
bundle_optionsobject[]Configurable bundle option groups (customer picks items from each group). Only applies to `class: ProductBundle`.
Show propertiesHide properties
Array of
objectidintegerBundle option ID, when updating.
namestringmin_countintegermax_countintegerdefault: 1
max_per_itemintegerbundle_itemsobject[]Show propertiesHide properties
Array of
objectidintegerBundle item ID, when updating.
product_idintegervariant_idintegerRequired unless `variant_sku` is given.
variant_skustringRequired unless `variant_id` is given.
unitsintegeradditional_priceintegerAdditional price in cents if this item is selected.
bundle_itemsobject[]Fixed bundle items (always included, no customer choice). Only applies to `class: ProductBundle`.
Show propertiesHide properties
Array of
objectidintegerBundle item ID, when updating.
product_idintegervariant_idintegerRequired unless `variant_sku` is given.
variant_skustringRequired unless `variant_id` is given.
unitsintegerdefault: 1
_policiesobjectControl update behaviour. All flags default to `false` (destructive replace). Set to `true` to preserve existing data when the corresponding field is not included in the request.
Show propertiesHide properties
keep_variantsbooleanKeep existing variants not listed in `variants`.
default: false
keep_collectionsbooleanKeep existing collection assignments not listed in `collections`.
default: false
keep_relationsbooleanKeep existing product relations not listed in `relations`.
default: false
keep_attributesbooleanKeep existing custom attributes not listed in `custom_attributes`.
default: false
ensure_uniquestringIf set, the product is not created when another product already has the same value for this field (returns 409 instead).
Allowed:
titleslugResponses
201Product created
_linksHalLinksidintegernamestringProduct display name.
slugstringclass_namestringstatusstringAllowed:
visiblehiddendescriptionstringshort_descriptionstringis_bundlebooleanis_deliverablebooleanhas_optionsbooleantagsstring[]currency_codestringbundle_price_modestringAllowed:
pricesumbundle_discountnumberregular_pricenumberIn cents
pricenumberEffective price in cents
sale_pricenumberIn cents
sale_price_starts_atstring<date-time>sale_price_ends_atstring<date-time>has_multiple_pricesbooleandiscount_percentagenumbersafety_stockintegeravailablebooleanstockintegerCurrent stock
online_stockintegerall_stockintegerStock across all locations
vendorstringvariant_optionsobject[]Show propertiesHide properties
Array of
objectnamestringvaluestringglobal_tagsstring[]stocksobjectstocks_per_locationobjectcart_max_quantityintegercart_quantity_multipleintegerlist_pricesobject[]Show propertiesHide properties
Array of
objectprice_list_idintegerpricenumbercreated_onstring<date-time>updated_onstring<date-time>403Not authorized to create products in this shop
422Validation error or missing shop_id
_embeddedobjectShow propertiesHide properties
errorsobject[]Show propertiesHide properties
Array of
objectfieldstringmessagesstring[]Request
curl -X POST "https://api.onbolder.com/v2/products" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"shop_id": 1,
"name": "Organic Cotton Tee",
"slug": "organic-cotton-tee",
"status": "visible",
"sale_price": 2999,
"regular_price": 3999
}'const response = await fetch("https://api.onbolder.com/v2/products", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"shop_id": 1,
"name": "Organic Cotton Tee",
"slug": "organic-cotton-tee",
"status": "visible",
"sale_price": 2999,
"regular_price": 3999
})
});import requests
response = requests.post(
"https://api.onbolder.com/v2/products",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"shop_id": 1,
"name": "Organic Cotton Tee",
"slug": "organic-cotton-tee",
"status": "visible",
"sale_price": 2999,
"regular_price": 3999
},
)Response
{
"id": 103,
"name": "Organic Cotton Tee",
"slug": "organic-cotton-tee",
"status": "visible",
"price": 2999,
"regular_price": 3999,
"currency_code": "USD",
"created_on": "2024-06-20T14:22:00Z",
"_links": {
"self": {
"href": "https://api.onbolder.com/v2/products/103"
},
"products:update": {
"href": "https://api.onbolder.com/v2/products/103",
"method": "put"
},
"products:delete": {
"href": "https://api.onbolder.com/v2/products/103",
"method": "delete"
}
}
}Not authorized to create products in this shop
{
"_embedded": {
"errors": [
{
"field": "string",
"messages": [
"string"
]
}
]
}
}