API reference
Sizes (variants)
On this page
A size (a variant) is a version of a product with its own price, MRP, SKU and weight, for example 250 g or 500 g. A new size starts with 0 in stock; stock changes only through stock adjustments. A size cannot be deleted through the API.
The size object#
| Field | Type | Meaning |
|---|---|---|
id | integer | The size id. |
product_id | integer | The id of the product the size belongs to. |
sku | string or null | The SKU of this size. null when it has none. |
label | string | The size label, for example "250 g". |
price | integer | Selling price, in whole units of the store's currency. |
mrp | integer | MRP, in whole units of the store's currency. |
weight_grams | integer or null | Shipping weight in grams. |
sort | integer | Position among the sizes of the product. |
stock | integer | Units available to sell. Read only: use POST /inventory/adjustments to change it. |
created_at | string | When the size was created (ISO 8601, UTC). |
updated_at | string | When the size was last changed (ISO 8601, UTC). |
List the sizes of a product#
GET/api/v1/products/{id}/variantsread:products
Every size of the product with price, MRP, SKU, weight and the current stock (read only).
This list is not paged: it returns every size of the product. meta is empty.
Address parameters
| Name | Type | Meaning |
|---|---|---|
id | integer | The product id (a whole number). |
Example request
curl -s "https://yourstore.example.com/api/v1/products/7/variants" \
-H "Authorization: Bearer YOUR_API_KEY"<?php
$ch = curl_init('https://yourstore.example.com/api/v1/products/7/variants');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
],
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
// $response['error']['code'] and $response['error']['message'] say what to fix
}// Node.js 18 or newer (fetch is built in). Save as call.mjs and run: node call.mjs
const res = await fetch('https://yourstore.example.com/api/v1/products/7/variants', {
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const json = await res.json();
if (!res.ok) {
// json.error.code and json.error.message say what to fix
}# Python 3 with the requests library (pip install requests)
import requests
res = requests.get(
"https://yourstore.example.com/api/v1/products/7/variants",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
data = res.json()
if not res.ok:
# data["error"]["code"] and data["error"]["message"] say what to fix
print(data["error"])Example answer (200 OK)
{
"data": [
{
"id": 31,
"product_id": 7,
"sku": "SAMPLE-001-250",
"label": "250 g",
"price": 399,
"mrp": 449,
"weight_grams": 250,
"sort": 0,
"stock": 120,
"created_at": "2026-11-01T09:00:00Z",
"updated_at": "2026-11-21T10:00:00Z"
}
],
"meta": {}
}Errors
| Status | Code | When |
|---|---|---|
| 401 | missing_api_key, invalid_api_key, revoked_api_key, expired_api_key | The key is missing, not valid, revoked or expired. |
| 403 | insufficient_scope | The key does not have the read:products scope. error.required_scope names it. (api_key_disabled and ip_not_allowed also give 403.) |
| 404 | not_found | That product does not exist. |
| 429 | rate_limited | More requests than the key's limit in a minute. Wait for Retry-After. |
Example error answer (403):
{
"error": {
"code": "insufficient_scope",
"message": "This API key does not have the \"read:products\" scope. Add it to the key in the admin (API & webhooks > API keys), or use a key that has it.",
"required_scope": "read:products"
}
}Add a size#
POST/api/v1/products/{id}/variantswrite:products
Adds a size to a product. It starts with 0 in stock: use POST /inventory/adjustments to add stock.
The size starts with 0 in stock. Add stock with POST /inventory/adjustments.
Address parameters
| Name | Type | Meaning |
|---|---|---|
id | integer | The product id (a whole number). |
Request body (JSON)
| Field | Type | Required | Limits | Meaning |
|---|---|---|---|---|
label | string | Yes | at most 100 characters | Size label, for example "250 g". Example: 250 g |
price | integer | Yes | at least 0 | Selling price in whole units of the store's currency. Example: 399 |
mrp | integer | Yes | at least 0 | MRP (the printed maximum price) in whole units of the store's currency. Example: 449 |
sku | string or null | No | at most 100 characters | SKU of this size (unique). Used by POST /inventory/adjustments. Example: SAMPLE-001-250 |
weight_grams | integer or null | No | 0 to 1000000 | Shipping weight in grams. Example: 250 |
Any field not listed here is refused with 422. Send an Idempotency-Key header so a retry is safe (see Requests).
Example request
curl -s -X POST "https://yourstore.example.com/api/v1/products/7/variants" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c0b3e-0d5a-4a52-9d5e-1f6c2a7b9e10" \
-d '{
"label": "500 g",
"price": 749,
"mrp": 849,
"sku": "SAMPLE-001-500",
"weight_grams": 500
}'<?php
$ch = curl_init('https://yourstore.example.com/api/v1/products/7/variants');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode([
'label' => '500 g',
'price' => 749,
'mrp' => 849,
'sku' => 'SAMPLE-001-500',
'weight_grams' => 500,
]),
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
// $response['error']['code'] and $response['error']['message'] say what to fix
}// Node.js 18 or newer (fetch is built in). Save as call.mjs and run: node call.mjs
import { randomUUID } from 'node:crypto';
const res = await fetch('https://yourstore.example.com/api/v1/products/7/variants', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
'Idempotency-Key': randomUUID(),
},
body: JSON.stringify({
label: '500 g',
price: 749,
mrp: 849,
sku: 'SAMPLE-001-500',
weight_grams: 500,
}),
});
const json = await res.json();
if (!res.ok) {
// json.error.code and json.error.message say what to fix
}# Python 3 with the requests library (pip install requests)
import uuid
import requests
res = requests.post(
"https://yourstore.example.com/api/v1/products/7/variants",
headers={"Authorization": "Bearer YOUR_API_KEY", "Idempotency-Key": str(uuid.uuid4())},
json={
"label": "500 g",
"price": 749,
"mrp": 849,
"sku": "SAMPLE-001-500",
"weight_grams": 500,
},
timeout=30,
)
data = res.json()
if not res.ok:
# data["error"]["code"] and data["error"]["message"] say what to fix
print(data["error"])Example answer (201 Created)
{
"data": {
"id": 31,
"product_id": 7,
"sku": "SAMPLE-001-250",
"label": "250 g",
"price": 399,
"mrp": 449,
"weight_grams": 250,
"sort": 0,
"stock": 120,
"created_at": "2026-11-01T09:00:00Z",
"updated_at": "2026-11-21T10:00:00Z"
},
"meta": {}
}Errors
| Status | Code | When |
|---|---|---|
| 401 | missing_api_key, invalid_api_key, revoked_api_key, expired_api_key | The key is missing, not valid, revoked or expired. |
| 403 | insufficient_scope | The key does not have the write:products scope. error.required_scope names it. (api_key_disabled and ip_not_allowed also give 403.) |
| 404 | not_found | That product does not exist. |
| 422 | validation_failed | A field is missing or wrong. error.fields says which and why. |
| 409 | idempotency_key_reuse, idempotency_in_progress | The Idempotency-Key was used for a different request, or the first request with it is still running. |
| 429 | rate_limited | More requests than the key's limit in a minute. Wait for Retry-After. |
Example error answer (422):
{
"error": {
"code": "validation_failed",
"message": "The request could not be accepted. See \"fields\" for what to fix.",
"fields": {
"label": [
"The label field is required."
]
}
}
}Update a size#
PATCH/api/v1/products/{id}/variants/{variantId}write:products
Changes label, price, MRP, SKU or weight of one size. Stock is not accepted here. A size cannot be deleted through the API.
Address parameters
| Name | Type | Meaning |
|---|---|---|
id | integer | The product id (a whole number). |
variantId | integer | The size id (a whole number). |
Request body (JSON)
| Field | Type | Required | Limits | Meaning |
|---|---|---|---|---|
label | string | No | at most 100 characters | Size label, for example "250 g". Example: 250 g |
price | integer | No | at least 0 | Selling price in whole units of the store's currency. Example: 399 |
mrp | integer | No | at least 0 | MRP (the printed maximum price) in whole units of the store's currency. Example: 449 |
sku | string or null | No | at most 100 characters | SKU of this size (unique). Used by POST /inventory/adjustments. Example: SAMPLE-001-250 |
weight_grams | integer or null | No | 0 to 1000000 | Shipping weight in grams. Example: 250 |
Any field not listed here is refused with 422. Send an Idempotency-Key header so a retry is safe (see Requests).
Example request
curl -s -X PATCH "https://yourstore.example.com/api/v1/products/7/variants/31" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c0b3e-0d5a-4a52-9d5e-1f6c2a7b9e10" \
-d '{
"price": 389,
"mrp": 449
}'<?php
$ch = curl_init('https://yourstore.example.com/api/v1/products/7/variants/31');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
'Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode([
'price' => 389,
'mrp' => 449,
]),
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
// $response['error']['code'] and $response['error']['message'] say what to fix
}// Node.js 18 or newer (fetch is built in). Save as call.mjs and run: node call.mjs
import { randomUUID } from 'node:crypto';
const res = await fetch('https://yourstore.example.com/api/v1/products/7/variants/31', {
method: 'PATCH',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
'Idempotency-Key': randomUUID(),
},
body: JSON.stringify({
price: 389,
mrp: 449,
}),
});
const json = await res.json();
if (!res.ok) {
// json.error.code and json.error.message say what to fix
}# Python 3 with the requests library (pip install requests)
import uuid
import requests
res = requests.patch(
"https://yourstore.example.com/api/v1/products/7/variants/31",
headers={"Authorization": "Bearer YOUR_API_KEY", "Idempotency-Key": str(uuid.uuid4())},
json={
"price": 389,
"mrp": 449,
},
timeout=30,
)
data = res.json()
if not res.ok:
# data["error"]["code"] and data["error"]["message"] say what to fix
print(data["error"])Example answer (200 OK)
{
"data": {
"id": 31,
"product_id": 7,
"sku": "SAMPLE-001-250",
"label": "250 g",
"price": 399,
"mrp": 449,
"weight_grams": 250,
"sort": 0,
"stock": 120,
"created_at": "2026-11-01T09:00:00Z",
"updated_at": "2026-11-21T10:00:00Z"
},
"meta": {}
}Errors
| Status | Code | When |
|---|---|---|
| 401 | missing_api_key, invalid_api_key, revoked_api_key, expired_api_key | The key is missing, not valid, revoked or expired. |
| 403 | insufficient_scope | The key does not have the write:products scope. error.required_scope names it. (api_key_disabled and ip_not_allowed also give 403.) |
| 404 | not_found | That product or size does not exist. |
| 422 | validation_failed | A field is missing or wrong. error.fields says which and why. |
| 409 | idempotency_key_reuse, idempotency_in_progress | The Idempotency-Key was used for a different request, or the first request with it is still running. |
| 429 | rate_limited | More requests than the key's limit in a minute. Wait for Retry-After. |
Example error answer (422):
{
"error": {
"code": "validation_failed",
"message": "The request could not be accepted. See \"fields\" for what to fix.",
"fields": {
"label": [
"The label field is required."
]
}
}
}