Create variant
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"is_default": true,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1
}
],
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"description": "<string>",
"images": [
"<string>"
],
"videos": [
"<string>"
],
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": true,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"related_products": {
"cross_sell": [
"<string>"
],
"upsell": [
"<string>"
]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": true,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants"
payload = [
{
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"is_default": True,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1
}
],
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"description": "<string>",
"images": ["<string>"],
"videos": ["<string>"],
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": True,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"related_products": {
"cross_sell": ["<string>"],
"upsell": ["<string>"]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": True,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: '<string>',
associated_options: [{attribute_id: '<string>', attribute_value: '<string>'}],
is_default: true,
short_description: '<string>',
metadata: {},
sku: '<string>',
slug: '<string>',
pricing: [
{
customer_group_id: '<string>',
cost_price: 123,
listing_price: 123,
selling_price: 123,
tax_rate: 123,
min_order_quantity: 1,
max_order_quantity: 123,
incremental_quantity: 1
}
],
variant_attributes: [{attribute_id: '<string>', attribute_value: '<string>'}],
description: '<string>',
images: ['<string>'],
videos: ['<string>'],
packaging: {
pack_width: 123,
pack_height: 123,
pack_length: 123,
pack_dry_weight: 123,
units_per_pack: 123,
vertical_rotation: true,
shipper_width: 123,
shipper_height: 123,
shipper_length: 123,
shipper_dry_weight: 123,
units_per_shipper: 123
},
related_products: {cross_sell: ['<string>'], upsell: ['<string>']},
promotions: {
promotion_type: 'discount',
starts_at: '<string>',
details: [
{
discount_type: 'percentage',
discount_percent: 123,
customer_group_id: '<string>',
minimum_quantity: 1,
maximum_quantity: 123,
maximum_discount_amount: 123
}
],
expires_at: '<string>'
},
subscriptions: [
{
subscription_plan: '<string>',
billing_interval: 123,
billing_frequency: 'monthly',
billing_limit: 123,
billing_trial_days: 0,
fulfill_separately: true,
subscription_price: [{suscription_price: 123, minimum_quantity: 1, customer_group_id: '<string>'}],
order_interval: 123,
order_frequency: 'monthly',
order_limit: 123
}
]
}
])
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => '<string>',
'associated_options' => [
[
'attribute_id' => '<string>',
'attribute_value' => '<string>'
]
],
'is_default' => true,
'short_description' => '<string>',
'metadata' => [
],
'sku' => '<string>',
'slug' => '<string>',
'pricing' => [
[
'customer_group_id' => '<string>',
'cost_price' => 123,
'listing_price' => 123,
'selling_price' => 123,
'tax_rate' => 123,
'min_order_quantity' => 1,
'max_order_quantity' => 123,
'incremental_quantity' => 1
]
],
'variant_attributes' => [
[
'attribute_id' => '<string>',
'attribute_value' => '<string>'
]
],
'description' => '<string>',
'images' => [
'<string>'
],
'videos' => [
'<string>'
],
'packaging' => [
'pack_width' => 123,
'pack_height' => 123,
'pack_length' => 123,
'pack_dry_weight' => 123,
'units_per_pack' => 123,
'vertical_rotation' => true,
'shipper_width' => 123,
'shipper_height' => 123,
'shipper_length' => 123,
'shipper_dry_weight' => 123,
'units_per_shipper' => 123
],
'related_products' => [
'cross_sell' => [
'<string>'
],
'upsell' => [
'<string>'
]
],
'promotions' => [
'promotion_type' => 'discount',
'starts_at' => '<string>',
'details' => [
[
'discount_type' => 'percentage',
'discount_percent' => 123,
'customer_group_id' => '<string>',
'minimum_quantity' => 1,
'maximum_quantity' => 123,
'maximum_discount_amount' => 123
]
],
'expires_at' => '<string>'
],
'subscriptions' => [
[
'subscription_plan' => '<string>',
'billing_interval' => 123,
'billing_frequency' => 'monthly',
'billing_limit' => 123,
'billing_trial_days' => 0,
'fulfill_separately' => true,
'subscription_price' => [
[
'suscription_price' => 123,
'minimum_quantity' => 1,
'customer_group_id' => '<string>'
]
],
'order_interval' => 123,
'order_frequency' => 'monthly',
'order_limit' => 123
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants"
payload := strings.NewReader("[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true,
"content": {
"variants": [
{
"id": "<string>",
"active": true,
"stock_available": true,
"is_default": true,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"hsn_code": "<string>",
"on_offer": true,
"on_promotion": true,
"on_subscription": true,
"product_type": "physical",
"product_id": "<string>",
"product_name": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
],
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_name": "<string>",
"attribute_type": "text",
"attribute_value": "<string>",
"key": "<string>"
}
],
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"description": "<string>",
"videos": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"video_preview_url": "<string>",
"video_stream_hls_url": "<string>",
"video_stream_dash_url": "<string>",
"image_thumbnail_url": "<string>",
"video_duration": 123,
"file_id": "<string>"
}
],
"seo": {
"title": "<string>",
"description": "<string>",
"keywords": "<array>"
},
"shipping": {
"handling_charge": 1
},
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": true,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"sales_channels": [
{
"id": "<string>",
"name": "<string>",
"kind": "storefront",
"active": true
}
],
"related_products": {
"upsell": [
{
"id": "<string>",
"product_id": "<string>",
"product_name": "<string>",
"product_type": "physical",
"status": "draft",
"tags": [
"<string>"
],
"reviews_rating_sum": 123,
"reviews_count": 123,
"hsn_code": "<string>",
"variant_id": "<string>",
"variant_name": "<string>",
"slug": "<string>",
"sku": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"active": true,
"stock_available": true,
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
]
}
],
"cross_sell": [
{
"id": "<string>",
"product_id": "<string>",
"product_name": "<string>",
"product_type": "physical",
"status": "draft",
"tags": [
"<string>"
],
"reviews_rating_sum": 123,
"reviews_count": 123,
"hsn_code": "<string>",
"variant_id": "<string>",
"variant_name": "<string>",
"slug": "<string>",
"sku": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"active": true,
"stock_available": true,
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
]
}
]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"id": "<string>",
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": true,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"subscription_plan_id": "<string>",
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
}
}Catalog
Create variant
Create variant
POST
/
catalog
/
products
/
{id}
/
variants
Create variant
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"is_default": true,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1
}
],
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"description": "<string>",
"images": [
"<string>"
],
"videos": [
"<string>"
],
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": true,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"related_products": {
"cross_sell": [
"<string>"
],
"upsell": [
"<string>"
]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": true,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants"
payload = [
{
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"is_default": True,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1
}
],
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_value": "<string>"
}
],
"description": "<string>",
"images": ["<string>"],
"videos": ["<string>"],
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": True,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"related_products": {
"cross_sell": ["<string>"],
"upsell": ["<string>"]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": True,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
name: '<string>',
associated_options: [{attribute_id: '<string>', attribute_value: '<string>'}],
is_default: true,
short_description: '<string>',
metadata: {},
sku: '<string>',
slug: '<string>',
pricing: [
{
customer_group_id: '<string>',
cost_price: 123,
listing_price: 123,
selling_price: 123,
tax_rate: 123,
min_order_quantity: 1,
max_order_quantity: 123,
incremental_quantity: 1
}
],
variant_attributes: [{attribute_id: '<string>', attribute_value: '<string>'}],
description: '<string>',
images: ['<string>'],
videos: ['<string>'],
packaging: {
pack_width: 123,
pack_height: 123,
pack_length: 123,
pack_dry_weight: 123,
units_per_pack: 123,
vertical_rotation: true,
shipper_width: 123,
shipper_height: 123,
shipper_length: 123,
shipper_dry_weight: 123,
units_per_shipper: 123
},
related_products: {cross_sell: ['<string>'], upsell: ['<string>']},
promotions: {
promotion_type: 'discount',
starts_at: '<string>',
details: [
{
discount_type: 'percentage',
discount_percent: 123,
customer_group_id: '<string>',
minimum_quantity: 1,
maximum_quantity: 123,
maximum_discount_amount: 123
}
],
expires_at: '<string>'
},
subscriptions: [
{
subscription_plan: '<string>',
billing_interval: 123,
billing_frequency: 'monthly',
billing_limit: 123,
billing_trial_days: 0,
fulfill_separately: true,
subscription_price: [{suscription_price: 123, minimum_quantity: 1, customer_group_id: '<string>'}],
order_interval: 123,
order_frequency: 'monthly',
order_limit: 123
}
]
}
])
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => '<string>',
'associated_options' => [
[
'attribute_id' => '<string>',
'attribute_value' => '<string>'
]
],
'is_default' => true,
'short_description' => '<string>',
'metadata' => [
],
'sku' => '<string>',
'slug' => '<string>',
'pricing' => [
[
'customer_group_id' => '<string>',
'cost_price' => 123,
'listing_price' => 123,
'selling_price' => 123,
'tax_rate' => 123,
'min_order_quantity' => 1,
'max_order_quantity' => 123,
'incremental_quantity' => 1
]
],
'variant_attributes' => [
[
'attribute_id' => '<string>',
'attribute_value' => '<string>'
]
],
'description' => '<string>',
'images' => [
'<string>'
],
'videos' => [
'<string>'
],
'packaging' => [
'pack_width' => 123,
'pack_height' => 123,
'pack_length' => 123,
'pack_dry_weight' => 123,
'units_per_pack' => 123,
'vertical_rotation' => true,
'shipper_width' => 123,
'shipper_height' => 123,
'shipper_length' => 123,
'shipper_dry_weight' => 123,
'units_per_shipper' => 123
],
'related_products' => [
'cross_sell' => [
'<string>'
],
'upsell' => [
'<string>'
]
],
'promotions' => [
'promotion_type' => 'discount',
'starts_at' => '<string>',
'details' => [
[
'discount_type' => 'percentage',
'discount_percent' => 123,
'customer_group_id' => '<string>',
'minimum_quantity' => 1,
'maximum_quantity' => 123,
'maximum_discount_amount' => 123
]
],
'expires_at' => '<string>'
],
'subscriptions' => [
[
'subscription_plan' => '<string>',
'billing_interval' => 123,
'billing_frequency' => 'monthly',
'billing_limit' => 123,
'billing_trial_days' => 0,
'fulfill_separately' => true,
'subscription_price' => [
[
'suscription_price' => 123,
'minimum_quantity' => 1,
'customer_group_id' => '<string>'
]
],
'order_interval' => 123,
'order_frequency' => 'monthly',
'order_limit' => 123
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants"
payload := strings.NewReader("[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/catalog/products/{id}/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"<string>\",\n \"associated_options\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"is_default\": true,\n \"short_description\": \"<string>\",\n \"metadata\": {},\n \"sku\": \"<string>\",\n \"slug\": \"<string>\",\n \"pricing\": [\n {\n \"customer_group_id\": \"<string>\",\n \"cost_price\": 123,\n \"listing_price\": 123,\n \"selling_price\": 123,\n \"tax_rate\": 123,\n \"min_order_quantity\": 1,\n \"max_order_quantity\": 123,\n \"incremental_quantity\": 1\n }\n ],\n \"variant_attributes\": [\n {\n \"attribute_id\": \"<string>\",\n \"attribute_value\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"images\": [\n \"<string>\"\n ],\n \"videos\": [\n \"<string>\"\n ],\n \"packaging\": {\n \"pack_width\": 123,\n \"pack_height\": 123,\n \"pack_length\": 123,\n \"pack_dry_weight\": 123,\n \"units_per_pack\": 123,\n \"vertical_rotation\": true,\n \"shipper_width\": 123,\n \"shipper_height\": 123,\n \"shipper_length\": 123,\n \"shipper_dry_weight\": 123,\n \"units_per_shipper\": 123\n },\n \"related_products\": {\n \"cross_sell\": [\n \"<string>\"\n ],\n \"upsell\": [\n \"<string>\"\n ]\n },\n \"promotions\": {\n \"promotion_type\": \"discount\",\n \"starts_at\": \"<string>\",\n \"details\": [\n {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"customer_group_id\": \"<string>\",\n \"minimum_quantity\": 1,\n \"maximum_quantity\": 123,\n \"maximum_discount_amount\": 123\n }\n ],\n \"expires_at\": \"<string>\"\n },\n \"subscriptions\": [\n {\n \"subscription_plan\": \"<string>\",\n \"billing_interval\": 123,\n \"billing_frequency\": \"monthly\",\n \"billing_limit\": 123,\n \"billing_trial_days\": 0,\n \"fulfill_separately\": true,\n \"subscription_price\": [\n {\n \"suscription_price\": 123,\n \"minimum_quantity\": 1,\n \"customer_group_id\": \"<string>\"\n }\n ],\n \"order_interval\": 123,\n \"order_frequency\": \"monthly\",\n \"order_limit\": 123\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true,
"content": {
"variants": [
{
"id": "<string>",
"active": true,
"stock_available": true,
"is_default": true,
"short_description": "<string>",
"metadata": {},
"sku": "<string>",
"slug": "<string>",
"hsn_code": "<string>",
"on_offer": true,
"on_promotion": true,
"on_subscription": true,
"product_type": "physical",
"product_id": "<string>",
"product_name": "<string>",
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
],
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"variant_attributes": [
{
"attribute_id": "<string>",
"attribute_name": "<string>",
"attribute_type": "text",
"attribute_value": "<string>",
"key": "<string>"
}
],
"name": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"description": "<string>",
"videos": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"video_preview_url": "<string>",
"video_stream_hls_url": "<string>",
"video_stream_dash_url": "<string>",
"image_thumbnail_url": "<string>",
"video_duration": 123,
"file_id": "<string>"
}
],
"seo": {
"title": "<string>",
"description": "<string>",
"keywords": "<array>"
},
"shipping": {
"handling_charge": 1
},
"packaging": {
"pack_width": 123,
"pack_height": 123,
"pack_length": 123,
"pack_dry_weight": 123,
"units_per_pack": 123,
"vertical_rotation": true,
"shipper_width": 123,
"shipper_height": 123,
"shipper_length": 123,
"shipper_dry_weight": 123,
"units_per_shipper": 123
},
"sales_channels": [
{
"id": "<string>",
"name": "<string>",
"kind": "storefront",
"active": true
}
],
"related_products": {
"upsell": [
{
"id": "<string>",
"product_id": "<string>",
"product_name": "<string>",
"product_type": "physical",
"status": "draft",
"tags": [
"<string>"
],
"reviews_rating_sum": 123,
"reviews_count": 123,
"hsn_code": "<string>",
"variant_id": "<string>",
"variant_name": "<string>",
"slug": "<string>",
"sku": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"active": true,
"stock_available": true,
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
]
}
],
"cross_sell": [
{
"id": "<string>",
"product_id": "<string>",
"product_name": "<string>",
"product_type": "physical",
"status": "draft",
"tags": [
"<string>"
],
"reviews_rating_sum": 123,
"reviews_count": 123,
"hsn_code": "<string>",
"variant_id": "<string>",
"variant_name": "<string>",
"slug": "<string>",
"sku": "<string>",
"associated_options": [
{
"attribute_id": "<string>",
"attribute_value": "<string>",
"attribute_name": "<string>",
"attribute_type": "single-select",
"key": "<string>"
}
],
"active": true,
"stock_available": true,
"images": [
{
"title": "<string>",
"alternate_text": "<string>",
"sort_order": 123,
"url_tiny": "<string>",
"url_thumbnail": "<string>",
"url_standard": "<string>",
"url_zoom": "<string>",
"file_id": "<string>",
"file_type": "image"
}
],
"pricing": [
{
"customer_group_id": "<string>",
"cost_price": 123,
"listing_price": 123,
"selling_price": 123,
"tax_rate": 123,
"min_order_quantity": 1,
"max_order_quantity": 123,
"incremental_quantity": 1,
"tax_type": "GST"
}
]
}
]
},
"promotions": {
"promotion_type": "discount",
"starts_at": "<string>",
"details": [
{
"discount_type": "percentage",
"discount_percent": 123,
"customer_group_id": "<string>",
"minimum_quantity": 1,
"maximum_quantity": 123,
"maximum_discount_amount": 123
}
],
"id": "<string>",
"expires_at": "<string>"
},
"subscriptions": [
{
"subscription_plan": "<string>",
"billing_interval": 123,
"billing_frequency": "monthly",
"billing_limit": 123,
"billing_trial_days": 0,
"fulfill_separately": true,
"subscription_price": [
{
"suscription_price": 123,
"minimum_quantity": 1,
"customer_group_id": "<string>"
}
],
"subscription_plan_id": "<string>",
"order_interval": 123,
"order_frequency": "monthly",
"order_limit": 123
}
]
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
product id
Body
application/json
Show child attributes
Show child attributes
Show child attributes
Show child attributes
variant sku. can be null for digital product.
variant sku. can be null for digital product.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
promotion_type = discount
- DiscountBasedPromotion
- FixedPricePromotion
- VolumeBasedPromotion
- FreeGoodsPromotion
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I