Create a product
Description
Create a new product with the title "Cool socks" and two product options that have two values each: A "Color" option, with the values "Red" and "Blue", and a "Size" option, with the values "Small" and "Large". This example returns the product's ID, title, and options. Learn more about [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data).
Query
mutation { productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation { productCreate(product: {title: \"Cool socks\", productOptions: [{name: \"Color\", values: [{name: \"Red\"}, {name: \"Blue\"}]}, {name: \"Size\", values: [{name: \"Small\"}, {name: \"Large\"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }" }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation { productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }`, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } } QUERY response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `mutation { productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }`, });
Response
{ "productCreate": { "product": { "id": "gid://shopify/Product/1072482054", "title": "Cool socks", "options": [ { "id": "gid://shopify/ProductOption/1064577875", "name": "Color", "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674807", "name": "Red", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674808", "name": "Blue", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064577876", "name": "Size", "position": 2, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674809", "name": "Small", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674810", "name": "Large", "hasVariants": false } ] } ] }, "userErrors": [] } }
Create a product and associate metafields
Description
Create a new product with [metafields](https://shopify.dev/docs/apps/build/custom-data) to store additional details about the product. In this example, a new product titled "Hiking Boots" is created with an associated metafield categorized under the namespace "my_fields." The metafield, of type ["single_line_text_field"](https://shopify.dev/docs/apps/build/custom-data/metafields/list-of-data-types#supported-types), is used to store the liner material information. This example returns the product's ID, title, and metafield.
Query
mutation { productCreate(product: {title: "Hiking Boots", metafields: [{namespace: "my_fields", key: "liner_material", type: "single_line_text_field", value: "Synthetic Leather"}]}) { product { id title metafields(first: 1) { nodes { id namespace key value } } } userErrors { field message } } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation { productCreate(product: {title: \"Hiking Boots\", metafields: [{namespace: \"my_fields\", key: \"liner_material\", type: \"single_line_text_field\", value: \"Synthetic Leather\"}]}) { product { id title metafields(first: 1) { nodes { id namespace key value } } } userErrors { field message } } }" }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation { productCreate(product: {title: "Hiking Boots", metafields: [{namespace: "my_fields", key: "liner_material", type: "single_line_text_field", value: "Synthetic Leather"}]}) { product { id title metafields(first: 1) { nodes { id namespace key value } } } userErrors { field message } } }`, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "Hiking Boots", metafields: [{namespace: "my_fields", key: "liner_material", type: "single_line_text_field", value: "Synthetic Leather"}]}) { product { id title metafields(first: 1) { nodes { id namespace key value } } } userErrors { field message } } } QUERY response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `mutation { productCreate(product: {title: "Hiking Boots", metafields: [{namespace: "my_fields", key: "liner_material", type: "single_line_text_field", value: "Synthetic Leather"}]}) { product { id title metafields(first: 1) { nodes { id namespace key value } } } userErrors { field message } } }`, });
Response
{ "productCreate": { "product": { "id": "gid://shopify/Product/1072482057", "title": "Hiking Boots", "metafields": { "nodes": [ { "id": "gid://shopify/Metafield/1069230536", "namespace": "my_fields", "key": "liner_material", "value": "Synthetic Leather" } ] } }, "userErrors": [] } }
Create a product with SEO settings and tags
Description
Create a new product with search engine optimization (SEO) settings and product tags. This example demonstrates how to create a product titled "Eco-Friendly Water Bottle" with custom SEO title and description for optimal search visibility. The product also includes descriptive tags for improved organization and discoverability. The mutation returns the product's ID, title, handle, description, product type, vendor, status, SEO settings, tags, options, and variants.
Query
mutation { productCreate(product: {title: "Eco-Friendly Water Bottle", descriptionHtml: "<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>", productType: "Drinkware", vendor: "EcoLifestyle", status: ACTIVE, handle: "eco-friendly-water-bottle", seo: {title: "Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle", description: "Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available."}, tags: ["eco-friendly", "stainless-steel", "insulated", "BPA-free", "sports", "outdoors"], productOptions: [{name: "Size", values: [{name: "16oz"}, {name: "20oz"}, {name: "32oz"}]}, {name: "Color", values: [{name: "Forest Green"}, {name: "Ocean Blue"}, {name: "Sunset Orange"}]}]}) { product { id title handle descriptionHtml productType vendor status seo { title description } tags options { id name position values optionValues { id name hasVariants } } variants(first: 1) { nodes { id title selectedOptions { name value } } } } userErrors { field message } } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation { productCreate(product: {title: \"Eco-Friendly Water Bottle\", descriptionHtml: \"<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>\", productType: \"Drinkware\", vendor: \"EcoLifestyle\", status: ACTIVE, handle: \"eco-friendly-water-bottle\", seo: {title: \"Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle\", description: \"Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available.\"}, tags: [\"eco-friendly\", \"stainless-steel\", \"insulated\", \"BPA-free\", \"sports\", \"outdoors\"], productOptions: [{name: \"Size\", values: [{name: \"16oz\"}, {name: \"20oz\"}, {name: \"32oz\"}]}, {name: \"Color\", values: [{name: \"Forest Green\"}, {name: \"Ocean Blue\"}, {name: \"Sunset Orange\"}]}]}) { product { id title handle descriptionHtml productType vendor status seo { title description } tags options { id name position values optionValues { id name hasVariants } } variants(first: 1) { nodes { id title selectedOptions { name value } } } } userErrors { field message } } }" }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation { productCreate(product: {title: "Eco-Friendly Water Bottle", descriptionHtml: "<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>", productType: "Drinkware", vendor: "EcoLifestyle", status: ACTIVE, handle: "eco-friendly-water-bottle", seo: {title: "Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle", description: "Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available."}, tags: ["eco-friendly", "stainless-steel", "insulated", "BPA-free", "sports", "outdoors"], productOptions: [{name: "Size", values: [{name: "16oz"}, {name: "20oz"}, {name: "32oz"}]}, {name: "Color", values: [{name: "Forest Green"}, {name: "Ocean Blue"}, {name: "Sunset Orange"}]}]}) { product { id title handle descriptionHtml productType vendor status seo { title description } tags options { id name position values optionValues { id name hasVariants } } variants(first: 1) { nodes { id title selectedOptions { name value } } } } userErrors { field message } } }`, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "Eco-Friendly Water Bottle", descriptionHtml: "<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>", productType: "Drinkware", vendor: "EcoLifestyle", status: ACTIVE, handle: "eco-friendly-water-bottle", seo: {title: "Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle", description: "Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available."}, tags: ["eco-friendly", "stainless-steel", "insulated", "BPA-free", "sports", "outdoors"], productOptions: [{name: "Size", values: [{name: "16oz"}, {name: "20oz"}, {name: "32oz"}]}, {name: "Color", values: [{name: "Forest Green"}, {name: "Ocean Blue"}, {name: "Sunset Orange"}]}]}) { product { id title handle descriptionHtml productType vendor status seo { title description } tags options { id name position values optionValues { id name hasVariants } } variants(first: 1) { nodes { id title selectedOptions { name value } } } } userErrors { field message } } } QUERY response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `mutation { productCreate(product: {title: "Eco-Friendly Water Bottle", descriptionHtml: "<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>", productType: "Drinkware", vendor: "EcoLifestyle", status: ACTIVE, handle: "eco-friendly-water-bottle", seo: {title: "Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle", description: "Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available."}, tags: ["eco-friendly", "stainless-steel", "insulated", "BPA-free", "sports", "outdoors"], productOptions: [{name: "Size", values: [{name: "16oz"}, {name: "20oz"}, {name: "32oz"}]}, {name: "Color", values: [{name: "Forest Green"}, {name: "Ocean Blue"}, {name: "Sunset Orange"}]}]}) { product { id title handle descriptionHtml productType vendor status seo { title description } tags options { id name position values optionValues { id name hasVariants } } variants(first: 1) { nodes { id title selectedOptions { name value } } } } userErrors { field message } } }`, });
Response
{ "productCreate": { "product": { "id": "gid://shopify/Product/1072482056", "title": "Eco-Friendly Water Bottle", "handle": "eco-friendly-water-bottle", "descriptionHtml": "<p>Stay hydrated with our premium stainless steel water bottle. Features double-wall insulation to keep drinks cold for 24 hours or hot for 12 hours.</p>", "productType": "Drinkware", "vendor": "EcoLifestyle", "status": "ACTIVE", "seo": { "title": "Eco Water Bottle - 24hr Cold, 12hr Hot | EcoLifestyle", "description": "Premium stainless steel water bottle with double-wall insulation. Eco-friendly, BPA-free, and perfect for active lifestyles. Free shipping available." }, "tags": [ "BPA-free", "eco-friendly", "insulated", "outdoors", "sports", "stainless-steel" ], "options": [ { "id": "gid://shopify/ProductOption/1064577878", "name": "Size", "position": 1, "values": [ "16oz" ], "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674812", "name": "16oz", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674813", "name": "20oz", "hasVariants": false }, { "id": "gid://shopify/ProductOptionValue/1054674814", "name": "32oz", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064577879", "name": "Color", "position": 2, "values": [ "Forest Green" ], "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054674815", "name": "Forest Green", "hasVariants": true }, { "id": "gid://shopify/ProductOptionValue/1054674816", "name": "Ocean Blue", "hasVariants": false }, { "id": "gid://shopify/ProductOptionValue/1054674817", "name": "Sunset Orange", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070326033", "title": "16oz / Forest Green", "selectedOptions": [ { "name": "Size", "value": "16oz" }, { "name": "Color", "value": "Forest Green" } ] } ] } }, "userErrors": [] } }
Create a product with media
Description
Create a new product and [asynchronously associate media](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components#asynchronous-media-management) to the product. The product title is "Helmet Nova" and the media consists of a Shopify-hosted image and an externally hosted video. This example returns the product ID, title, and media for the product.
Query
mutation CreateProductWithNewMedia($product: ProductCreateInput!, $media: [CreateMediaInput!]) { productCreate(product: $product, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }
Variables
{ "product": { "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" } ] }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation CreateProductWithNewMedia($product: ProductCreateInput!, $media: [CreateMediaInput!]) { productCreate(product: $product, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }", "variables": { "product": { "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" } ] } }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation CreateProductWithNewMedia($product: ProductCreateInput!, $media: [CreateMediaInput!]) { productCreate(product: $product, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }`, { variables: { "product": { "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" } ] }, }, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation CreateProductWithNewMedia($product: ProductCreateInput!, $media: [CreateMediaInput!]) { productCreate(product: $product, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } } QUERY variables = { "product": { "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 = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation CreateProductWithNewMedia($product: ProductCreateInput!, $media: [CreateMediaInput!]) { productCreate(product: $product, media: $media) { product { id title media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }`, "variables": { "product": { "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
{ "productCreate": { "product": { "id": "gid://shopify/Product/1072482059", "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": [] } }
Create a product with product metadata
Description
Create a new product titled "Wireless Headphones" by specifying details such as `productType` and `vendor`. The mutation returns the product's ID, title, product type, vendor, status, and variants. Learn more about [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data).
Query
mutation { productCreate(product: {title: "Wireless Headphones", productType: "Electronics", vendor: "AudioTech", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation { productCreate(product: {title: \"Wireless Headphones\", productType: \"Electronics\", vendor: \"AudioTech\", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } }" }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation { productCreate(product: {title: "Wireless Headphones", productType: "Electronics", vendor: "AudioTech", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } }`, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "Wireless Headphones", productType: "Electronics", vendor: "AudioTech", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } } QUERY response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `mutation { productCreate(product: {title: "Wireless Headphones", productType: "Electronics", vendor: "AudioTech", status: ACTIVE}) { product { id title productType vendor status variants(first: 1) { nodes { id price inventoryItem { id tracked } } } } userErrors { field message } } }`, });
Response
{ "productCreate": { "product": { "id": "gid://shopify/Product/1072482045", "title": "Wireless Headphones", "productType": "Electronics", "vendor": "AudioTech", "status": "ACTIVE", "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070326022", "price": "0.00", "inventoryItem": { "id": "gid://shopify/InventoryItem/1070326022", "tracked": false } } ] } }, "userErrors": [] } }
Create a product with product options and option values
Description
Create a new product with product options and option values. This example creates a product titled "New product" with options for color ("Red", "Green") and size ("Small", "Medium"). It returns the product's ID and details about the product options and first five variants. Only one product variant is created and linked with the first option value specified for each option name. Learn more about [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data).
Query
mutation { productCreate(product: {title: "New product", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Green"}]}, {name: "Size", values: [{name: "Small"}, {name: "Medium"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }
cURL
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation { productCreate(product: {title: \"New product\", productOptions: [{name: \"Color\", values: [{name: \"Red\"}, {name: \"Green\"}]}, {name: \"Size\", values: [{name: \"Small\"}, {name: \"Medium\"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }" }'
React Router
import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation { productCreate(product: {title: "New product", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Green"}]}, {name: "Size", values: [{name: "Small"}, {name: "Medium"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }`, ); const json = await response.json(); return json.data; }
Ruby
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation { productCreate(product: {title: "New product", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Green"}]}, {name: "Size", values: [{name: "Small"}, {name: "Medium"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } } QUERY response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `mutation { productCreate(product: {title: "New product", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Green"}]}, {name: "Size", values: [{name: "Small"}, {name: "Medium"}]}]}) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }`, });
Response
{ "productCreate": { "userErrors": [], "product": { "id": "gid://shopify/Product/1072482053", "options": [ { "id": "gid://shopify/ProductOption/1064577873", "name": "Color", "position": 1, "values": [ "Red" ], "optionValues": [ { "name": "Red", "hasVariants": true }, { "name": "Green", "hasVariants": false } ] }, { "id": "gid://shopify/ProductOption/1064577874", "name": "Size", "position": 2, "values": [ "Small" ], "optionValues": [ { "name": "Small", "hasVariants": true }, { "name": "Medium", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070326030", "title": "Red / Small", "selectedOptions": [ { "name": "Color", "value": "Red" }, { "name": "Size", "value": "Small" } ] } ] } } } }