Products
Create product variant
Developer API operation for POST /dev/v1/products//variants.
POST
/
dev
/
v1
/
products
/
{id}
/
variants
Create product variant
curl --request POST \
--url https://api.shoppex.io/dev/v1/products/{id}/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "New",
"description": null,
"price": 9,
"price_modifier": null,
"stock": 3,
"stock_delimiter": null,
"license_period": null,
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"option_values": {
"region": "eu"
},
"is_default": false,
"sort_order": 0
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'New',
description: null,
price: 9,
price_modifier: null,
stock: 3,
stock_delimiter: null,
license_period: null,
file_id: '550e8400-e29b-41d4-a716-446655440000',
dynamic_webhook: 'https://example.com/variant-hook',
option_values: {region: 'eu'},
is_default: false,
sort_order: 0
})
};
fetch('https://api.shoppex.io/dev/v1/products/{id}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/products/{id}/variants"
payload = {
"title": "New",
"description": None,
"price": 9,
"price_modifier": None,
"stock": 3,
"stock_delimiter": None,
"license_period": None,
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"option_values": { "region": "eu" },
"is_default": False,
"sort_order": 0
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/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([
'title' => 'New',
'description' => null,
'price' => 9,
'price_modifier' => null,
'stock' => 3,
'stock_delimiter' => null,
'license_period' => null,
'file_id' => '550e8400-e29b-41d4-a716-446655440000',
'dynamic_webhook' => 'https://example.com/variant-hook',
'option_values' => [
'region' => 'eu'
],
'is_default' => false,
'sort_order' => 0
]),
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://api.shoppex.io/dev/v1/products/{id}/variants"
payload := strings.NewReader("{\n \"title\": \"New\",\n \"description\": null,\n \"price\": 9,\n \"price_modifier\": null,\n \"stock\": 3,\n \"stock_delimiter\": null,\n \"license_period\": null,\n \"file_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"dynamic_webhook\": \"https://example.com/variant-hook\",\n \"option_values\": {\n \"region\": \"eu\"\n },\n \"is_default\": false,\n \"sort_order\": 0\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))
}{
"data": {}
}{
"data": {
"id": "variant_2",
"uniqid": "variant_2",
"product_uniqid": "prod_1",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"title": "New",
"description": null,
"price": 9,
"price_modifier": null,
"stock": 3,
"stock_delimiter": null,
"license_period": null,
"option_values": {
"region": "eu"
},
"is_default": false,
"sort_order": 0,
"created_at": 1711953600,
"updated_at": 1711953900
}
}Previous
Reorder product variantsDeveloper API operation for PATCH /dev/v1/products/{id}/variants/order.
Next
⌘I
Create product variant
curl --request POST \
--url https://api.shoppex.io/dev/v1/products/{id}/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "New",
"description": null,
"price": 9,
"price_modifier": null,
"stock": 3,
"stock_delimiter": null,
"license_period": null,
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"option_values": {
"region": "eu"
},
"is_default": false,
"sort_order": 0
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'New',
description: null,
price: 9,
price_modifier: null,
stock: 3,
stock_delimiter: null,
license_period: null,
file_id: '550e8400-e29b-41d4-a716-446655440000',
dynamic_webhook: 'https://example.com/variant-hook',
option_values: {region: 'eu'},
is_default: false,
sort_order: 0
})
};
fetch('https://api.shoppex.io/dev/v1/products/{id}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/products/{id}/variants"
payload = {
"title": "New",
"description": None,
"price": 9,
"price_modifier": None,
"stock": 3,
"stock_delimiter": None,
"license_period": None,
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"option_values": { "region": "eu" },
"is_default": False,
"sort_order": 0
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/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([
'title' => 'New',
'description' => null,
'price' => 9,
'price_modifier' => null,
'stock' => 3,
'stock_delimiter' => null,
'license_period' => null,
'file_id' => '550e8400-e29b-41d4-a716-446655440000',
'dynamic_webhook' => 'https://example.com/variant-hook',
'option_values' => [
'region' => 'eu'
],
'is_default' => false,
'sort_order' => 0
]),
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://api.shoppex.io/dev/v1/products/{id}/variants"
payload := strings.NewReader("{\n \"title\": \"New\",\n \"description\": null,\n \"price\": 9,\n \"price_modifier\": null,\n \"stock\": 3,\n \"stock_delimiter\": null,\n \"license_period\": null,\n \"file_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"dynamic_webhook\": \"https://example.com/variant-hook\",\n \"option_values\": {\n \"region\": \"eu\"\n },\n \"is_default\": false,\n \"sort_order\": 0\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))
}{
"data": {}
}{
"data": {
"id": "variant_2",
"uniqid": "variant_2",
"product_uniqid": "prod_1",
"file_id": "550e8400-e29b-41d4-a716-446655440000",
"dynamic_webhook": "https://example.com/variant-hook",
"title": "New",
"description": null,
"price": 9,
"price_modifier": null,
"stock": 3,
"stock_delimiter": null,
"license_period": null,
"option_values": {
"region": "eu"
},
"is_default": false,
"sort_order": 0,
"created_at": 1711953600,
"updated_at": 1711953900
}
}