productCreate
Requires access scope. Also: The user must have a permission to create products.
Creates a product
with attributes such as title, description, and vendor.
You can use the mutation to define
options and
values
for products with
product variants,
such as different sizes or colors.
To create multiple product variants for a single product and manage prices, use the
mutation.
To create or update a product in a single request, use the
mutation.
Learn more about the product model and adding product data.
Arguments
- Anchor to mediamedia•
The media to add to the product.
- Anchor to productproduct•
The attributes of the new product.
- Anchor to inputinput•Product
Input Deprecated The properties of the new product. Deprecated as of
2024-10
.Use
product
argument instead.
Anchor to ProductCreatePayload returnsProductCreatePayload returns
- Anchor to productproduct•
The product object.
- Anchor to shopshop•Shop!non-null
The shop associated with the product.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Examples
mutation {
productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) {
product {
id
title
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
}
userErrors {
field
message
}
}
}
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 { productCreate(product: {title: \"Cool socks\", productOptions: [{name: \"Color\", values: [{name: \"Red\"}, {name: \"Blue\"}]}, {name: \"Size\", values: [{name: \"Small\"}, {name: \"Large\"}]}]}) { product { id title options { id name position optionValues { id name hasVariants } } } userErrors { field message } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation {
productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) {
product {
id
title
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
}
userErrors {
field
message
}
}
}`,
);
const data = await response.json();
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 {
productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) {
product {
id
title
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
}
userErrors {
field
message
}
}
}
QUERY
response = client.query(query: query)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `mutation {
productCreate(product: {title: "Cool socks", productOptions: [{name: "Color", values: [{name: "Red"}, {name: "Blue"}]}, {name: "Size", values: [{name: "Small"}, {name: "Large"}]}]}) {
product {
id
title
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
}
userErrors {
field
message
}
}
}`,
});