Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/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/2024-04/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/2024-04/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/2024-04/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": [] } } }