Update product data
Use the GraphQL Admin API to update existing products, including their variants and options. The API provides granular control over updates, allowing you to modify only the specific fields or entities that need to change without affecting the rest of the product data.
If your app syncs product data from an external source, use the productSet mutation to update 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 understand how products, variants, and options work in the GraphQL Admin API.
- You've created products with variants that you want to update. If you need to create products first, refer to Add product data.
Anchor to How it worksHow it works
The GraphQL Admin API provides separate, targeted mutations for updating different parts of a product:
- Use
productUpdateto modify product-level fields like title or tags. - Use dedicated option mutations to add, rename, reorder, or remove product options.
- Use bulk variant mutations to update, delete, or reorder multiple variants at once. Each mutation modifies only what you specify, and everything else remains unchanged.
This separation gives you precise control. For example, you can update the price on 50 specific variants without touching the other variants, or rename an option without affecting any variant data.
Anchor to Step 1: Retrieve product dataStep 1: Retrieve product data
To get the IDs you'll need for update operations, query the product first.
The following example shows how to retrieve a product with its options, option values, and variants. The response includes IDs for the product, options, option values, and variants that you'll use in subsequent update steps.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Step 2: Update product informationStep 2: Update product information
To update product-level fields without affecting variants or options, use productUpdate.
The following example shows how to change a product's title from "My Cool Socks" to "My Extra Cool Socks". Only the title field is modified, and all other product data remains unchanged.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 3: Manage product optionsStep 3: Manage product options
Options can be managed independently of the product and its variants, giving you control over how products are structured.
Anchor to 3.1 Add a new option3. 1 Add a new option
To expand a product's characteristics, use productOptionsCreate.
The following example shows how to add a Material option with two values (Cotton and Wool) to the product. When you create a new option, all existing variants are automatically updated to include the first value. In this example, all nine variants will get Material: Cotton added to their option combinations, while Wool becomes unused (hasVariants: false) until you assign it to variants.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to 3.2 Update an option3. 2 Update an option
To modify an option's properties, use productOptionUpdate.
The following example shows how to rename the Material option to Fabric and move it to position 1. The option ID remains the same. Only its name and position change, and all variants that used Material now display Fabric instead.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to 3.3 Reorder options3. 3 Reorder options
To change the display order of options and their values, use productOptionsReorder.
The following example shows how to reorder both options and their values in a single operation. This mutation moves Color to position 1, reorders the color values to display Blue, Red, Green, and moves Fabric to position 2 with Wool before Cotton. Variant titles automatically update to reflect the new order.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to 3.4 Delete an option3. 4 Delete an option
To remove an option and automatically resolve duplicate variant combinations, use productOptionsDelete with the POSITION strategy.
The following example shows how to delete the Size option. The API keeps lower-positioned variants and deletes higher-positioned ones. For example, if you have Red / Small, Red / Medium, and Red / Large, the API keeps Red / Small (position 0) and deletes the others, resulting in one variant for each color.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 4: Update product variantsStep 4: Update product variants
Bulk variant mutations let you efficiently update, delete, or reorder multiple variants at once, specifying only what you're changing.
Anchor to 4.1 Update variant fields4. 1 Update variant fields
To modify specific fields on variants, use productVariantsBulkUpdate.
The following example shows how to update a variant's price from $4.99 to $9.99 and change its Material option from Cotton to Wool. This mutation modifies only the specified variant (gid://shopify/ProductVariant/102) using the option value ID for precision. All other variants remain unchanged. You can update up to 250 variants in a single operation.
You can reference option values by either their ID or by name: { "name": "Wool", "optionName": "Fabric" }
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to 4.2 Delete variants4. 2 Delete variants
To remove variants you no longer need, use productVariantsBulkDelete.
The following example shows how to delete two specific variants from the product. If these were the only variants using certain option values, those values will become unused (hasVariants: false). You can keep them for future use or remove them in Step 5.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to 4.3 Reorder variants4. 3 Reorder variants
To change the display order of variants, use productVariantsBulkReorder.
The following example shows how to move two variants to new positions. You only specify the variants whose positions are changing, and the API automatically adjusts the others. The order affects how variants appear in the Shopify admin and on storefronts (depending on theme).
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Step 5: Clean up unused option valuesStep 5: Clean up unused option values
When you delete variants or add new options, some option values might become unused. These values exist but aren't assigned to any variants. To remove them, use productOptionUpdate with the optionValuesToDelete argument.
Regularly audit and remove unused option values. Large numbers of unused option values can impact performance and cause timeouts when updating products. Use the hasVariants field to identify option values that aren't assigned to any variants, as shown in Step 1.
The following example shows how to remove the unused values Red and Green from the Color option after deleting variants. The mutation keeps the Color option itself and any values still assigned to variants (like Blue). Only the specified unused values are removed.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Next stepsNext steps
- Learn how to add product data to create new products with options and variants.
- Learn how to sync product data from external sources.
- Learn how to manage media for products.
- Learn how to link metafields to product options for enhanced taxonomy.
- Learn how to reorder products in collections.
- Explore the
productUpdateandproductVariantsBulkUpdatemutations in the GraphQL Admin API reference.