Create a product
const url = 'https://digize.com/api/v1/commerce/products';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"name":"example","slug":"example","description":"example","category":"example","vendor":"example","type":"physical","status":"active","color":"primary","tags":["example"],"options":[{"name":"example","values":["example"]}],"variants":[{"id":"example","label":"example","options":["example"],"sku":"example","barcode":"example","price":1,"cost":1,"compareAtPrice":1,"weight":1,"reorderAt":1,"onHand":1,"imageId":"example"}],"channels":["storefront"],"chargeTax":true,"continueSelling":true,"seo":{"title":"example","description":"example"},"images":[{"imageId":"example","alt":"example"}],"subscription":{"interval":"week","every":1},"collectionIds":["example"],"id":"example"}'};
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://digize.com/api/v1/commerce/products \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "name": "example", "slug": "example", "description": "example", "category": "example", "vendor": "example", "type": "physical", "status": "active", "color": "primary", "tags": [ "example" ], "options": [ { "name": "example", "values": [ "example" ] } ], "variants": [ { "id": "example", "label": "example", "options": [ "example" ], "sku": "example", "barcode": "example", "price": 1, "cost": 1, "compareAtPrice": 1, "weight": 1, "reorderAt": 1, "onHand": 1, "imageId": "example" } ], "channels": [ "storefront" ], "chargeTax": true, "continueSelling": true, "seo": { "title": "example", "description": "example" }, "images": [ { "imageId": "example", "alt": "example" } ], "subscription": { "interval": "week", "every": 1 }, "collectionIds": [ "example" ], "id": "example" }'Adds a product with its variants. Active products in the storefront channel show on the storefront a few seconds later.
Needs the commerce:write permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.
Example
5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69Request Bodyrequired
Section titled “Request Bodyrequired”object
The storefront URL segment; made from the name when left out.
object
object
Left out for a new variant.
In the store currency’s minor unit: 1900 is $19.00.
In the store currency’s minor unit: 1900 is $19.00.
Sets the count on hand.
object
Upload each first with commerce.products.createImageUpload.
object
The manual collections it’s in.
Responses
Section titled “Responses”Done
object
object
object
“12 oz · Whole bean”, or “Default” for a product with one variant.
On hand at the locations that ship online orders.
Held by open checkouts for 30 minutes.
In grams.
object
object
Example
{ "type": "physical", "status": "active", "color": "primary", "channels": [ "storefront" ], "subscription": { "interval": "week" }}What was sent isn’t valid (invalid).
object
object
object
Example
{ "error": { "code": "invalid" }}No key, or one that’s unknown, off or expired.
object
object
object
Example
{ "error": { "code": "invalid" }}The key doesn’t have the permission this needs.
object
object
object
Example
{ "error": { "code": "invalid" }}Nothing has that id (not_found).
object
object
object
Example
{ "error": { "code": "invalid" }}A request with the same Idempotency-Key is still running (conflict).
object
object
object
Example
{ "error": { "code": "invalid" }}The Idempotency-Key was used with a different request.
object
object
object
Example
{ "error": { "code": "invalid" }}Over the rate limit; see retry-after.
object
object
object
Example
{ "error": { "code": "invalid" }}