# productCreate - admin-graphql - MUTATION Version: 2024-07 ## Description Creates a [product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) with attributes such as title, description, and vendor. You can use the `productCreate` mutation to define [options](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption) and [values](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOptionValue) for products with [product variants](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant), such as different sizes or colors. To create multiple product variants for a single product and manage prices, use the [`productVariantsBulkCreate`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productVariantsBulkCreate) mutation. To create or update a product in a single request, use the [`productSet`](https://shopify.dev/docs/api/admin-graphql/latest/mutations/productSet) mutation. Learn more about the [product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model) and [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data). ### Access Scopes `write_products` access scope. Also: The user must have a permission to create products. ## Arguments * [input](/docs/api/admin-graphql/2024-07/input-objects/ProductInput): ProductInput! - The properties of the new product. * [media](/docs/api/admin-graphql/2024-07/input-objects/CreateMediaInput): CreateMediaInput - The media to add to the product. ## Returns * [product](/docs/api/admin-graphql/2024-07/objects/Product): Product The product object. * [shop](/docs/api/admin-graphql/2024-07/objects/Shop): Shop! The shop associated with the product. * [userErrors](/docs/api/admin-graphql/2024-07/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a product with an option linked to a metafield Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/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/971662587\",\n \"gid://shopify/Metaobject/971662588\",\n \"gid://shopify/Metaobject/971662589\"\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/971662587\",\n \"gid://shopify/Metaobject/971662588\",\n \"gid://shopify/Metaobject/971662589\"\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/971662587\", \"gid://shopify/Metaobject/971662588\", \"gid://shopify/Metaobject/971662589\"]}}]\n }\n}\n\nresponse = 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/971662587\",\n \"gid://shopify/Metaobject/971662588\",\n \"gid://shopify/Metaobject/971662589\"\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}" #### Graphql Input { "input": { "title": "Oversized hoodie", "productCategory": { "productTaxonomyNodeId": "gid://shopify/ProductTaxonomyNode/329005233" }, "productOptions": [ { "name": "Color", "linkedMetafield": { "namespace": "shopify", "key": "color-pattern", "values": [ "gid://shopify/Metaobject/971662587", "gid://shopify/Metaobject/971662588", "gid://shopify/Metaobject/971662589" ] } } ] } } #### Graphql 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/971662587" }, { "name": "Blue", "linkedMetafieldValue": "gid://shopify/Metaobject/971662588" }, { "name": "Yellow", "linkedMetafieldValue": "gid://shopify/Metaobject/971662589" } ] } ] } } } }