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 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 = <<[\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/1072481125", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229271", "namespace": "my_field", "key": "liner_material", "value": "Synthetic Leather" } } ] } }, "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 { 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([\"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/1072481123" } } } }
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 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 = <<[\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/1072481126", "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/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CreateProductWithLinkedOptions($input: ProductInput!) { productCreate(input: $input) { userErrors { field message } product { productCategory { productTaxonomyNode { id } } options { name linkedMetafield { namespace key } optionValues { name linkedMetafieldValue } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Oversized hoodie\",\n \"productCategory\": {\n \"productTaxonomyNodeId\": \"gid://shopify/ProductTaxonomyNode/329005233\"\n },\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"linkedMetafield\": {\n \"namespace\": \"shopify\",\n \"key\": \"color-pattern\",\n \"values\": [\n \"gid://shopify/Metaobject/971662500\",\n \"gid://shopify/Metaobject/971662501\",\n \"gid://shopify/Metaobject/971662502\"\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 CreateProductWithLinkedOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n productCategory {\n productTaxonomyNode {\n id\n }\n }\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Oversized hoodie\",\n \"productCategory\": {\n \"productTaxonomyNodeId\": \"gid://shopify/ProductTaxonomyNode/329005233\"\n },\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"linkedMetafield\": {\n \"namespace\": \"shopify\",\n \"key\": \"color-pattern\",\n \"values\": [\n \"gid://shopify/Metaobject/971662500\",\n \"gid://shopify/Metaobject/971662501\",\n \"gid://shopify/Metaobject/971662502\"\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 CreateProductWithLinkedOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n productCategory {\n productTaxonomyNode {\n id\n }\n }\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Oversized hoodie\",\n \"productCategory\": {\n \"productTaxonomyNodeId\": \"gid://shopify/ProductTaxonomyNode/329005233\"\n },\n \"productOptions\": [{\"name\"=>\"Color\", \"linkedMetafield\"=>{\"namespace\"=>\"shopify\", \"key\"=>\"color-pattern\", \"values\"=>[\"gid://shopify/Metaobject/971662500\", \"gid://shopify/Metaobject/971662501\", \"gid://shopify/Metaobject/971662502\"]}}]\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 = <<[\n \"title\" => \"Oversized hoodie\",\n \"productCategory\" => [\n \"productTaxonomyNodeId\" => \"gid://shopify/ProductTaxonomyNode/329005233\",\n ],\n \"productOptions\" => [{\"name\"=>\"Color\", \"linkedMetafield\"=>{\"namespace\"=>\"shopify\", \"key\"=>\"color-pattern\", \"values\"=>[\"gid://shopify/Metaobject/971662500\", \"gid://shopify/Metaobject/971662501\", \"gid://shopify/Metaobject/971662502\"]}}],\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 CreateProductWithLinkedOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n productCategory {\n productTaxonomyNode {\n id\n }\n }\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Oversized hoodie\",\n \"productCategory\": {\n \"productTaxonomyNodeId\": \"gid://shopify/ProductTaxonomyNode/329005233\"\n },\n \"productOptions\": [\n {\n \"name\": \"Color\",\n \"linkedMetafield\": {\n \"namespace\": \"shopify\",\n \"key\": \"color-pattern\",\n \"values\": [\n \"gid://shopify/Metaobject/971662500\",\n \"gid://shopify/Metaobject/971662501\",\n \"gid://shopify/Metaobject/971662502\"\n ]\n }\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateProductWithLinkedOptions($input: ProductInput!) {\n productCreate(input: $input) {\n userErrors {\n field\n message\n }\n product {\n productCategory {\n productTaxonomyNode {\n id\n }\n }\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n}"
input: { "input": { "title": "Oversized hoodie", "productCategory": { "productTaxonomyNodeId": "gid://shopify/ProductTaxonomyNode/329005233" }, "productOptions": [ { "name": "Color", "linkedMetafield": { "namespace": "shopify", "key": "color-pattern", "values": [ "gid://shopify/Metaobject/971662500", "gid://shopify/Metaobject/971662501", "gid://shopify/Metaobject/971662502" ] } } ] } }
response: { "data": { "productCreate": { "userErrors": [], "product": { "productCategory": { "productTaxonomyNode": { "id": "gid://shopify/ProductTaxonomyNode/329005233" } }, "options": [ { "name": "Color", "linkedMetafield": { "namespace": "shopify", "key": "color-pattern" }, "optionValues": [ { "name": "Red", "linkedMetafieldValue": "gid://shopify/Metaobject/971662500" }, { "name": "Blue", "linkedMetafieldValue": "gid://shopify/Metaobject/971662501" }, { "name": "Yellow", "linkedMetafieldValue": "gid://shopify/Metaobject/971662502" } ] } ] } } } }
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 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 = <<[\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/1072481127", "options": [ { "id": "gid://shopify/ProductOption/1064576616", "name": "Color", "position": 1, "values": [ "Red" ], "optionValues": [ { "name": "Red", "hasVariants": true }, { "name": "Green", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064576617", "name": "Size", "position": 2, "values": [ "Small" ], "optionValues": [ { "name": "Small", "hasVariants": true }, { "name": "Medium", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325227", "title": "Red / Small", "selectedOptions": [ { "name": "Color", "value": "Red" }, { "name": "Size", "value": "Small" } ] } ] } } } } }