# productVariantsBulkCreate - admin-graphql - MUTATION
Version: 2025-01

## Description
Creates multiple variants in a single product. This mutation can be called directly or via the bulkOperation.

### Access Scopes
`write_products` access scope. Also: The user must have a permission to create product variants.


## Arguments
* [media](/docs/api/admin-graphql/2025-01/input-objects/CreateMediaInput): CreateMediaInput - List of new media to be added to the product.
* [productId](/docs/api/admin-graphql/2025-01/scalars/ID): ID! - The ID of the product on which to create the variants.
* [strategy](/docs/api/admin-graphql/2025-01/enums/ProductVariantsBulkCreateStrategy): ProductVariantsBulkCreateStrategy - The strategy defines which behavior the mutation should observe, such as whether to keep or delete the standalone variant (when product has only a single or default variant) when creating new variants in bulk.
* [variants](/docs/api/admin-graphql/2025-01/input-objects/ProductVariantsBulkInput): ProductVariantsBulkInput! - An array of product variants to be created.


## Returns
* [product](/docs/api/admin-graphql/2025-01/objects/Product): Product The updated product object.
* [productVariants](/docs/api/admin-graphql/2025-01/objects/ProductVariant): ProductVariant The newly created variants.
* [userErrors](/docs/api/admin-graphql/2025-01/objects/ProductVariantsBulkCreateUserError): ProductVariantsBulkCreateUserError! The list of errors that occurred from executing the mutation.


## Examples
### Create a new Product Variant
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 ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkCreate(productId: $productId, variants: $variants) { productVariants { id title selectedOptions { name value } } userErrors { field message } } }\",\n \"variables\": {\n    \"productId\": \"gid://shopify/Product/20995642\",\n    \"variants\": [\n      {\n        \"price\": 15.99,\n        \"compareAtPrice\": 19.99,\n        \"optionValues\": [\n          {\n            \"name\": \"Golden\",\n            \"optionId\": \"gid://shopify/ProductOption/328272167\"\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 ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n      productVariantsBulkCreate(productId: $productId, variants: $variants) {\n        productVariants {\n          id\n          title\n          selectedOptions {\n            name\n            value\n          }\n        }\n        userErrors {\n          field\n          message\n        }\n      }\n    }`,\n    \"variables\": {\n      \"productId\": \"gid://shopify/Product/20995642\",\n      \"variants\": [\n        {\n          \"price\": 15.99,\n          \"compareAtPrice\": 19.99,\n          \"optionValues\": [\n            {\n              \"name\": \"Golden\",\n              \"optionId\": \"gid://shopify/ProductOption/328272167\"\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 ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n    productVariantsBulkCreate(productId: $productId, variants: $variants) {\n      productVariants {\n        id\n        title\n        selectedOptions {\n          name\n          value\n        }\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"productId\": \"gid://shopify/Product/20995642\",\n  \"variants\": [{\"price\"=>15.99, \"compareAtPrice\"=>19.99, \"optionValues\"=>[{\"name\"=>\"Golden\", \"optionId\"=>\"gid://shopify/ProductOption/328272167\"}]}]\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 ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n    productVariantsBulkCreate(productId: $productId, variants: $variants) {\n      productVariants {\n        id\n        title\n        selectedOptions {\n          name\n          value\n        }\n      }\n      userErrors {\n        field\n        message\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"productId\": \"gid://shopify/Product/20995642\",\n      \"variants\": [\n        {\n          \"price\": 15.99,\n          \"compareAtPrice\": 19.99,\n          \"optionValues\": [\n            {\n              \"name\": \"Golden\",\n              \"optionId\": \"gid://shopify/ProductOption/328272167\"\n            }\n          ]\n        }\n      ]\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n  productVariantsBulkCreate(productId: $productId, variants: $variants) {\n    productVariants {\n      id\n      title\n      selectedOptions {\n        name\n        value\n      }\n    }\n    userErrors {\n      field\n      message\n    }\n  }\n}"
#### Graphql Input
{
  "productId": "gid://shopify/Product/20995642",
  "variants": [
    {
      "price": 15.99,
      "compareAtPrice": 19.99,
      "optionValues": [
        {
          "name": "Golden",
          "optionId": "gid://shopify/ProductOption/328272167"
        }
      ]
    }
  ]
}
#### Graphql Response
{
  "data": {
    "productVariantsBulkCreate": {
      "productVariants": [
        {
          "id": "gid://shopify/ProductVariant/1070325177",
          "title": "Golden",
          "selectedOptions": [
            {
              "name": "Title",
              "value": "Golden"
            }
          ]
        }
      ],
      "userErrors": []
    }
  }
}

### Create product variants using existing and new option values
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 productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkCreate(productId: $productId, variants: $variants) { userErrors { field message } product { id options { id name values position optionValues { id name hasVariants } } } productVariants { id title selectedOptions { name value } } } }\",\n \"variables\": {\n    \"productId\": \"gid://shopify/Product/1072481066\",\n    \"variants\": [\n      {\n        \"optionValues\": [\n          {\n            \"name\": \"Red\",\n            \"optionName\": \"Color\"\n          },\n          {\n            \"name\": \"Brand new style\",\n            \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n          },\n          {\n            \"name\": \"Silk\",\n            \"optionName\": \"Material\"\n          }\n        ],\n        \"price\": 22.0\n      },\n      {\n        \"optionValues\": [\n          {\n            \"name\": \"Brand new style\",\n            \"optionName\": \"Style\"\n          },\n          {\n            \"id\": \"gid://shopify/ProductOptionValue/1054672336\",\n            \"optionName\": \"Color\"\n          },\n          {\n            \"name\": \"Silk\",\n            \"optionName\": \"Material\"\n          }\n        ],\n        \"price\": 23.5\n      },\n      {\n        \"optionValues\": [\n          {\n            \"name\": \"Brand new style\",\n            \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n          },\n          {\n            \"id\": \"gid://shopify/ProductOptionValue/1054672337\",\n            \"optionId\": \"gid://shopify/ProductOption/1064576529\"\n          },\n          {\n            \"id\": \"gid://shopify/ProductOptionValue/1054672339\",\n            \"optionId\": \"gid://shopify/ProductOption/1064576531\"\n          }\n        ],\n        \"price\": 29.5\n      }\n    ]\n  }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n  data: {\n    \"query\": `mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n      productVariantsBulkCreate(productId: $productId, variants: $variants) {\n        userErrors {\n          field\n          message\n        }\n        product {\n          id\n          options {\n            id\n            name\n            values\n            position\n            optionValues {\n              id\n              name\n              hasVariants\n            }\n          }\n        }\n        productVariants {\n          id\n          title\n          selectedOptions {\n            name\n            value\n          }\n        }\n      }\n    }`,\n    \"variables\": {\n      \"productId\": \"gid://shopify/Product/1072481066\",\n      \"variants\": [\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Red\",\n              \"optionName\": \"Color\"\n            },\n            {\n              \"name\": \"Brand new style\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n            },\n            {\n              \"name\": \"Silk\",\n              \"optionName\": \"Material\"\n            }\n          ],\n          \"price\": 22.0\n        },\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Brand new style\",\n              \"optionName\": \"Style\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672336\",\n              \"optionName\": \"Color\"\n            },\n            {\n              \"name\": \"Silk\",\n              \"optionName\": \"Material\"\n            }\n          ],\n          \"price\": 23.5\n        },\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Brand new style\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672337\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576529\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672339\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576531\"\n            }\n          ],\n          \"price\": 29.5\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 productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n    productVariantsBulkCreate(productId: $productId, variants: $variants) {\n      userErrors {\n        field\n        message\n      }\n      product {\n        id\n        options {\n          id\n          name\n          values\n          position\n          optionValues {\n            id\n            name\n            hasVariants\n          }\n        }\n      }\n      productVariants {\n        id\n        title\n        selectedOptions {\n          name\n          value\n        }\n      }\n    }\n  }\nQUERY\n\nvariables = {\n  \"productId\": \"gid://shopify/Product/1072481066\",\n  \"variants\": [{\"optionValues\"=>[{\"name\"=>\"Red\", \"optionName\"=>\"Color\"}, {\"name\"=>\"Brand new style\", \"optionId\"=>\"gid://shopify/ProductOption/1064576530\"}, {\"name\"=>\"Silk\", \"optionName\"=>\"Material\"}], \"price\"=>22.0}, {\"optionValues\"=>[{\"name\"=>\"Brand new style\", \"optionName\"=>\"Style\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054672336\", \"optionName\"=>\"Color\"}, {\"name\"=>\"Silk\", \"optionName\"=>\"Material\"}], \"price\"=>23.5}, {\"optionValues\"=>[{\"name\"=>\"Brand new style\", \"optionId\"=>\"gid://shopify/ProductOption/1064576530\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054672337\", \"optionId\"=>\"gid://shopify/ProductOption/1064576529\"}, {\"id\"=>\"gid://shopify/ProductOptionValue/1054672339\", \"optionId\"=>\"gid://shopify/ProductOption/1064576531\"}], \"price\"=>29.5}]\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 productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n    productVariantsBulkCreate(productId: $productId, variants: $variants) {\n      userErrors {\n        field\n        message\n      }\n      product {\n        id\n        options {\n          id\n          name\n          values\n          position\n          optionValues {\n            id\n            name\n            hasVariants\n          }\n        }\n      }\n      productVariants {\n        id\n        title\n        selectedOptions {\n          name\n          value\n        }\n      }\n    }\n  }`,\n  {\n    variables: {\n      \"productId\": \"gid://shopify/Product/1072481066\",\n      \"variants\": [\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Red\",\n              \"optionName\": \"Color\"\n            },\n            {\n              \"name\": \"Brand new style\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n            },\n            {\n              \"name\": \"Silk\",\n              \"optionName\": \"Material\"\n            }\n          ],\n          \"price\": 22.0\n        },\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Brand new style\",\n              \"optionName\": \"Style\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672336\",\n              \"optionName\": \"Color\"\n            },\n            {\n              \"name\": \"Silk\",\n              \"optionName\": \"Material\"\n            }\n          ],\n          \"price\": 23.5\n        },\n        {\n          \"optionValues\": [\n            {\n              \"name\": \"Brand new style\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576530\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672337\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576529\"\n            },\n            {\n              \"id\": \"gid://shopify/ProductOptionValue/1054672339\",\n              \"optionId\": \"gid://shopify/ProductOption/1064576531\"\n            }\n          ],\n          \"price\": 29.5\n        }\n      ]\n    },\n  },\n);\n\nconst data = await response.json();\n"
Graphql query: "mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n  productVariantsBulkCreate(productId: $productId, variants: $variants) {\n    userErrors {\n      field\n      message\n    }\n    product {\n      id\n      options {\n        id\n        name\n        values\n        position\n        optionValues {\n          id\n          name\n          hasVariants\n        }\n      }\n    }\n    productVariants {\n      id\n      title\n      selectedOptions {\n        name\n        value\n      }\n    }\n  }\n}"
#### Graphql Input
{
  "productId": "gid://shopify/Product/1072481066",
  "variants": [
    {
      "optionValues": [
        {
          "name": "Red",
          "optionName": "Color"
        },
        {
          "name": "Brand new style",
          "optionId": "gid://shopify/ProductOption/1064576530"
        },
        {
          "name": "Silk",
          "optionName": "Material"
        }
      ],
      "price": 22.0
    },
    {
      "optionValues": [
        {
          "name": "Brand new style",
          "optionName": "Style"
        },
        {
          "id": "gid://shopify/ProductOptionValue/1054672336",
          "optionName": "Color"
        },
        {
          "name": "Silk",
          "optionName": "Material"
        }
      ],
      "price": 23.5
    },
    {
      "optionValues": [
        {
          "name": "Brand new style",
          "optionId": "gid://shopify/ProductOption/1064576530"
        },
        {
          "id": "gid://shopify/ProductOptionValue/1054672337",
          "optionId": "gid://shopify/ProductOption/1064576529"
        },
        {
          "id": "gid://shopify/ProductOptionValue/1054672339",
          "optionId": "gid://shopify/ProductOption/1064576531"
        }
      ],
      "price": 29.5
    }
  ]
}
#### Graphql Response
{
  "data": {
    "productVariantsBulkCreate": {
      "userErrors": [],
      "product": {
        "id": "gid://shopify/Product/1072481066",
        "options": [
          {
            "id": "gid://shopify/ProductOption/1064576529",
            "name": "Color",
            "values": [
              "Blue",
              "Red"
            ],
            "position": 1,
            "optionValues": [
              {
                "id": "gid://shopify/ProductOptionValue/1054672336",
                "name": "Blue",
                "hasVariants": true
              },
              {
                "id": "gid://shopify/ProductOptionValue/1054672337",
                "name": "Red",
                "hasVariants": true
              }
            ]
          },
          {
            "id": "gid://shopify/ProductOption/1064576530",
            "name": "Style",
            "values": [
              "Old style",
              "Brand new style"
            ],
            "position": 2,
            "optionValues": [
              {
                "id": "gid://shopify/ProductOptionValue/1054672338",
                "name": "Old style",
                "hasVariants": true
              },
              {
                "id": "gid://shopify/ProductOptionValue/1054672341",
                "name": "Brand new style",
                "hasVariants": true
              }
            ]
          },
          {
            "id": "gid://shopify/ProductOption/1064576531",
            "name": "Material",
            "values": [
              "Polyester",
              "Silk"
            ],
            "position": 3,
            "optionValues": [
              {
                "id": "gid://shopify/ProductOptionValue/1054672339",
                "name": "Polyester",
                "hasVariants": true
              },
              {
                "id": "gid://shopify/ProductOptionValue/1054672340",
                "name": "Silk",
                "hasVariants": true
              }
            ]
          }
        ]
      },
      "productVariants": [
        {
          "id": "gid://shopify/ProductVariant/1070325180",
          "title": "Red / Brand new style / Silk",
          "selectedOptions": [
            {
              "name": "Color",
              "value": "Red"
            },
            {
              "name": "Style",
              "value": "Brand new style"
            },
            {
              "name": "Material",
              "value": "Silk"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/1070325181",
          "title": "Blue / Brand new style / Silk",
          "selectedOptions": [
            {
              "name": "Color",
              "value": "Blue"
            },
            {
              "name": "Style",
              "value": "Brand new style"
            },
            {
              "name": "Material",
              "value": "Silk"
            }
          ]
        },
        {
          "id": "gid://shopify/ProductVariant/1070325182",
          "title": "Red / Brand new style / Polyester",
          "selectedOptions": [
            {
              "name": "Color",
              "value": "Red"
            },
            {
              "name": "Style",
              "value": "Brand new style"
            },
            {
              "name": "Material",
              "value": "Polyester"
            }
          ]
        }
      ]
    }
  }
}