Create
curl --request POST \
--url https://{defaultHost}/v1/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"variant": {
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"option_1": "Red",
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
}
}
}
'import requests
url = "https://{defaultHost}/v1/variants"
payload = { "variant": {
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"option_1": "Red",
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
}
} }
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({
variant: {
product: '78cd6ad5-b6d3-40bb-9803-827c4642c4ab',
option_1: 'Red',
dimensions: {length: 12, width: 8, height: 4, unit: 'cm'}
}
})
};
fetch('https://{defaultHost}/v1/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://{defaultHost}/v1/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([
'variant' => [
'product' => '78cd6ad5-b6d3-40bb-9803-827c4642c4ab',
'option_1' => 'Red',
'dimensions' => [
'length' => 12,
'width' => 8,
'height' => 4,
'unit' => 'cm'
]
]
]),
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://{defaultHost}/v1/variants"
payload := strings.NewReader("{\n \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\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://{defaultHost}/v1/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/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 \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "4b372a51-183b-4b0e-9234-55b2e850876e",
"object": "variant",
"amount": null,
"available_stock": 0,
"allow_out_of_stock_purchases": null,
"auto_fulfill_enabled": null,
"currency": "usd",
"current_version": true,
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
},
"downloads_enabled": true,
"held_stock": 0,
"license_activation_limit": null,
"metadata": {},
"option_1": "Red",
"option_2": null,
"option_3": null,
"option_names": [
"Color"
],
"position": 1,
"purchase_limit": null,
"shipping_enabled": null,
"sku": null,
"stock": 0,
"stock_enabled": null,
"tax_category": null,
"tax_enabled": null,
"weight_unit": null,
"hs_code": null,
"country_of_origin": null,
"manufacturer_code": null,
"google_product_data": {
"gtin": null,
"mpn": null,
"condition": null,
"age_group": null,
"gender": null,
"color": null,
"size": null,
"size_type": null,
"size_system": null,
"material": null,
"pattern": null
},
"weight": null,
"current_release_download": null,
"image": null,
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"created_at": 1796064005,
"updated_at": 1796064005
}Variants
Create
Creates a new variant.
POST
/
v1
/
variants
Create
curl --request POST \
--url https://{defaultHost}/v1/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"variant": {
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"option_1": "Red",
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
}
}
}
'import requests
url = "https://{defaultHost}/v1/variants"
payload = { "variant": {
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"option_1": "Red",
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
}
} }
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({
variant: {
product: '78cd6ad5-b6d3-40bb-9803-827c4642c4ab',
option_1: 'Red',
dimensions: {length: 12, width: 8, height: 4, unit: 'cm'}
}
})
};
fetch('https://{defaultHost}/v1/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://{defaultHost}/v1/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([
'variant' => [
'product' => '78cd6ad5-b6d3-40bb-9803-827c4642c4ab',
'option_1' => 'Red',
'dimensions' => [
'length' => 12,
'width' => 8,
'height' => 4,
'unit' => 'cm'
]
]
]),
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://{defaultHost}/v1/variants"
payload := strings.NewReader("{\n \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\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://{defaultHost}/v1/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/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 \"variant\": {\n \"product\": \"78cd6ad5-b6d3-40bb-9803-827c4642c4ab\",\n \"option_1\": \"Red\",\n \"dimensions\": {\n \"length\": 12,\n \"width\": 8,\n \"height\": 4,\n \"unit\": \"cm\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "4b372a51-183b-4b0e-9234-55b2e850876e",
"object": "variant",
"amount": null,
"available_stock": 0,
"allow_out_of_stock_purchases": null,
"auto_fulfill_enabled": null,
"currency": "usd",
"current_version": true,
"dimensions": {
"length": 12,
"width": 8,
"height": 4,
"unit": "cm"
},
"downloads_enabled": true,
"held_stock": 0,
"license_activation_limit": null,
"metadata": {},
"option_1": "Red",
"option_2": null,
"option_3": null,
"option_names": [
"Color"
],
"position": 1,
"purchase_limit": null,
"shipping_enabled": null,
"sku": null,
"stock": 0,
"stock_enabled": null,
"tax_category": null,
"tax_enabled": null,
"weight_unit": null,
"hs_code": null,
"country_of_origin": null,
"manufacturer_code": null,
"google_product_data": {
"gtin": null,
"mpn": null,
"condition": null,
"age_group": null,
"gender": null,
"color": null,
"size": null,
"size_type": null,
"size_system": null,
"material": null,
"pattern": null
},
"weight": null,
"current_release_download": null,
"image": null,
"product": "78cd6ad5-b6d3-40bb-9803-827c4642c4ab",
"created_at": 1796064005,
"updated_at": 1796064005
}Authorizations
Response
200 - application/json
Success
Whether or not downloads are enabled for this variant. When false, downloads will be disabled for this variant. When true, the downloads that are set for this variant will override the product downloads. If no downloads are set, then the product downloads will be used.
Expandable – The associated download ID.
Expandable – The associated media ID.
Expandable – The associated product ID.
Was this page helpful?