Sync product data from an external source
The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the GraphQL Admin API. For details and migration steps, visit our migration guide.
Use the productSet mutation to sync the desired state of a product with data from an external source in a single operation
This mutation is suited for apps and use cases where the state of the product model is managed outside of Shopify, for example with an Enterprise Resource Planning (ERP) system or Worksheet, and you want to update Shopify's product model to reflect your external state.
The mutation is available in both asynchronous and synchronous modes. The default is asynchronous.
The productSet mutation has an input limit of 2K variants when run asynchronously and only 100 variants when run synchronously.
This guide provides examples of how to create and update products asynchronously and synchronously, with data from an external source.
Anchor to Create a product with variants and options asynchronouslyCreate a product with variants and options asynchronously
The following productSet mutation initiates an asynchronous operation to create a product with an option named Color. The option has three possible values: Red, Green, and Blue. The mutation also sets up product variants, each associated with one of the color options.
The response to the mutation indicates that the operation has been successfully initiated with the status CREATED.
| Variant GID | Option name | Option value name |
|---|---|---|
gid://shopify/ProductVariant/1 | Color | Red |
gid://shopify/ProductVariant/2 | Color | Green |
gid://shopify/ProductVariant/3 | Color | Blue |
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Check the status of the operationCheck the status of the operation
Use the productOperation query to check the status of the operation, using the ID that was returned when the product was created.
The query response indicates that the operation is COMPLETE and provides the details of the created product.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Update the product data asynchronouslyUpdate the product data asynchronously
The following productSet mutation initiates an asynchronous operation to update an existing product's Color option. The original color values of Red, Green, and Blue are replaced with new values of Maroon, Forest Green, and Deep Sea Blue. The mutation also updates the product variants from the old color values to the new ones. Each variant retains its original GID.
| Variant GID | Option name | Option value name |
|---|---|---|
gid://shopify/ProductVariant/1 | Color | Deep Sea Blue |
gid://shopify/ProductVariant/2 | Color | Forest Green |
gid://shopify/ProductVariant/3 | Color | Maroon |
The response to the mutation indicates that the operation has been successfully initiated with the status CREATED.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL mutation
JSON response
Anchor to Query the updated product asynchronouslyQuery the updated product asynchronously
After the product has been updated asynchronously, use the productOperation query to retrieve the updated product data. This query uses the ProductSetOperation object to check the status of the operation and to retrieve the details of the updated product and its variants.
The response to this query indicates that the operation is COMPLETE, and indicates that the product's title has been updated, and the color options have been updated to Deep Sea Blue, Forest Green, and Maroon.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Create a product with variants and options synchronouslyCreate a product with variants and options synchronously
The following productSet mutation creates a product with an option named Color. The option has three possible values, Red, Green, and Blue. The mutation creates product variants where each is associated with one of the color options. Each variant is identified by a globally-unique ID.
The mutation runs synchronously because the synchronous field is set.
| Variant GID | Option name | Option value name |
|---|---|---|
gid://shopify/ProductVariant/1 | Color | Red |
gid://shopify/ProductVariant/2 | Color | Green |
gid://shopify/ProductVariant/3 | Color | Blue |
synchronous: true executes the mutation in synchronous mode.
POST https://{shop}.myshopify.com/api/{api_version}/graphql.json
GraphQL query
JSON response
Anchor to Update the product data synchronouslyUpdate the product data synchronously
Because this mutation encapsulates many domain entities and their relationships, forming valid product inputs requires more care and attention and the mutations will take longer to execute.
The following productSet mutation updates the existing product's Color option. The original color values Red, Green, and Blue are replaced with new values of Maroon, Forest Green, and Deep Sea Blue. The mutation also updates the product variants from the old color values to the new ones. Each variant retains its original GID.
The mutation runs synchronously because the synchronous field is set.
| Variant GID | Option name | Option value name |
|---|---|---|
gid://shopify/ProductVariant/1 | Color | Deep Sea Blue |
gid://shopify/ProductVariant/2 | Color | Forest Green |
gid://shopify/ProductVariant/3 | Color | Maroon |