Requires write_products
access scope. Also: The user must have a permission to create product variants.
Creates one or more options on a product, such as size, color, or material. Each option includes a name, position, and a list of values. The combination of a product option and value creates a product variant.
Use the productOptionsCreate
mutation for the following use cases:
The productOptionsCreate
mutation enforces strict data integrity for product options and variants. All option positions must be sequential, and every option should be used by at least one variant. If you use the CREATE
variant strategy, consider the maximum allowed number of variants for each product (100 by default, and 2,048 if you've enabled the Extended Variants developer preview).
After you create product options, you can further manage a product's configuration using related mutations:
productOptionUpdate
productOptionsReorder
productOptionsDelete
productVariantsBulkCreate
productVariantsBulkUpdate
productSet
Learn more about the product model and adding product data.
Options to add to the product.
The ID of the product to update.
The strategy defines which behavior the mutation should observe regarding variants. If not provided or set to null, the strategy LEAVE_AS_IS
will be used.
The updated product object.
The list of errors that occurred from executing the mutation.
mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { userErrors { field message code } product { id variants(first: 10) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { userErrors { field message code } product { id variants(first: 10) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } }", "variables": { "productId": "gid://shopify/Product/20995642", "options": [ { "name": "Color", "position": 1, "values": [ { "name": "Blue" } ] } ] } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { userErrors { field message code } product { id variants(first: 10) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } }`, { variables: { "productId": "gid://shopify/Product/20995642", "options": [ { "name": "Color", "position": 1, "values": [ { "name": "Blue" } ] } ] }, }, ); const data = await response.json();
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { userErrors { field message code } product { id variants(first: 10) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } }`, "variables": { "productId": "gid://shopify/Product/20995642", "options": [ { "name": "Color", "position": 1, "values": [ { "name": "Blue" } ] } ] }, }, });
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 createOptions($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) { productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) { userErrors { field message code } product { id variants(first: 10) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } } QUERY variables = { "productId": "gid://shopify/Product/20995642", "options": [ { "name": "Color", "position": 1, "values": [ { "name": "Blue" } ] } ] } response = client.query(query: query, variables: variables)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4