Add product data
Use the GraphQL Admin API to create products with multiple options, option values, and variants. The API provides flexibility in how you structure your product creation workflow, from single operations that create everything at once to incremental mutations that build products step by step.
If your app syncs product data from an external source, use the productSet mutation to add data in a single operation. Learn more about syncing product data.
Anchor to RequirementsRequirements
- Your app can make authenticated requests to the latest version of the GraphQL Admin API or higher.
- Your app has the
write_productsaccess scope. Learn how to configure your access scopes using Shopify CLI. - You're familiar with Shopify's product model, where products contain options (like color and size) and variants represent specific purchasable combinations.
Anchor to How it worksHow it works
The GraphQL Admin API separates product creation from variant creation, giving you control over your product structure.
When you create a product with productCreate, you define the product's options (like color and size) and their possible values. The API automatically creates one standalone variant using the first value from each option, ensuring the product is immediately purchasable. You then use productVariantsBulkCreate to create the specific variant combinations you need.
This approach gives you flexibility: you can keep the standalone variant as part of your product matrix, or remove it using the REMOVE_STANDALONE_VARIANT strategy if you want to define all variants yourself. The separation also means you can add variants to existing products without modifying the product itself.
Anchor to Step 1: Create a product with optionsStep 1: Create a product with options
Use productCreate to create a product with options and option values.
The following example creates a product with two options: Color (Red, Green, Blue) and Size (Small, Medium, Large). Only Red and Small are assigned to the standalone variant—the other values are unused until you create variants in Step 2.
Avoid leaving option values unused. Always create variants for all option values you define, or remove option values that you don't need. Unused option values can cause confusion and unexpected behavior.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 2: Create product variantsStep 2: Create product variants
Use productVariantsBulkCreate to create your variants. The mutation accepts up to 2,048 variants in a single operation. You have two options:
- Option A: Replace the standalone variant (recommended): Use the
REMOVE_STANDALONE_VARIANTstrategy to remove the auto-created variant and define all variants yourself. This gives you full control over your variant matrix. - Option B: Keep the standalone variant: Add up to 2,047 additional variants alongside the auto-created standalone variant.
Anchor to Option A: Replace the standalone variantOption A: Replace the standalone variant
Use the REMOVE_STANDALONE_VARIANT strategy to remove the auto-created variant and create all variants yourself. This approach gives you full control over your product's variant matrix.
The following example removes the standalone variant and creates all nine variants for the 3x3 color/size matrix.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Option B: Keep the standalone variantOption B: Keep the standalone variant
If you want to keep the auto-created standalone variant as part of your product matrix, omit the strategy argument and create only the additional variants you need.
The following example adds eight variants to complete the 3x3 matrix, keeping the auto-created Red / Small variant from Step 1.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Next stepsNext steps
- Learn how to update product data.
- Learn how to manage media for products.
- Explore the
ProductandProductVariantobjects in the GraphQL Admin API reference.