Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } }\",\n \"variables\": {\n \"synchronous\": false,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 69.99\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n }\n productSetOperation {\n id\n status\n userErrors {\n code\n field\n message\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": false,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 69.99\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n }\n productSetOperation {\n id\n status\n userErrors {\n code\n field\n message\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": false,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"variants\": [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"price\"=>79.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"price\"=>69.99}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n }\n productSetOperation {\n id\n status\n userErrors {\n code\n field\n message\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => false,\n \"productSet\" => [\n \"title\" => \"Winter hat\",\n \"productOptions\" => [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"variants\" => [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"price\"=>79.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"price\"=>69.99}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n }\n productSetOperation {\n id\n status\n userErrors {\n code\n field\n message\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": false,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"price\": 69.99\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n }\n productSetOperation {\n id\n status\n userErrors {\n code\n field\n message\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n}"
input: { "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: { "data": { "productSet": { "product": null, "productSetOperation": { "id": "gid://shopify/ProductSetOperation/1010604247", "status": "CREATED", "userErrors": [] }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) { product { id title description options(first: 5) { name position optionValues { name } } variants(first: 5) { nodes { price compareAtPrice selectedOptions { name optionValue { id name } } taxable taxCode barcode inventoryPolicy metafields(first: 5) { nodes { key value type namespace } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"input\": {\n \"title\": \"Winter gloves\",\n \"descriptionHtml\": \"Keep your hands toasty in the winter\",\n \"handle\": \"winter-gloves\",\n \"productType\": \"Apparel\",\n \"tags\": [\n \"winter\",\n \"gloves\",\n \"clothing\"\n ],\n \"vendor\": \"The Fake Glove Co\",\n \"status\": \"ACTIVE\",\n \"collections\": [\n \"gid://shopify/Collection/442946009\",\n \"gid://shopify/Collection/1063001310\",\n \"gid://shopify/Collection/793607630\"\n ],\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability\",\n \"value\": \"Eco-friendly\",\n \"type\": \"single_line_text_field\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"certified\",\n \"value\": \"false\",\n \"type\": \"boolean\"\n }\n ],\n \"productOptions\": [\n {\n \"name\": \"Finger Style\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Standard\"\n },\n {\n \"name\": \"Fingerless\"\n }\n ]\n },\n {\n \"name\": \"Outer Material\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"100% Wool\"\n },\n {\n \"name\": \"Wool Blend\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 1,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 2,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 3,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 4,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n }\n ]\n },\n \"productPreferences\": {\n \"showSkuAndBarcode\": true,\n \"showInternationalShipping\": false\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) {\n product {\n id\n title\n description\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n taxable\n taxCode\n barcode\n inventoryPolicy\n metafields(first: 5) {\n nodes {\n key\n value\n type\n namespace\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"input\": {\n \"title\": \"Winter gloves\",\n \"descriptionHtml\": \"Keep your hands toasty in the winter\",\n \"handle\": \"winter-gloves\",\n \"productType\": \"Apparel\",\n \"tags\": [\n \"winter\",\n \"gloves\",\n \"clothing\"\n ],\n \"vendor\": \"The Fake Glove Co\",\n \"status\": \"ACTIVE\",\n \"collections\": [\n \"gid://shopify/Collection/442946009\",\n \"gid://shopify/Collection/1063001310\",\n \"gid://shopify/Collection/793607630\"\n ],\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability\",\n \"value\": \"Eco-friendly\",\n \"type\": \"single_line_text_field\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"certified\",\n \"value\": \"false\",\n \"type\": \"boolean\"\n }\n ],\n \"productOptions\": [\n {\n \"name\": \"Finger Style\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Standard\"\n },\n {\n \"name\": \"Fingerless\"\n }\n ]\n },\n {\n \"name\": \"Outer Material\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"100% Wool\"\n },\n {\n \"name\": \"Wool Blend\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 1,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 2,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 3,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 4,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n }\n ]\n },\n \"productPreferences\": {\n \"showSkuAndBarcode\": true,\n \"showInternationalShipping\": false\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) {\n product {\n id\n title\n description\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n taxable\n taxCode\n barcode\n inventoryPolicy\n metafields(first: 5) {\n nodes {\n key\n value\n type\n namespace\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"input\": {\n \"title\": \"Winter gloves\",\n \"descriptionHtml\": \"Keep your hands toasty in the winter\",\n \"handle\": \"winter-gloves\",\n \"productType\": \"Apparel\",\n \"tags\": [\"winter\", \"gloves\", \"clothing\"],\n \"vendor\": \"The Fake Glove Co\",\n \"status\": \"ACTIVE\",\n \"collections\": [\"gid://shopify/Collection/442946009\", \"gid://shopify/Collection/1063001310\", \"gid://shopify/Collection/793607630\"],\n \"metafields\": [{\"namespace\"=>\"custom\", \"key\"=>\"sustainability\", \"value\"=>\"Eco-friendly\", \"type\"=>\"single_line_text_field\"}, {\"namespace\"=>\"custom\", \"key\"=>\"certified\", \"value\"=>\"false\", \"type\"=>\"boolean\"}],\n \"productOptions\": [{\"name\"=>\"Finger Style\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Standard\"}, {\"name\"=>\"Fingerless\"}]}, {\"name\"=>\"Outer Material\", \"position\"=>2, \"values\"=>[{\"name\"=>\"100% Wool\"}, {\"name\"=>\"Wool Blend\"}]}],\n \"variants\": [{\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>1, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Standard\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"100% Wool\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>2, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Standard\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"Wool Blend\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>3, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Fingerless\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"100% Wool\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>4, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Fingerless\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"Wool Blend\", \"optionName\"=>\"Outer Material\"}]}]\n },\n \"productPreferences\": {\n \"showSkuAndBarcode\": true,\n \"showInternationalShipping\": false\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) {\n product {\n id\n title\n description\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n taxable\n taxCode\n barcode\n inventoryPolicy\n metafields(first: 5) {\n nodes {\n key\n value\n type\n namespace\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"input\" => [\n \"title\" => \"Winter gloves\",\n \"descriptionHtml\" => \"Keep your hands toasty in the winter\",\n \"handle\" => \"winter-gloves\",\n \"productType\" => \"Apparel\",\n \"tags\" => [\"winter\", \"gloves\", \"clothing\"],\n \"vendor\" => \"The Fake Glove Co\",\n \"status\" => \"ACTIVE\",\n \"collections\" => [\"gid://shopify/Collection/442946009\", \"gid://shopify/Collection/1063001310\", \"gid://shopify/Collection/793607630\"],\n \"metafields\" => [{\"namespace\"=>\"custom\", \"key\"=>\"sustainability\", \"value\"=>\"Eco-friendly\", \"type\"=>\"single_line_text_field\"}, {\"namespace\"=>\"custom\", \"key\"=>\"certified\", \"value\"=>\"false\", \"type\"=>\"boolean\"}],\n \"productOptions\" => [{\"name\"=>\"Finger Style\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Standard\"}, {\"name\"=>\"Fingerless\"}]}, {\"name\"=>\"Outer Material\", \"position\"=>2, \"values\"=>[{\"name\"=>\"100% Wool\"}, {\"name\"=>\"Wool Blend\"}]}],\n \"variants\" => [{\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>1, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Standard\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"100% Wool\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>2, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Standard\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"Wool Blend\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>3, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Fingerless\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"100% Wool\", \"optionName\"=>\"Outer Material\"}]}, {\"requiresComponents\"=>false, \"barcode\"=>\"ABC-abc-1234\", \"inventoryPolicy\"=>\"DENY\", \"position\"=>4, \"price\"=>15.0, \"compareAtPrice\"=>20.0, \"taxable\"=>true, \"taxCode\"=>\"ZER\", \"metafields\"=>[{\"namespace\"=>\"custom\", \"key\"=>\"sustainability_rating\", \"value\"=>\"4.5\", \"type\"=>\"float\"}, {\"namespace\"=>\"custom\", \"key\"=>\"origin_country\", \"value\"=>\"CN\", \"type\"=>\"single_line_text_field\"}], \"optionValues\"=>[{\"name\"=>\"Fingerless\", \"optionName\"=>\"Finger Style\"}, {\"name\"=>\"Wool Blend\", \"optionName\"=>\"Outer Material\"}]}],\n ],\n \"productPreferences\" => [\n \"showSkuAndBarcode\" => true,\n \"showInternationalShipping\" => false,\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) {\n product {\n id\n title\n description\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n taxable\n taxCode\n barcode\n inventoryPolicy\n metafields(first: 5) {\n nodes {\n key\n value\n type\n namespace\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"input\": {\n \"title\": \"Winter gloves\",\n \"descriptionHtml\": \"Keep your hands toasty in the winter\",\n \"handle\": \"winter-gloves\",\n \"productType\": \"Apparel\",\n \"tags\": [\n \"winter\",\n \"gloves\",\n \"clothing\"\n ],\n \"vendor\": \"The Fake Glove Co\",\n \"status\": \"ACTIVE\",\n \"collections\": [\n \"gid://shopify/Collection/442946009\",\n \"gid://shopify/Collection/1063001310\",\n \"gid://shopify/Collection/793607630\"\n ],\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability\",\n \"value\": \"Eco-friendly\",\n \"type\": \"single_line_text_field\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"certified\",\n \"value\": \"false\",\n \"type\": \"boolean\"\n }\n ],\n \"productOptions\": [\n {\n \"name\": \"Finger Style\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Standard\"\n },\n {\n \"name\": \"Fingerless\"\n }\n ]\n },\n {\n \"name\": \"Outer Material\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"100% Wool\"\n },\n {\n \"name\": \"Wool Blend\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 1,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 2,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Standard\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 3,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"100% Wool\",\n \"optionName\": \"Outer Material\"\n }\n ]\n },\n {\n \"requiresComponents\": false,\n \"barcode\": \"ABC-abc-1234\",\n \"inventoryPolicy\": \"DENY\",\n \"position\": 4,\n \"price\": 15.0,\n \"compareAtPrice\": 20.0,\n \"taxable\": true,\n \"taxCode\": \"ZER\",\n \"metafields\": [\n {\n \"namespace\": \"custom\",\n \"key\": \"sustainability_rating\",\n \"value\": \"4.5\",\n \"type\": \"float\"\n },\n {\n \"namespace\": \"custom\",\n \"key\": \"origin_country\",\n \"value\": \"CN\",\n \"type\": \"single_line_text_field\"\n }\n ],\n \"optionValues\": [\n {\n \"name\": \"Fingerless\",\n \"optionName\": \"Finger Style\"\n },\n {\n \"name\": \"Wool Blend\",\n \"optionName\": \"Outer Material\"\n }\n ]\n }\n ]\n },\n \"productPreferences\": {\n \"showSkuAndBarcode\": true,\n \"showInternationalShipping\": false\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createEntireProduct($input: ProductSetInput!, $productPreferences: ProductPreferencesInput, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input, productPreferences: $productPreferences) {\n product {\n id\n title\n description\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n taxable\n taxCode\n barcode\n inventoryPolicy\n metafields(first: 5) {\n nodes {\n key\n value\n type\n namespace\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "input": { "title": "Winter gloves", "descriptionHtml": "Keep your hands toasty in the winter", "handle": "winter-gloves", "productType": "Apparel", "tags": [ "winter", "gloves", "clothing" ], "vendor": "The Fake Glove Co", "status": "ACTIVE", "collections": [ "gid://shopify/Collection/442946009", "gid://shopify/Collection/1063001310", "gid://shopify/Collection/793607630" ], "metafields": [ { "namespace": "custom", "key": "sustainability", "value": "Eco-friendly", "type": "single_line_text_field" }, { "namespace": "custom", "key": "certified", "value": "false", "type": "boolean" } ], "productOptions": [ { "name": "Finger Style", "position": 1, "values": [ { "name": "Standard" }, { "name": "Fingerless" } ] }, { "name": "Outer Material", "position": 2, "values": [ { "name": "100% Wool" }, { "name": "Wool Blend" } ] } ], "variants": [ { "requiresComponents": false, "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "position": 1, "price": 15.0, "compareAtPrice": 20.0, "taxable": true, "taxCode": "ZER", "metafields": [ { "namespace": "custom", "key": "sustainability_rating", "value": "4.5", "type": "float" }, { "namespace": "custom", "key": "origin_country", "value": "CN", "type": "single_line_text_field" } ], "optionValues": [ { "name": "Standard", "optionName": "Finger Style" }, { "name": "100% Wool", "optionName": "Outer Material" } ] }, { "requiresComponents": false, "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "position": 2, "price": 15.0, "compareAtPrice": 20.0, "taxable": true, "taxCode": "ZER", "metafields": [ { "namespace": "custom", "key": "sustainability_rating", "value": "4.5", "type": "float" }, { "namespace": "custom", "key": "origin_country", "value": "CN", "type": "single_line_text_field" } ], "optionValues": [ { "name": "Standard", "optionName": "Finger Style" }, { "name": "Wool Blend", "optionName": "Outer Material" } ] }, { "requiresComponents": false, "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "position": 3, "price": 15.0, "compareAtPrice": 20.0, "taxable": true, "taxCode": "ZER", "metafields": [ { "namespace": "custom", "key": "sustainability_rating", "value": "4.5", "type": "float" }, { "namespace": "custom", "key": "origin_country", "value": "CN", "type": "single_line_text_field" } ], "optionValues": [ { "name": "Fingerless", "optionName": "Finger Style" }, { "name": "100% Wool", "optionName": "Outer Material" } ] }, { "requiresComponents": false, "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "position": 4, "price": 15.0, "compareAtPrice": 20.0, "taxable": true, "taxCode": "ZER", "metafields": [ { "namespace": "custom", "key": "sustainability_rating", "value": "4.5", "type": "float" }, { "namespace": "custom", "key": "origin_country", "value": "CN", "type": "single_line_text_field" } ], "optionValues": [ { "name": "Fingerless", "optionName": "Finger Style" }, { "name": "Wool Blend", "optionName": "Outer Material" } ] } ] }, "productPreferences": { "showSkuAndBarcode": true, "showInternationalShipping": false } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072484032", "title": "Winter gloves", "description": "Keep your hands toasty in the winter", "options": [ { "name": "Finger Style", "position": 1, "optionValues": [ { "name": "Standard" }, { "name": "Fingerless" } ] }, { "name": "Outer Material", "position": 2, "optionValues": [ { "name": "100% Wool" }, { "name": "Wool Blend" } ] } ], "variants": { "nodes": [ { "price": "15.00", "compareAtPrice": "20.00", "selectedOptions": [ { "name": "Finger Style", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689928", "name": "Standard" } }, { "name": "Outer Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689930", "name": "100% Wool" } } ], "taxable": true, "taxCode": "ZER", "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "metafields": { "nodes": [ { "key": "sustainability_rating", "value": "4.5", "type": "float", "namespace": "custom" }, { "key": "origin_country", "value": "CN", "type": "single_line_text_field", "namespace": "custom" } ] } }, { "price": "15.00", "compareAtPrice": "20.00", "selectedOptions": [ { "name": "Finger Style", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689928", "name": "Standard" } }, { "name": "Outer Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689931", "name": "Wool Blend" } } ], "taxable": true, "taxCode": "ZER", "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "metafields": { "nodes": [ { "key": "sustainability_rating", "value": "4.5", "type": "float", "namespace": "custom" }, { "key": "origin_country", "value": "CN", "type": "single_line_text_field", "namespace": "custom" } ] } }, { "price": "15.00", "compareAtPrice": "20.00", "selectedOptions": [ { "name": "Finger Style", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689929", "name": "Fingerless" } }, { "name": "Outer Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689930", "name": "100% Wool" } } ], "taxable": true, "taxCode": "ZER", "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "metafields": { "nodes": [ { "key": "sustainability_rating", "value": "4.5", "type": "float", "namespace": "custom" }, { "key": "origin_country", "value": "CN", "type": "single_line_text_field", "namespace": "custom" } ] } }, { "price": "15.00", "compareAtPrice": "20.00", "selectedOptions": [ { "name": "Finger Style", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689929", "name": "Fingerless" } }, { "name": "Outer Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689931", "name": "Wool Blend" } } ], "taxable": true, "taxCode": "ZER", "barcode": "ABC-abc-1234", "inventoryPolicy": "DENY", "metafields": { "nodes": [ { "key": "sustainability_rating", "value": "4.5", "type": "float", "namespace": "custom" }, { "key": "origin_country", "value": "CN", "type": "single_line_text_field", "namespace": "custom" } ] } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id variants(first: 5) { nodes { title price inventoryQuantity inventoryItem { inventoryLevels(first: 5) { nodes { location { id name } available } } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 12\n },\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 19\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 976\n },\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 844\n }\n ],\n \"price\": 11.99\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n variants(first: 5) {\n nodes {\n title\n price\n inventoryQuantity\n inventoryItem {\n inventoryLevels(first: 5) {\n nodes {\n location {\n id\n name\n }\n available\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 12\n },\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 19\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 976\n },\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 844\n }\n ],\n \"price\": 11.99\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n variants(first: 5) {\n nodes {\n title\n price\n inventoryQuantity\n inventoryItem {\n inventoryLevels(first: 5) {\n nodes {\n location {\n id\n name\n }\n available\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"variants\": [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"inventoryQuantities\"=>[{\"locationId\"=>\"gid://shopify/Location/415211365\", \"name\"=>\"available\", \"quantity\"=>12}, {\"locationId\"=>\"gid://shopify/Location/346779380\", \"name\"=>\"available\", \"quantity\"=>19}], \"price\"=>79.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"inventoryQuantities\"=>[{\"locationId\"=>\"gid://shopify/Location/346779380\", \"name\"=>\"available\", \"quantity\"=>976}, {\"locationId\"=>\"gid://shopify/Location/415211365\", \"name\"=>\"available\", \"quantity\"=>844}], \"price\"=>11.99}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n variants(first: 5) {\n nodes {\n title\n price\n inventoryQuantity\n inventoryItem {\n inventoryLevels(first: 5) {\n nodes {\n location {\n id\n name\n }\n available\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"productSet\" => [\n \"title\" => \"Winter hat\",\n \"productOptions\" => [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"variants\" => [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"inventoryQuantities\"=>[{\"locationId\"=>\"gid://shopify/Location/415211365\", \"name\"=>\"available\", \"quantity\"=>12}, {\"locationId\"=>\"gid://shopify/Location/346779380\", \"name\"=>\"available\", \"quantity\"=>19}], \"price\"=>79.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"inventoryQuantities\"=>[{\"locationId\"=>\"gid://shopify/Location/346779380\", \"name\"=>\"available\", \"quantity\"=>976}, {\"locationId\"=>\"gid://shopify/Location/415211365\", \"name\"=>\"available\", \"quantity\"=>844}], \"price\"=>11.99}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n variants(first: 5) {\n nodes {\n title\n price\n inventoryQuantity\n inventoryItem {\n inventoryLevels(first: 5) {\n nodes {\n location {\n id\n name\n }\n available\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 12\n },\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 19\n }\n ],\n \"price\": 79.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"inventoryQuantities\": [\n {\n \"locationId\": \"gid://shopify/Location/346779380\",\n \"name\": \"available\",\n \"quantity\": 976\n },\n {\n \"locationId\": \"gid://shopify/Location/415211365\",\n \"name\": \"available\",\n \"quantity\": 844\n }\n ],\n \"price\": 11.99\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n variants(first: 5) {\n nodes {\n title\n price\n inventoryQuantity\n inventoryItem {\n inventoryLevels(first: 5) {\n nodes {\n location {\n id\n name\n }\n available\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "productSet": { "title": "Winter hat", "productOptions": [ { "name": "Color", "position": 1, "values": [ { "name": "Grey" }, { "name": "Black" } ] } ], "variants": [ { "optionValues": [ { "optionName": "Color", "name": "Grey" } ], "inventoryQuantities": [ { "locationId": "gid://shopify/Location/415211365", "name": "available", "quantity": 12 }, { "locationId": "gid://shopify/Location/346779380", "name": "available", "quantity": 19 } ], "price": 79.99 }, { "optionValues": [ { "optionName": "Color", "name": "Black" } ], "inventoryQuantities": [ { "locationId": "gid://shopify/Location/346779380", "name": "available", "quantity": 976 }, { "locationId": "gid://shopify/Location/415211365", "name": "available", "quantity": 844 } ], "price": 11.99 } ] } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072481193", "variants": { "nodes": [ { "title": "Grey", "price": "79.99", "inventoryQuantity": 31, "inventoryItem": { "inventoryLevels": { "nodes": [ { "location": { "id": "gid://shopify/Location/346779380", "name": "Ottawa Store" }, "available": 19 }, { "location": { "id": "gid://shopify/Location/415211365", "name": "US Store" }, "available": 12 } ] } } }, { "title": "Black", "price": "11.99", "inventoryQuantity": 1820, "inventoryItem": { "inventoryLevels": { "nodes": [ { "location": { "id": "gid://shopify/Location/346779380", "name": "Ottawa Store" }, "available": 976 }, { "location": { "id": "gid://shopify/Location/415211365", "name": "US Store" }, "available": 844 } ] } } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id media(first: 5) { nodes { id position alt mediaContentType status } } variants(first: 5) { nodes { title price media(first: 5) { nodes { id position alt mediaContentType status } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"files\": [\n {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n variants(first: 5) {\n nodes {\n title\n price\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"files\": [\n {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n variants(first: 5) {\n nodes {\n title\n price\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"files\": [{\"originalSource\"=>\"https://example.com/hats/grey-hat.jpg\", \"alt\"=>\"An elegant grey hat\", \"filename\"=>\"grey-hat.jpg\", \"contentType\"=>\"IMAGE\"}, {\"originalSource\"=>\"https://example.com/hats/black-hat.jpg\", \"alt\"=>\"An elegant black hat\", \"filename\"=>\"black-hat.jpg\", \"contentType\"=>\"IMAGE\"}],\n \"variants\": [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"file\"=>{\"originalSource\"=>\"https://example.com/hats/grey-hat.jpg\", \"alt\"=>\"An elegant grey hat\", \"filename\"=>\"grey-hat.jpg\", \"contentType\"=>\"IMAGE\"}, \"price\"=>11.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"file\"=>{\"originalSource\"=>\"https://example.com/hats/black-hat.jpg\", \"alt\"=>\"An elegant black hat\", \"filename\"=>\"black-hat.jpg\", \"contentType\"=>\"IMAGE\"}, \"price\"=>11.99}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n variants(first: 5) {\n nodes {\n title\n price\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"productSet\" => [\n \"title\" => \"Winter hat\",\n \"productOptions\" => [{\"name\"=>\"Color\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Grey\"}, {\"name\"=>\"Black\"}]}],\n \"files\" => [{\"originalSource\"=>\"https://example.com/hats/grey-hat.jpg\", \"alt\"=>\"An elegant grey hat\", \"filename\"=>\"grey-hat.jpg\", \"contentType\"=>\"IMAGE\"}, {\"originalSource\"=>\"https://example.com/hats/black-hat.jpg\", \"alt\"=>\"An elegant black hat\", \"filename\"=>\"black-hat.jpg\", \"contentType\"=>\"IMAGE\"}],\n \"variants\" => [{\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Grey\"}], \"file\"=>{\"originalSource\"=>\"https://example.com/hats/grey-hat.jpg\", \"alt\"=>\"An elegant grey hat\", \"filename\"=>\"grey-hat.jpg\", \"contentType\"=>\"IMAGE\"}, \"price\"=>11.99}, {\"optionValues\"=>[{\"optionName\"=>\"Color\", \"name\"=>\"Black\"}], \"file\"=>{\"originalSource\"=>\"https://example.com/hats/black-hat.jpg\", \"alt\"=>\"An elegant black hat\", \"filename\"=>\"black-hat.jpg\", \"contentType\"=>\"IMAGE\"}, \"price\"=>11.99}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n variants(first: 5) {\n nodes {\n title\n price\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"Winter hat\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Grey\"\n },\n {\n \"name\": \"Black\"\n }\n ]\n }\n ],\n \"files\": [\n {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Grey\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/grey-hat.jpg\",\n \"alt\": \"An elegant grey hat\",\n \"filename\": \"grey-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Color\",\n \"name\": \"Black\"\n }\n ],\n \"file\": {\n \"originalSource\": \"https://example.com/hats/black-hat.jpg\",\n \"alt\": \"An elegant black hat\",\n \"filename\": \"black-hat.jpg\",\n \"contentType\": \"IMAGE\"\n },\n \"price\": 11.99\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n variants(first: 5) {\n nodes {\n title\n price\n media(first: 5) {\n nodes {\n id\n position\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "productSet": { "title": "Winter hat", "productOptions": [ { "name": "Color", "position": 1, "values": [ { "name": "Grey" }, { "name": "Black" } ] } ], "files": [ { "originalSource": "https://example.com/hats/grey-hat.jpg", "alt": "An elegant grey hat", "filename": "grey-hat.jpg", "contentType": "IMAGE" }, { "originalSource": "https://example.com/hats/black-hat.jpg", "alt": "An elegant black hat", "filename": "black-hat.jpg", "contentType": "IMAGE" } ], "variants": [ { "optionValues": [ { "optionName": "Color", "name": "Grey" } ], "file": { "originalSource": "https://example.com/hats/grey-hat.jpg", "alt": "An elegant grey hat", "filename": "grey-hat.jpg", "contentType": "IMAGE" }, "price": 11.99 }, { "optionValues": [ { "optionName": "Color", "name": "Black" } ], "file": { "originalSource": "https://example.com/hats/black-hat.jpg", "alt": "An elegant black hat", "filename": "black-hat.jpg", "contentType": "IMAGE" }, "price": 11.99 } ] } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072481213", "media": { "nodes": [ { "position": 1, "alt": "An elegant grey hat", "mediaContentType": "IMAGE", "status": "UPLOADED" }, { "position": 2, "alt": "An elegant black hat", "mediaContentType": "IMAGE", "status": "UPLOADED" } ] }, "variants": { "nodes": [ { "title": "Grey", "price": "11.99", "media": { "nodes": [ { "position": 1, "alt": "An elegant grey hat", "mediaContentType": "IMAGE", "status": "UPLOADED" } ] } }, { "title": "Black", "price": "11.99", "media": { "nodes": [ { "position": 2, "alt": "An elegant black hat", "mediaContentType": "IMAGE", "status": "UPLOADED" } ] } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id title options(first: 5) { name position optionValues { name } } variants(first: 5) { nodes { price selectedOptions { name optionValue { id name } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"A humble tie\",\n \"productOptions\": [\n {\n \"name\": \"Pattern\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Plain\"\n },\n {\n \"name\": \"Stripes\"\n }\n ]\n },\n {\n \"name\": \"Width\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"Slim\"\n },\n {\n \"name\": \"Classic\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n title\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"A humble tie\",\n \"productOptions\": [\n {\n \"name\": \"Pattern\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Plain\"\n },\n {\n \"name\": \"Stripes\"\n }\n ]\n },\n {\n \"name\": \"Width\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"Slim\"\n },\n {\n \"name\": \"Classic\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n title\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"A humble tie\",\n \"productOptions\": [{\"name\"=>\"Pattern\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Plain\"}, {\"name\"=>\"Stripes\"}]}, {\"name\"=>\"Width\", \"position\"=>2, \"values\"=>[{\"name\"=>\"Slim\"}, {\"name\"=>\"Classic\"}]}],\n \"variants\": [{\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Plain\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Slim\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Plain\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Classic\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Stripes\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Slim\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Stripes\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Classic\"}], \"price\"=>15.0}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n title\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"productSet\" => [\n \"title\" => \"A humble tie\",\n \"productOptions\" => [{\"name\"=>\"Pattern\", \"position\"=>1, \"values\"=>[{\"name\"=>\"Plain\"}, {\"name\"=>\"Stripes\"}]}, {\"name\"=>\"Width\", \"position\"=>2, \"values\"=>[{\"name\"=>\"Slim\"}, {\"name\"=>\"Classic\"}]}],\n \"variants\" => [{\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Plain\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Slim\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Plain\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Classic\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Stripes\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Slim\"}], \"price\"=>15.0}, {\"optionValues\"=>[{\"optionName\"=>\"Pattern\", \"name\"=>\"Stripes\"}, {\"optionName\"=>\"Width\", \"name\"=>\"Classic\"}], \"price\"=>15.0}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n title\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"productSet\": {\n \"title\": \"A humble tie\",\n \"productOptions\": [\n {\n \"name\": \"Pattern\",\n \"position\": 1,\n \"values\": [\n {\n \"name\": \"Plain\"\n },\n {\n \"name\": \"Stripes\"\n }\n ]\n },\n {\n \"name\": \"Width\",\n \"position\": 2,\n \"values\": [\n {\n \"name\": \"Slim\"\n },\n {\n \"name\": \"Classic\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Plain\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Slim\"\n }\n ],\n \"price\": 15.0\n },\n {\n \"optionValues\": [\n {\n \"optionName\": \"Pattern\",\n \"name\": \"Stripes\"\n },\n {\n \"optionName\": \"Width\",\n \"name\": \"Classic\"\n }\n ],\n \"price\": 15.0\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n title\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "productSet": { "title": "A humble tie", "productOptions": [ { "name": "Pattern", "position": 1, "values": [ { "name": "Plain" }, { "name": "Stripes" } ] }, { "name": "Width", "position": 2, "values": [ { "name": "Slim" }, { "name": "Classic" } ] } ], "variants": [ { "optionValues": [ { "optionName": "Pattern", "name": "Plain" }, { "optionName": "Width", "name": "Slim" } ], "price": 15.0 }, { "optionValues": [ { "optionName": "Pattern", "name": "Plain" }, { "optionName": "Width", "name": "Classic" } ], "price": 15.0 }, { "optionValues": [ { "optionName": "Pattern", "name": "Stripes" }, { "optionName": "Width", "name": "Slim" } ], "price": 15.0 }, { "optionValues": [ { "optionName": "Pattern", "name": "Stripes" }, { "optionName": "Width", "name": "Classic" } ], "price": 15.0 } ] } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072484059", "title": "A humble tie", "options": [ { "name": "Pattern", "position": 1, "optionValues": [ { "name": "Plain" }, { "name": "Stripes" } ] }, { "name": "Width", "position": 2, "optionValues": [ { "name": "Slim" }, { "name": "Classic" } ] } ], "variants": { "nodes": [ { "price": "15.00", "selectedOptions": [ { "name": "Pattern", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690245", "name": "Plain" } }, { "name": "Width", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690247", "name": "Slim" } } ] }, { "price": "15.00", "selectedOptions": [ { "name": "Pattern", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690245", "name": "Plain" } }, { "name": "Width", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690248", "name": "Classic" } } ] }, { "price": "15.00", "selectedOptions": [ { "name": "Pattern", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690246", "name": "Stripes" } }, { "name": "Width", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690247", "name": "Slim" } } ] }, { "price": "15.00", "selectedOptions": [ { "name": "Pattern", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690246", "name": "Stripes" } }, { "name": "Width", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054690248", "name": "Classic" } } ] } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id hasOnlyDefaultVariant } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"id\": \"gid://shopify/Product/20995642\",\n \"productOptions\": [],\n \"variants\": []\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n hasOnlyDefaultVariant\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"productSet\": {\n \"id\": \"gid://shopify/Product/20995642\",\n \"productOptions\": [],\n \"variants\": []\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n hasOnlyDefaultVariant\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"productSet\": {\n \"id\": \"gid://shopify/Product/20995642\",\n \"productOptions\": [],\n \"variants\": []\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n hasOnlyDefaultVariant\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"productSet\" => [\n \"id\" => \"gid://shopify/Product/20995642\",\n \"productOptions\" => [],\n \"variants\" => [],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n hasOnlyDefaultVariant\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"productSet\": {\n \"id\": \"gid://shopify/Product/20995642\",\n \"productOptions\": [],\n \"variants\": []\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateProductToLeaveDefaultVariant($productSet: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $productSet) {\n product {\n id\n hasOnlyDefaultVariant\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "productSet": { "id": "gid://shopify/Product/20995642", "productOptions": [], "variants": [] } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/20995642", "hasOnlyDefaultVariant": true }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $input) { product { id title description handle options(first: 5) { name position optionValues { name } } variants(first: 5) { nodes { price compareAtPrice selectedOptions { name optionValue { id name } } } } } userErrors { field message } } }\",\n \"variables\": {\n \"synchronous\": true,\n \"input\": {\n \"id\": \"gid://shopify/Product/1072484024\",\n \"title\": \"Bike frame\",\n \"descriptionHtml\": \"Blending durability with aerodynamics\",\n \"handle\": \"bike-frame\",\n \"productType\": \"parts\",\n \"tags\": [\n \"cycling\",\n \"bike\",\n \"parts\"\n ],\n \"vendor\": \"Your cycling company\",\n \"status\": \"ACTIVE\",\n \"productOptions\": [\n {\n \"id\": \"gid://shopify/ProductOption/1064581962\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductOption/1064581963\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"id\": \"gid://shopify/ProductVariant/1070337963\",\n \"position\": 1,\n \"price\": 94.99,\n \"compareAtPrice\": 99.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337964\",\n \"position\": 2,\n \"price\": 259.99,\n \"compareAtPrice\": 299.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337965\",\n \"position\": 3,\n \"price\": 169.99,\n \"compareAtPrice\": 199.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n }\n ]\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input) {\n product {\n id\n title\n description\n handle\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"synchronous\": true,\n \"input\": {\n \"id\": \"gid://shopify/Product/1072484024\",\n \"title\": \"Bike frame\",\n \"descriptionHtml\": \"Blending durability with aerodynamics\",\n \"handle\": \"bike-frame\",\n \"productType\": \"parts\",\n \"tags\": [\n \"cycling\",\n \"bike\",\n \"parts\"\n ],\n \"vendor\": \"Your cycling company\",\n \"status\": \"ACTIVE\",\n \"productOptions\": [\n {\n \"id\": \"gid://shopify/ProductOption/1064581962\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductOption/1064581963\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"id\": \"gid://shopify/ProductVariant/1070337963\",\n \"position\": 1,\n \"price\": 94.99,\n \"compareAtPrice\": 99.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337964\",\n \"position\": 2,\n \"price\": 259.99,\n \"compareAtPrice\": 299.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337965\",\n \"position\": 3,\n \"price\": 169.99,\n \"compareAtPrice\": 199.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n }\n ]\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input) {\n product {\n id\n title\n description\n handle\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"synchronous\": true,\n \"input\": {\n \"id\": \"gid://shopify/Product/1072484024\",\n \"title\": \"Bike frame\",\n \"descriptionHtml\": \"Blending durability with aerodynamics\",\n \"handle\": \"bike-frame\",\n \"productType\": \"parts\",\n \"tags\": [\"cycling\", \"bike\", \"parts\"],\n \"vendor\": \"Your cycling company\",\n \"status\": \"ACTIVE\",\n \"productOptions\": [{\"id\"=>\"gid://shopify/ProductOption/1064581962\", \"values\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689820\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689821\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689822\"}]}, {\"id\"=>\"gid://shopify/ProductOption/1064581963\", \"values\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689824\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689823\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689825\"}]}],\n \"variants\": [{\"id\"=>\"gid://shopify/ProductVariant/1070337963\", \"position\"=>1, \"price\"=>94.99, \"compareAtPrice\"=>99.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689820\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689823\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}, {\"id\"=>\"gid://shopify/ProductVariant/1070337964\", \"position\"=>2, \"price\"=>259.99, \"compareAtPrice\"=>299.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689821\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689824\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}, {\"id\"=>\"gid://shopify/ProductVariant/1070337965\", \"position\"=>3, \"price\"=>169.99, \"compareAtPrice\"=>199.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689822\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689825\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input) {\n product {\n id\n title\n description\n handle\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"synchronous\" => true,\n \"input\" => [\n \"id\" => \"gid://shopify/Product/1072484024\",\n \"title\" => \"Bike frame\",\n \"descriptionHtml\" => \"Blending durability with aerodynamics\",\n \"handle\" => \"bike-frame\",\n \"productType\" => \"parts\",\n \"tags\" => [\"cycling\", \"bike\", \"parts\"],\n \"vendor\" => \"Your cycling company\",\n \"status\" => \"ACTIVE\",\n \"productOptions\" => [{\"id\"=>\"gid://shopify/ProductOption/1064581962\", \"values\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689820\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689821\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689822\"}]}, {\"id\"=>\"gid://shopify/ProductOption/1064581963\", \"values\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689824\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689823\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689825\"}]}],\n \"variants\" => [{\"id\"=>\"gid://shopify/ProductVariant/1070337963\", \"position\"=>1, \"price\"=>94.99, \"compareAtPrice\"=>99.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689820\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689823\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}, {\"id\"=>\"gid://shopify/ProductVariant/1070337964\", \"position\"=>2, \"price\"=>259.99, \"compareAtPrice\"=>299.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689821\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689824\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}, {\"id\"=>\"gid://shopify/ProductVariant/1070337965\", \"position\"=>3, \"price\"=>169.99, \"compareAtPrice\"=>199.99, \"optionValues\"=>[{\"id\"=>\"gid://shopify/ProductOptionValue/1054689822\", \"optionId\"=>\"gid://shopify/ProductOption/1064581962\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054689825\", \"optionId\"=>\"gid://shopify/ProductOption/1064581963\"}]}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input) {\n product {\n id\n title\n description\n handle\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"synchronous\": true,\n \"input\": {\n \"id\": \"gid://shopify/Product/1072484024\",\n \"title\": \"Bike frame\",\n \"descriptionHtml\": \"Blending durability with aerodynamics\",\n \"handle\": \"bike-frame\",\n \"productType\": \"parts\",\n \"tags\": [\n \"cycling\",\n \"bike\",\n \"parts\"\n ],\n \"vendor\": \"Your cycling company\",\n \"status\": \"ACTIVE\",\n \"productOptions\": [\n {\n \"id\": \"gid://shopify/ProductOption/1064581962\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductOption/1064581963\",\n \"values\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\"\n }\n ]\n }\n ],\n \"variants\": [\n {\n \"id\": \"gid://shopify/ProductVariant/1070337963\",\n \"position\": 1,\n \"price\": 94.99,\n \"compareAtPrice\": 99.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689820\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689823\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337964\",\n \"position\": 2,\n \"price\": 259.99,\n \"compareAtPrice\": 299.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689821\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689824\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n },\n {\n \"id\": \"gid://shopify/ProductVariant/1070337965\",\n \"position\": 3,\n \"price\": 169.99,\n \"compareAtPrice\": 199.99,\n \"optionValues\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689822\",\n \"optionId\": \"gid://shopify/ProductOption/1064581962\"\n },\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054689825\",\n \"optionId\": \"gid://shopify/ProductOption/1064581963\"\n }\n ]\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateProductVariantPricing($input: ProductSetInput!, $synchronous: Boolean!) {\n productSet(synchronous: $synchronous, input: $input) {\n product {\n id\n title\n description\n handle\n options(first: 5) {\n name\n position\n optionValues {\n name\n }\n }\n variants(first: 5) {\n nodes {\n price\n compareAtPrice\n selectedOptions {\n name\n optionValue {\n id\n name\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "synchronous": true, "input": { "id": "gid://shopify/Product/1072484024", "title": "Bike frame", "descriptionHtml": "Blending durability with aerodynamics", "handle": "bike-frame", "productType": "parts", "tags": [ "cycling", "bike", "parts" ], "vendor": "Your cycling company", "status": "ACTIVE", "productOptions": [ { "id": "gid://shopify/ProductOption/1064581962", "values": [ { "id": "gid://shopify/ProductOptionValue/1054689820" }, { "id": "gid://shopify/ProductOptionValue/1054689821" }, { "id": "gid://shopify/ProductOptionValue/1054689822" } ] }, { "id": "gid://shopify/ProductOption/1064581963", "values": [ { "id": "gid://shopify/ProductOptionValue/1054689824" }, { "id": "gid://shopify/ProductOptionValue/1054689823" }, { "id": "gid://shopify/ProductOptionValue/1054689825" } ] } ], "variants": [ { "id": "gid://shopify/ProductVariant/1070337963", "position": 1, "price": 94.99, "compareAtPrice": 99.99, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054689820", "optionId": "gid://shopify/ProductOption/1064581962" }, { "id": "gid://shopify/ProductOptionValue/1054689823", "optionId": "gid://shopify/ProductOption/1064581963" } ] }, { "id": "gid://shopify/ProductVariant/1070337964", "position": 2, "price": 259.99, "compareAtPrice": 299.99, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054689821", "optionId": "gid://shopify/ProductOption/1064581962" }, { "id": "gid://shopify/ProductOptionValue/1054689824", "optionId": "gid://shopify/ProductOption/1064581963" } ] }, { "id": "gid://shopify/ProductVariant/1070337965", "position": 3, "price": 169.99, "compareAtPrice": 199.99, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054689822", "optionId": "gid://shopify/ProductOption/1064581962" }, { "id": "gid://shopify/ProductOptionValue/1054689825", "optionId": "gid://shopify/ProductOption/1064581963" } ] } ] } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072484024", "title": "Bike frame", "description": "Blending durability with aerodynamics", "handle": "bike-frame", "options": [ { "name": "Material", "position": 1, "optionValues": [ { "name": "Aluminium" }, { "name": "Carbon" }, { "name": "Steel" } ] }, { "name": "Color", "position": 2, "optionValues": [ { "name": "Grey" }, { "name": "Black" }, { "name": "Silver" } ] } ], "variants": { "nodes": [ { "price": "94.99", "compareAtPrice": "99.99", "selectedOptions": [ { "name": "Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689820", "name": "Aluminium" } }, { "name": "Color", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689823", "name": "Grey" } } ] }, { "price": "259.99", "compareAtPrice": "299.99", "selectedOptions": [ { "name": "Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689821", "name": "Carbon" } }, { "name": "Color", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689824", "name": "Black" } } ] }, { "price": "169.99", "compareAtPrice": "199.99", "selectedOptions": [ { "name": "Material", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689822", "name": "Steel" } }, { "name": "Color", "optionValue": { "id": "gid://shopify/ProductOptionValue/1054689825", "name": "Silver" } } ] } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) { productSet(input: $input, upsertInput: $upsertInput) { product { id title handle } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Winter hat\",\n \"handle\": \"winter-hat\"\n },\n \"upsertInput\": {\n \"match\": {\n \"handle\": \"winter-hat\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) {\n productSet(input: $input, upsertInput: $upsertInput) {\n product {\n id\n title\n handle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Winter hat\",\n \"handle\": \"winter-hat\"\n },\n \"upsertInput\": {\n \"match\": {\n \"handle\": \"winter-hat\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) {\n productSet(input: $input, upsertInput: $upsertInput) {\n product {\n id\n title\n handle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Winter hat\",\n \"handle\": \"winter-hat\"\n },\n \"upsertInput\": {\n \"match\": {\n \"handle\": \"winter-hat\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) {\n productSet(input: $input, upsertInput: $upsertInput) {\n product {\n id\n title\n handle\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"title\" => \"Winter hat\",\n \"handle\" => \"winter-hat\",\n ],\n \"upsertInput\" => [\n \"match\" => [\n \"handle\" => \"winter-hat\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) {\n productSet(input: $input, upsertInput: $upsertInput) {\n product {\n id\n title\n handle\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Winter hat\",\n \"handle\": \"winter-hat\"\n },\n \"upsertInput\": {\n \"match\": {\n \"handle\": \"winter-hat\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation UpsertProductByHandle($input: ProductSetInput!, $upsertInput: ProductSetUpsertInput) {\n productSet(input: $input, upsertInput: $upsertInput) {\n product {\n id\n title\n handle\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "title": "Winter hat", "handle": "winter-hat" }, "upsertInput": { "match": { "handle": "winter-hat" } } }
response: { "data": { "productSet": { "product": { "id": "gid://shopify/Product/1072484048", "title": "Winter hat", "handle": "winter-hat" }, "userErrors": [] } } }