Add a variant to a product
POST
/admin/v1/products/{productId}/variants
const url = 'https://your-store.example.com/admin/v1/products/example/variants';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"sku":"example","title":"example","options":{},"priceAmount":1,"currency":"example","compareAtAmount":1,"stockQuantity":0,"allowBackorder":false,"weightGrams":1,"lengthMm":1,"widthMm":1,"heightMm":1,"position":0}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://your-store.example.com/admin/v1/products/example/variants \ --header 'Content-Type: application/json' \ --data '{ "sku": "example", "title": "example", "options": {}, "priceAmount": 1, "currency": "example", "compareAtAmount": 1, "stockQuantity": 0, "allowBackorder": false, "weightGrams": 1, "lengthMm": 1, "widthMm": 1, "heightMm": 1, "position": 0 }'Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” productId
required
string
Request Body required
Section titled “Request Body required ” Media type application/json
object
sku
string
title
string
options
object
key
additional properties
priceAmount
required
integer
currency
required
string
stockQuantity
integer
allowBackorder
boolean
position
integer