Asynchronously create a product with two variants
Description
Create a product with two variants asynchronously using different
[option values](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOptionValue).
This example returns a [`productSetOperation`](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductSetOperation)
with the status `CREATED`.
Query
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
Variables
{
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id } productSetOperation { id status userErrors { code field message } } userErrors { code field message } } }",
"variables": {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
},
},
);
const data = await response.json();
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 createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"synchronous": false,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"price": 69.99
}
]
}
},
},
});
Response
{
"productSet": {
"product": null,
"productSetOperation": {
"id": "gid://shopify/ProductSetOperation/1010603851",
"status": "CREATED",
"userErrors": []
},
"userErrors": []
}
}
Create a product and associate files
Description
Create a product and associate file attachments (like images or videos).
This example returns the product and its associated image files.
Query
mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
variants(first: 5) {
nodes {
title
price
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"files": [
{
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
{
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"file": {
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"file": {
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id media(first: 5) { nodes { id alt mediaContentType status } } variants(first: 5) { nodes { title price media(first: 5) { nodes { id alt mediaContentType status } } } } } userErrors { field message } } }",
"variables": {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"files": [
{
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
{
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"file": {
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"file": {
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
}
]
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
variants(first: 5) {
nodes {
title
price
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"files": [
{
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
{
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"file": {
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"file": {
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
}
]
}
},
},
);
const data = await response.json();
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 createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
variants(first: 5) {
nodes {
title
price
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"files": [
{
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
{
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"file": {
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"file": {
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
variants(first: 5) {
nodes {
title
price
media(first: 5) {
nodes {
id
alt
mediaContentType
status
}
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"files": [
{
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
{
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"file": {
"originalSource": "https://example.com/hats/grey-hat.jpg",
"alt": "An elegant grey hat",
"filename": "grey-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"file": {
"originalSource": "https://example.com/hats/black-hat.jpg",
"alt": "An elegant black hat",
"filename": "black-hat.jpg",
"contentType": "IMAGE"
},
"price": 11.99
}
]
}
},
},
});
Response
{
"productSet": {
"product": {
"id": "gid://shopify/Product/1072481957",
"media": {
"nodes": [
{
"alt": "An elegant grey hat",
"mediaContentType": "IMAGE",
"status": "UPLOADED"
},
{
"alt": "An elegant black hat",
"mediaContentType": "IMAGE",
"status": "UPLOADED"
}
]
},
"variants": {
"nodes": [
{
"title": "Grey",
"price": "11.99",
"media": {
"nodes": [
{
"alt": "An elegant grey hat",
"mediaContentType": "IMAGE",
"status": "UPLOADED"
}
]
}
},
{
"title": "Black",
"price": "11.99",
"media": {
"nodes": [
{
"alt": "An elegant black hat",
"mediaContentType": "IMAGE",
"status": "UPLOADED"
}
]
}
}
]
}
},
"userErrors": []
}
}
Create a product with customized inventory quantities
Description
Create a product with [inventory quantities](https://shopify.dev/docs/apps/build/orders-fulfillment/inventory-management-apps/manage-quantities-states).
This example returns the product with the specified inventory quantities configured for the variants.
Query
mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
variants(first: 5) {
nodes {
title
price
inventoryQuantity
inventoryItem {
inventoryLevels(first: 5) {
nodes {
location {
id
name
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 12
},
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 19
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 976
},
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 844
}
],
"price": 11.99
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id variants(first: 5) { nodes { title price inventoryQuantity inventoryItem { inventoryLevels(first: 5) { nodes { location { id name } } } } } } } userErrors { field message } } }",
"variables": {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 12
},
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 19
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 976
},
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 844
}
],
"price": 11.99
}
]
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
variants(first: 5) {
nodes {
title
price
inventoryQuantity
inventoryItem {
inventoryLevels(first: 5) {
nodes {
location {
id
name
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 12
},
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 19
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 976
},
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 844
}
],
"price": 11.99
}
]
}
},
},
);
const data = await response.json();
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 createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
variants(first: 5) {
nodes {
title
price
inventoryQuantity
inventoryItem {
inventoryLevels(first: 5) {
nodes {
location {
id
name
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 12
},
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 19
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 976
},
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 844
}
],
"price": 11.99
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation createProduct($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
variants(first: 5) {
nodes {
title
price
inventoryQuantity
inventoryItem {
inventoryLevels(first: 5) {
nodes {
location {
id
name
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"synchronous": true,
"productSet": {
"title": "Winter hat",
"productOptions": [
{
"name": "Color",
"position": 1,
"values": [
{
"name": "Grey"
},
{
"name": "Black"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Color",
"name": "Grey"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 12
},
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 19
}
],
"price": 79.99
},
{
"optionValues": [
{
"optionName": "Color",
"name": "Black"
}
],
"inventoryQuantities": [
{
"locationId": "gid://shopify/Location/346779380",
"name": "available",
"quantity": 976
},
{
"locationId": "gid://shopify/Location/415211365",
"name": "available",
"quantity": 844
}
],
"price": 11.99
}
]
}
},
},
});
Response
{
"productSet": {
"product": {
"id": "gid://shopify/Product/1072481937",
"variants": {
"nodes": [
{
"title": "Grey",
"price": "79.99",
"inventoryQuantity": 31,
"inventoryItem": {
"inventoryLevels": {
"nodes": [
{
"location": {
"id": "gid://shopify/Location/346779380",
"name": "Ottawa Store"
}
},
{
"location": {
"id": "gid://shopify/Location/415211365",
"name": "US Store"
}
}
]
}
}
},
{
"title": "Black",
"price": "11.99",
"inventoryQuantity": 1820,
"inventoryItem": {
"inventoryLevels": {
"nodes": [
{
"location": {
"id": "gid://shopify/Location/346779380",
"name": "Ottawa Store"
}
},
{
"location": {
"id": "gid://shopify/Location/415211365",
"name": "US Store"
}
}
]
}
}
}
]
}
},
"userErrors": []
}
}
Create a product with two options and four variants
Description
Create a product with [multiple options](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption)
and all possible [variant](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) combinations.
This example returns a product with two options and four variants, representing all
[option value](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOptionValue) combinations.
Query
mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
options(first: 5) {
name
position
optionValues {
name
}
}
variants(first: 5) {
nodes {
price
selectedOptions {
name
optionValue {
id
name
}
}
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"synchronous": true,
"productSet": {
"title": "A humble tie",
"productOptions": [
{
"name": "Pattern",
"position": 1,
"values": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"values": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
}
]
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id title options(first: 5) { name position optionValues { name } } variants(first: 5) { nodes { price selectedOptions { name optionValue { id name } } } } } userErrors { field message } } }",
"variables": {
"synchronous": true,
"productSet": {
"title": "A humble tie",
"productOptions": [
{
"name": "Pattern",
"position": 1,
"values": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"values": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
}
]
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
options(first: 5) {
name
position
optionValues {
name
}
}
variants(first: 5) {
nodes {
price
selectedOptions {
name
optionValue {
id
name
}
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"synchronous": true,
"productSet": {
"title": "A humble tie",
"productOptions": [
{
"name": "Pattern",
"position": 1,
"values": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"values": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
}
]
}
},
},
);
const data = await response.json();
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 createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
options(first: 5) {
name
position
optionValues {
name
}
}
variants(first: 5) {
nodes {
price
selectedOptions {
name
optionValue {
id
name
}
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"synchronous": true,
"productSet": {
"title": "A humble tie",
"productOptions": [
{
"name": "Pattern",
"position": 1,
"values": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"values": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation createProductWithTwoOptionsAndVariants($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
title
options(first: 5) {
name
position
optionValues {
name
}
}
variants(first: 5) {
nodes {
price
selectedOptions {
name
optionValue {
id
name
}
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"synchronous": true,
"productSet": {
"title": "A humble tie",
"productOptions": [
{
"name": "Pattern",
"position": 1,
"values": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"values": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": [
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Plain"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Slim"
}
],
"price": 15
},
{
"optionValues": [
{
"optionName": "Pattern",
"name": "Stripes"
},
{
"optionName": "Width",
"name": "Classic"
}
],
"price": 15
}
]
}
},
},
});
Response
{
"productSet": {
"product": {
"id": "gid://shopify/Product/1072481953",
"title": "A humble tie",
"options": [
{
"name": "Pattern",
"position": 1,
"optionValues": [
{
"name": "Plain"
},
{
"name": "Stripes"
}
]
},
{
"name": "Width",
"position": 2,
"optionValues": [
{
"name": "Slim"
},
{
"name": "Classic"
}
]
}
],
"variants": {
"nodes": [
{
"price": "15.00",
"selectedOptions": [
{
"name": "Pattern",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677147",
"name": "Plain"
}
},
{
"name": "Width",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677149",
"name": "Slim"
}
}
]
},
{
"price": "15.00",
"selectedOptions": [
{
"name": "Pattern",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677147",
"name": "Plain"
}
},
{
"name": "Width",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677150",
"name": "Classic"
}
}
]
},
{
"price": "15.00",
"selectedOptions": [
{
"name": "Pattern",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677148",
"name": "Stripes"
}
},
{
"name": "Width",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677149",
"name": "Slim"
}
}
]
},
{
"price": "15.00",
"selectedOptions": [
{
"name": "Pattern",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677148",
"name": "Stripes"
}
},
{
"name": "Width",
"optionValue": {
"id": "gid://shopify/ProductOptionValue/1054677150",
"name": "Classic"
}
}
]
}
]
}
},
"userErrors": []
}
}