Create a product with its variants
POST
/api/v1/workspaces/{workspaceId}/products
const url = 'https://api.crossmart.io/api/v1/workspaces/example/products';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"title":"example","descriptionHtml":"example","vendor":"example","productType":"example","tags":["example"],"status":"DRAFT","optionNames":["Size","Color"],"media":[{"url":"https://cdn.example.com/mug.jpg","altText":"example"}],"handle":"example","variants":[{"sku":"example","barcode":"example","optionValues":["example"],"price":"19.90","compareAtPrice":"24.90","cost":"40.00","weightGrams":1,"requiresShipping":true,"taxable":true,"outOfStockPolicy":"STOP_SELLING","tracked":true,"quantity":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://api.crossmart.io/api/v1/workspaces/example/products \ --header 'Content-Type: application/json' \ --data '{ "title": "example", "descriptionHtml": "example", "vendor": "example", "productType": "example", "tags": [ "example" ], "status": "DRAFT", "optionNames": [ "Size", "Color" ], "media": [ { "url": "https://cdn.example.com/mug.jpg", "altText": "example" } ], "handle": "example", "variants": [ { "sku": "example", "barcode": "example", "optionValues": [ "example" ], "price": "19.90", "compareAtPrice": "24.90", "cost": "40.00", "weightGrams": 1, "requiresShipping": true, "taxable": true, "outOfStockPolicy": "STOP_SELLING", "tracked": true, "quantity": 0 } ] }'Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”workspaceId
required
string
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
title
required
string
descriptionHtml
string
vendor
string
productType
string
tags
Array<string>
status
string
optionNames
Array<string>
Example
[ "Size", "Color"]media
Array<object>
object
url
required
string
Example
https://cdn.example.com/mug.jpgaltText
string
handle
Unique in the workspace. Defaults to the slugified title, or to product-<random id> when the title has no Latin letters or digits (such as a Hebrew title).
string
variants
required
Array<object>
object
sku
string
barcode
GTIN, UPC, EAN or ISBN
string
optionValues
One value per product option, in order
Array<string>
price
required
string
Example
19.90compareAtPrice
string
Example
24.90cost
What you pay per unit. Used for pricing floors; never shown to buyers.
string
Example
40.00weightGrams
number
requiresShipping
boolean
taxable
boolean
outOfStockPolicy
string
tracked
Track stock for this variant
boolean
quantity
Opening stock
number
Responses
Section titled “Responses”Media typeapplication/json
object
id
required
string format: uuid
handle
required
string
title
required
string
descriptionHtml
required
string
vendor
required
string
productType
required
string
tags
required
Array<string>
status
required
string
optionNames
required
Array<string>
variants
required
Array<object>
object
id
required
string format: uuid
position
required
number
sku
required
string
barcode
required
GTIN, UPC, EAN or ISBN
string
optionValues
required
One value per product option, in order
Array<string>
price
required
Decimal string in the workspace currency
string
compareAtPrice
required
string
cost
required
What you pay per unit; never shown to buyers
string
weightGrams
required
number
requiresShipping
required
boolean
taxable
required
boolean
outOfStockPolicy
required
string
tracked
required
Whether Crossmart tracks stock for this variant
boolean
available
required
number
media
required
Array<object>
object
id
required
string format: uuid
url
required
string
altText
required
string
position
required
number
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
Example
{ "status": "DRAFT", "optionNames": [ "Size", "Color" ], "variants": [ { "price": "89.00", "compareAtPrice": "99.00", "cost": "40.00", "outOfStockPolicy": "STOP_SELLING" } ]}