Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createProductMetafields($input: ProductInput!) { productCreate(input: $input) { product { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"liner_material\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Synthetic Leather\"\n }\n ],\n \"title\": \"Hiking Boots\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createProductMetafields($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"liner_material\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Synthetic Leather\"\n }\n ],\n \"title\": \"Hiking Boots\"\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 createProductMetafields($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"liner_material\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Synthetic Leather\"}],\n \"title\": \"Hiking Boots\"\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 createProductMetafields($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"liner_material\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Synthetic Leather\"}],\n \"title\" => \"Hiking Boots\",\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 createProductMetafields($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"liner_material\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Synthetic Leather\"\n }\n ],\n \"title\": \"Hiking Boots\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createProductMetafields($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "metafields": [ { "namespace": "my_field", "key": "liner_material", "type": "single_line_text_field", "value": "Synthetic Leather" } ], "title": "Hiking Boots" } }
response: { "data": { "productCreate": { "product": { "id": "gid://shopify/Product/1072481051", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229050", "namespace": "my_field", "key": "liner_material", "value": "Synthetic Leather" } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ProductCreate($input: ProductInput!) { productCreate(input: $input) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Cool socks\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Large\"\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 ProductCreate($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n title\n options {\n id\n name\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Cool socks\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Large\"\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 ProductCreate($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n title\n options {\n id\n name\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Cool socks\",\n \"productOptions\": [{\"name\"=>\"Color\", \"values\"=>[{\"name\"=>\"Red\"}, {\"name\"=>\"Blue\"}]}, {\"name\"=>\"Size\", \"values\"=>[{\"name\"=>\"Small\"}, {\"name\"=>\"Large\"}]}]\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 ProductCreate($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n title\n options {\n id\n name\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"title\" => \"Cool socks\",\n \"productOptions\" => [{\"name\"=>\"Color\", \"values\"=>[{\"name\"=>\"Red\"}, {\"name\"=>\"Blue\"}]}, {\"name\"=>\"Size\", \"values\"=>[{\"name\"=>\"Small\"}, {\"name\"=>\"Large\"}]}],\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 ProductCreate($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n title\n options {\n id\n name\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Cool socks\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Large\"\n }\n ]\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ProductCreate($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n title\n options {\n id\n name\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "title": "Cool socks", "productOptions": [ { "name": "Color", "values": [ { "name": "Red" }, { "name": "Blue" } ] }, { "name": "Size", "values": [ { "name": "Small" }, { "name": "Large" } ] } ] } }
response: { "data": { "productCreate": { "product": { "id": "gid://shopify/Product/1072481053", "title": "Cool socks", "options": [ { "id": "gid://shopify/ProductOption/1064576495", "name": "Color", "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054672173", "name": "Red", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054672174", "name": "Blue", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064576496", "name": "Size", "position": 2, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054672175", "name": "Small", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054672176", "name": "Large", "hasVariants": false } ] } ] }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation { productCreate(input: {title: \\\"Sweet new product\\\", productType: \\\"Snowboard\\\", vendor: \\\"JadedPixel\\\"}) { product { id } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation {\n productCreate(input: {title: \"Sweet new product\", productType: \"Snowboard\", vendor: \"JadedPixel\"}) {\n product {\n id\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 {\n productCreate(input: {title: \"Sweet new product\", productType: \"Snowboard\", vendor: \"JadedPixel\"}) {\n product {\n id\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation {\n productCreate(input: {title: \"Sweet new product\", productType: \"Snowboard\", vendor: \"JadedPixel\"}) {\n product {\n id\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation {\n productCreate(input: {title: \"Sweet new product\", productType: \"Snowboard\", vendor: \"JadedPixel\"}) {\n product {\n id\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "mutation {\n productCreate(input: {title: \"Sweet new product\", productType: \"Snowboard\", vendor: \"JadedPixel\"}) {\n product {\n id\n }\n }\n}"
input: null
response: { "data": { "productCreate": { "product": { "id": "gid://shopify/Product/1072481054" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) { productCreate(input: $input, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Helmet Nova\"\n },\n \"media\": [\n {\n \"originalSource\": \"https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png\",\n \"alt\": \"Gray helmet for bikers\",\n \"mediaContentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz\",\n \"alt\": \"Testing helmet resistance against impacts\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {\n productCreate(input: $input, media: $media) {\n product {\n id\n title\n media(first: 10) {\n nodes {\n alt\n mediaContentType\n preview {\n status\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Helmet Nova\"\n },\n \"media\": [\n {\n \"originalSource\": \"https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png\",\n \"alt\": \"Gray helmet for bikers\",\n \"mediaContentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz\",\n \"alt\": \"Testing helmet resistance against impacts\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\"\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 CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {\n productCreate(input: $input, media: $media) {\n product {\n id\n title\n media(first: 10) {\n nodes {\n alt\n mediaContentType\n preview {\n status\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Helmet Nova\"\n },\n \"media\": [{\"originalSource\"=>\"https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png\", \"alt\"=>\"Gray helmet for bikers\", \"mediaContentType\"=>\"IMAGE\"}, {\"originalSource\"=>\"https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz\", \"alt\"=>\"Testing helmet resistance against impacts\", \"mediaContentType\"=>\"EXTERNAL_VIDEO\"}]\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 CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {\n productCreate(input: $input, media: $media) {\n product {\n id\n title\n media(first: 10) {\n nodes {\n alt\n mediaContentType\n preview {\n status\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"title\" => \"Helmet Nova\",\n ],\n \"media\" => [{\"originalSource\"=>\"https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png\", \"alt\"=>\"Gray helmet for bikers\", \"mediaContentType\"=>\"IMAGE\"}, {\"originalSource\"=>\"https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz\", \"alt\"=>\"Testing helmet resistance against impacts\", \"mediaContentType\"=>\"EXTERNAL_VIDEO\"}],\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 CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {\n productCreate(input: $input, media: $media) {\n product {\n id\n title\n media(first: 10) {\n nodes {\n alt\n mediaContentType\n preview {\n status\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Helmet Nova\"\n },\n \"media\": [\n {\n \"originalSource\": \"https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png\",\n \"alt\": \"Gray helmet for bikers\",\n \"mediaContentType\": \"IMAGE\"\n },\n {\n \"originalSource\": \"https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz\",\n \"alt\": \"Testing helmet resistance against impacts\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateProductWithNewMedia($input: ProductInput!, $media: [CreateMediaInput!]) {\n productCreate(input: $input, media: $media) {\n product {\n id\n title\n media(first: 10) {\n nodes {\n alt\n mediaContentType\n preview {\n status\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n}"
input: { "input": { "title": "Helmet Nova" }, "media": [ { "originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png", "alt": "Gray helmet for bikers", "mediaContentType": "IMAGE" }, { "originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz", "alt": "Testing helmet resistance against impacts", "mediaContentType": "EXTERNAL_VIDEO" } ] }
response: { "data": { "productCreate": { "product": { "id": "gid://shopify/Product/1072481049", "title": "Helmet Nova", "media": { "nodes": [ { "alt": "Gray helmet for bikers", "mediaContentType": "IMAGE", "preview": { "status": "UPLOADED" } }, { "alt": "Testing helmet resistance against impacts", "mediaContentType": "EXTERNAL_VIDEO", "preview": { "status": "UPLOADED" } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CreateCombinedListing($input: ProductInput!) { productCreate(input: $input) { product { id combinedListingRole } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Helmet Nova\",\n \"combinedListingRole\": \"PARENT\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CreateCombinedListing($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n combinedListingRole\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Helmet Nova\",\n \"combinedListingRole\": \"PARENT\"\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 CreateCombinedListing($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n combinedListingRole\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Helmet Nova\",\n \"combinedListingRole\": \"PARENT\"\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 CreateCombinedListing($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n combinedListingRole\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"title\" => \"Helmet Nova\",\n \"combinedListingRole\" => \"PARENT\",\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 CreateCombinedListing($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n combinedListingRole\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Helmet Nova\",\n \"combinedListingRole\": \"PARENT\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateCombinedListing($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n combinedListingRole\n }\n }\n}"
input: { "input": { "title": "Helmet Nova", "combinedListingRole": "PARENT" } }
response: { "data": { "productCreate": { "product": { "id": "gid://shopify/Product/1072481052", "combinedListingRole": "PARENT" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CreateProductWithOptions($input: ProductInput!) { productCreate(input: $input) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"New product\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Green\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Medium\"\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 CreateProductWithOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n id\n options {\n id\n name\n position\n values\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"New product\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Green\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Medium\"\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 CreateProductWithOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n id\n options {\n id\n name\n position\n values\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"New product\",\n \"productOptions\": [{\"name\"=>\"Color\", \"values\"=>[{\"name\"=>\"Red\"}, {\"name\"=>\"Green\"}]}, {\"name\"=>\"Size\", \"values\"=>[{\"name\"=>\"Small\"}, {\"name\"=>\"Medium\"}]}]\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 CreateProductWithOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n id\n options {\n id\n name\n position\n values\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"title\" => \"New product\",\n \"productOptions\" => [{\"name\"=>\"Color\", \"values\"=>[{\"name\"=>\"Red\"}, {\"name\"=>\"Green\"}]}, {\"name\"=>\"Size\", \"values\"=>[{\"name\"=>\"Small\"}, {\"name\"=>\"Medium\"}]}],\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 CreateProductWithOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n id\n options {\n id\n name\n position\n values\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"New product\",\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"values\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Green\"\n }\n ]\n },\n {\n \"name\": \"Size\",\n \"values\": [\n {\n \"name\": \"Small\"\n },\n {\n \"name\": \"Medium\"\n }\n ]\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateProductWithOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n id\n options {\n id\n name\n position\n values\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n}"
input: { "input": { "title": "New product", "productOptions": [ { "name": "Color", "values": [ { "name": "Red" }, { "name": "Green" } ] }, { "name": "Size", "values": [ { "name": "Small" }, { "name": "Medium" } ] } ] } }
response: { "data": { "productCreate": { "userErrors": [], "product": { "id": "gid://shopify/Product/1072481050", "options": [ { "id": "gid://shopify/ProductOption/1064576491", "name": "Color", "position": 1, "values": [ "Red" ], "optionValues": [ { "name": "Red", "hasVariants": true }, { "name": "Green", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064576492", "name": "Size", "position": 2, "values": [ "Small" ], "optionValues": [ { "name": "Small", "hasVariants": true }, { "name": "Medium", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325027", "title": "Red / Small", "selectedOptions": [ { "name": "Color", "value": "Red" }, { "name": "Size", "value": "Small" } ] } ] } } } } }