Import products or stock from a file
const url = 'https://api.crossmart.io/api/v1/workspaces/example/product-imports';const form = new FormData();form.append('format', 'shopify_csv');form.append('mode', 'create');form.append('file', 'binary');
const options = {method: 'POST'};
options.body = form;
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/product-imports \ --header 'Content-Type: multipart/form-data' \ --form format=shopify_csv \ --form mode=create \ --form file=binaryIn create mode, products whose handle is already in the catalog are skipped, never overwritten. In update mode, products are found by handle and only the columns in the file change: a missing column keeps its value, an empty cell clears it. Variants are matched by SKU, then by option values, and are never deleted; stock is left as it is. In inventory mode, a sku,available CSV sets the stock of tracked variants. Invalid records are reported; the rest are applied. Every import is recorded in the import history. Product modes need products:edit, inventory needs inventory:edit.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
create adds new products (Shopify CSV), update replaces products matched by handle (Shopify CSV) and inventory sets stock by SKU (inventory CSV)
The catalog file
Responses
Section titled “Responses”object
The import history entry of this import
Products replaced by an update import
Variants whose stock an inventory import set
Records left as they were: already in the catalog, not found, stock not tracked
object
Spreadsheet row number; the header is row 1
Records that could not be imported
object
Spreadsheet row number; the header is row 1
Example
{ "mode": "create", "skipped": [ { "code": "already_exists" } ], "failed": [ { "code": "already_exists" } ]}