bulkCreateProducts
Requires permission products:product:create.
Creates products from a list of rows, each with a product name, SKU and optional category, brand, prices, cost, stock and unit. Missing categories and brands are created by name. Rows are processed one by one; the result lists what was created and the error for each row that failed. Requires permission to create products.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation BulkCreateProducts($input: BulkCreateProductsInput!) {
bulkCreateProducts(input: $input) {
createdCount
failedCount
success
created {
productName
productId
rowIndex
sku
variantId
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation BulkCreateProducts($input: BulkCreateProductsInput!) {\n bulkCreateProducts(input: $input) {\n createdCount\n failedCount\n success\n created {\n productName\n productId\n rowIndex\n sku\n variantId\n }\n }\n}",
"variables": {
"input": {
"rows": [
{
"productName": "string",
"sku": "string"
}
]
}
}
}
EOF
Variables:
{
"input": {
"rows": [
{
"productName": "string",
"sku": "string"
}
]
}
}
Response:
{
"data": {
"bulkCreateProducts": {
"createdCount": 0,
"failedCount": 0,
"success": true,
"created": [
{
"productName": "string",
"productId": "id",
"rowIndex": 0,
"sku": "string",
"variantId": "id"
}
]
}
}
}
bulkCreateProducts(
input: BulkCreateProductsInput!
): BulkCreateProductsResult!
Arguments
bulkCreateProducts.input ● BulkCreateProductsInput! non-null input
The rows to create.
Type
BulkCreateProductsResult object
The outcome of a bulk product create.