productVariantsBulkCreate - Option does not exist

Topic summary

Issue: Using Shopify’s productVariantsBulkCreate mutation returned “Option does not exist.” The payload included media, pricing, inventory, and optionValues.

Root cause: The optionValues fields were inverted.

  • name should be the selected option value (e.g., L, M, Blue, White).
  • optionName should be the product option name (e.g., Size, Color, Material).

Fix: Swap the values so that name = selected value and optionName = option name. After correcting this mapping, the mutation worked.

Status: Resolved; no further open questions noted.

Summarized with AI on December 23. AI used: gpt-5.
mutation productVariantsBulkCreate($productId: ID!, $media: [CreateMediaInput!] , $strategy:ProductVariantsBulkCreateStrategy!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkCreate(productId: $productId, variants: $variants, media: $media, strategy:$strategy) {
product {
id
}
userErrors {
field
message
}
}
}

I used the productVariantsBulkCreate mutation to create new variant, with full of params for payload:

{
  "productId": "gid://shopify/Product/9562088571168",
  "media": [
    {
      "alt": "https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg",
      "mediaContentType": "IMAGE",
      "originalSource": "https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg"
    }
  ],
  "variants": [
    {
      "compareAtPrice": "77662.99",
      "price": "51775.45",
      "inventoryItem": {
        "cost": "25887.60",
        "tracked": true
      },
      "inventoryPolicy": "CONTINUE",
      "inventoryQuantities": {
        "availableQuantity": 2399,
        "locationId": "gid://shopify/Location/100882448672"
      },
      "mediaSrc": [
        "https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg"
      ],
      "optionValues": [
        {
          "name": "Size",
          "optionName": "8 inch"
        },
        {
          "name": "Color",
          "optionName": "honeycomb Tan"
        }
      ],
      "taxable": true
    }
  ]
}

I’ve checked some questions related with this mutation, and make sure that my payload is correct. But when running, I got the error:

"errors": [
    {
      "message": "Option does not exist",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "productVariantsBulkCreate"
      ]
    }
  ]

What are the errors? How can I fix to create new variant success?

Sorry all,

I found my error:

name          => name of variant selected option ( like L,M, Blue, White...)

optionName.   => name of product option (like Size, Color, Material)

But I did with the reverse back. My problem was fixed.

Thanks all,

1 Like