Requires write_products access scope. Also: The user must have a permission to create products.

Creates or updates a product in a single request.

Use this mutation when syncing information from an external data source into Shopify.

When using this mutation to update a product, specify that product's id in the input.

Any list field (e.g. collections, metafields, variants) will be updated so that all included entries are either created or updated, and all existing entries not included will be deleted.

All other fields will be updated to the value passed. Omitted fields will not be updated.

When run in synchronous mode, the productSet mutation has an input limit of 100 variants. If you anticipate any of your use cases requiring support for more than 100 variants, please use the mutation in asynchronous mode (default).

When run in synchronous mode, you will get the product back in the response.

In asynchronous mode, you will instead get a ProductSetOperation object back. You can then 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.

If you need to update a subset of variants, use one of the bulk variant mutations:

If you need to update options, use one of the product option mutations:

See our guide to sync product data from an external source for more.


The properties of the newly created or updated product.

Anchor to synchronous
synchronous
default:true

Whether the mutation should be run synchronously or asynchronously.

If true, the mutation will return the updated product.

If false, the mutation will return a productSetOperation.

Defaults to true.

Setting synchronous: false may be desirable depending on the input complexity/size, and should be used if you are experiencing timeouts.

Note: When run in the context of a bulk operation, the mutation will always run synchronously and this argument will be ignored.


Was this section helpful?

The product object.

The product set operation, returned when run in asynchronous mode.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
Copy
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
  productSet(synchronous: $synchronous, input: $productSet) {
    product {
      id
    }
    productSetOperation {
      id
      status
      userErrors {
        code
        field
        message
      }
    }
    userErrors {
      code
      field
      message
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id } productSetOperation { id status userErrors { code field message } } userErrors { code field message } } }",
 "variables": {
    "synchronous": false,
    "productSet": {
      "title": "Winter hat",
      "productOptions": [
        {
          "name": "Color",
          "position": 1,
          "values": [
            {
              "name": "Grey"
            },
            {
              "name": "Black"
            }
          ]
        }
      ],
      "variants": [
        {
          "optionValues": [
            {
              "optionName": "Color",
              "name": "Grey"
            }
          ],
          "price": 79.99
        },
        {
          "optionValues": [
            {
              "optionName": "Color",
              "name": "Black"
            }
          ],
          "price": 69.99
        }
      ]
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
    productSet(synchronous: $synchronous, input: $productSet) {
      product {
        id
      }
      productSetOperation {
        id
        status
        userErrors {
          code
          field
          message
        }
      }
      userErrors {
        code
        field
        message
      }
    }
  }`,
  {
    variables: {
      "synchronous": false,
      "productSet": {
        "title": "Winter hat",
        "productOptions": [
          {
            "name": "Color",
            "position": 1,
            "values": [
              {
                "name": "Grey"
              },
              {
                "name": "Black"
              }
            ]
          }
        ],
        "variants": [
          {
            "optionValues": [
              {
                "optionName": "Color",
                "name": "Grey"
              }
            ],
            "price": 79.99
          },
          {
            "optionValues": [
              {
                "optionName": "Color",
                "name": "Black"
              }
            ],
            "price": 69.99
          }
        ]
      }
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
    productSet(synchronous: $synchronous, input: $productSet) {
      product {
        id
      }
      productSetOperation {
        id
        status
        userErrors {
          code
          field
          message
        }
      }
      userErrors {
        code
        field
        message
      }
    }
  }
QUERY

variables = {
  "synchronous": false,
  "productSet": {
    "title": "Winter hat",
    "productOptions": [{"name"=>"Color", "position"=>1, "values"=>[{"name"=>"Grey"}, {"name"=>"Black"}]}],
    "variants": [{"optionValues"=>[{"optionName"=>"Color", "name"=>"Grey"}], "price"=>79.99}, {"optionValues"=>[{"optionName"=>"Color", "name"=>"Black"}], "price"=>69.99}]
  }
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
      productSet(synchronous: $synchronous, input: $productSet) {
        product {
          id
        }
        productSetOperation {
          id
          status
          userErrors {
            code
            field
            message
          }
        }
        userErrors {
          code
          field
          message
        }
      }
    }`,
    "variables": {
      "synchronous": false,
      "productSet": {
        "title": "Winter hat",
        "productOptions": [
          {
            "name": "Color",
            "position": 1,
            "values": [
              {
                "name": "Grey"
              },
              {
                "name": "Black"
              }
            ]
          }
        ],
        "variants": [
          {
            "optionValues": [
              {
                "optionName": "Color",
                "name": "Grey"
              }
            ],
            "price": 79.99
          },
          {
            "optionValues": [
              {
                "optionName": "Color",
                "name": "Black"
              }
            ],
            "price": 69.99
          }
        ]
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
    productSet(synchronous: $synchronous, input: $productSet) {
      product {
        id
      }
      productSetOperation {
        id
        status
        userErrors {
          code
          field
          message
        }
      }
      userErrors {
        code
        field
        message
      }
    }
  }
QUERY;

$variables = [
  "synchronous" => false,
  "productSet" => [
    "title" => "Winter hat",
    "productOptions" => [{"name"=>"Color", "position"=>1, "values"=>[{"name"=>"Grey"}, {"name"=>"Black"}]}],
    "variants" => [{"optionValues"=>[{"optionName"=>"Color", "name"=>"Grey"}], "price"=>79.99}, {"optionValues"=>[{"optionName"=>"Color", "name"=>"Black"}], "price"=>69.99}],
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "synchronous": false,
  "productSet": {
    "title": "Winter hat",
    "productOptions": [
      {
        "name": "Color",
        "position": 1,
        "values": [
          {
            "name": "Grey"
          },
          {
            "name": "Black"
          }
        ]
      }
    ],
    "variants": [
      {
        "optionValues": [
          {
            "optionName": "Color",
            "name": "Grey"
          }
        ],
        "price": 79.99
      },
      {
        "optionValues": [
          {
            "optionName": "Color",
            "name": "Black"
          }
        ],
        "price": 69.99
      }
    ]
  }
}
Hide code
Response
JSON
{
  "productSet": {
    "product": null,
    "productSetOperation": {
      "id": "gid://shopify/ProductSetOperation/1010603729",
      "status": "CREATED",
      "userErrors": []
    },
    "userErrors": []
  }
}