Add new media to an existing product
Description
Add new media, such as an image and a video, to an existing product.
The media is [asynchronously](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components#asynchronous-media-management)
uploaded and associated with the product. This example returns the product's ID, title, and media.
Learn more about [managing media for products](https://shopify.dev/docs/apps/build/online-store/product-media).
Query
mutation UpdateProductWithNewMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) {
productUpdate(product: $product, media: $media) {
product {
id
media(first: 10) {
nodes {
alt
mediaContentType
preview {
status
}
}
}
}
userErrors {
field
message
}
}
}
Variables
{
"product": {
"id": "gid://shopify/Product/912855135"
},
"media": [
{
"originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png",
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE"
},
{
"originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz",
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO"
}
]
}
cURL
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 UpdateProductWithNewMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) { productUpdate(product: $product, media: $media) { product { id media(first: 10) { nodes { alt mediaContentType preview { status } } } } userErrors { field message } } }",
"variables": {
"product": {
"id": "gid://shopify/Product/912855135"
},
"media": [
{
"originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png",
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE"
},
{
"originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz",
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO"
}
]
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateProductWithNewMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) {
productUpdate(product: $product, media: $media) {
product {
id
media(first: 10) {
nodes {
alt
mediaContentType
preview {
status
}
}
}
}
userErrors {
field
message
}
}
}`,
{
variables: {
"product": {
"id": "gid://shopify/Product/912855135"
},
"media": [
{
"originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png",
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE"
},
{
"originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz",
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO"
}
]
},
},
);
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 UpdateProductWithNewMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) {
productUpdate(product: $product, media: $media) {
product {
id
media(first: 10) {
nodes {
alt
mediaContentType
preview {
status
}
}
}
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"product": {
"id": "gid://shopify/Product/912855135"
},
"media": [
{
"originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png",
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE"
},
{
"originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz",
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO"
}
]
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateProductWithNewMedia($product: ProductUpdateInput!, $media: [CreateMediaInput!]) {
productUpdate(product: $product, media: $media) {
product {
id
media(first: 10) {
nodes {
alt
mediaContentType
preview {
status
}
}
}
}
userErrors {
field
message
}
}
}`,
"variables": {
"product": {
"id": "gid://shopify/Product/912855135"
},
"media": [
{
"originalSource": "https://cdn.shopify.com/shopifycloud/brochure/assets/sell/image/image-@artdirection-large-1ba8d5de56c361cec6bc487b747c8774b9ec8203f392a99f53c028df8d0fb3fc.png",
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE"
},
{
"originalSource": "https://www.youtube.com/watch?v=4L8VbGRibj8&list=PLlMkWQ65HlcEoPyG9QayqEaAu0ftj0MMz",
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO"
}
]
},
},
});
Response
{
"productUpdate": {
"product": {
"id": "gid://shopify/Product/912855135",
"media": {
"nodes": [
{
"alt": "Gray helmet for bikers",
"mediaContentType": "IMAGE",
"preview": {
"status": "UPLOADED"
}
},
{
"alt": "Testing helmet resistance against impacts",
"mediaContentType": "EXTERNAL_VIDEO",
"preview": {
"status": "UPLOADED"
}
}
]
}
},
"userErrors": []
}
}
Update a product with comprehensive details
Description
Update a product to include information such as SEO settings, vendor details, and tags.
This example returns the product's ID, title, handle, vendor, product type, status, tags, and SEO settings.
Learn more about the [product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model)
and [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data).
Query
mutation UpdateProductComprehensive($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
vendor
productType
status
tags
seo {
title
description
}
}
}
}
Variables
{
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"eco-friendly",
"bamboo",
"sustainable",
"water bottle",
"reusable"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
}
cURL
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 UpdateProductComprehensive($product: ProductUpdateInput!) { productUpdate(product: $product) { userErrors { field message } product { id title handle vendor productType status tags seo { title description } } } }",
"variables": {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"eco-friendly",
"bamboo",
"sustainable",
"water bottle",
"reusable"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateProductComprehensive($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
vendor
productType
status
tags
seo {
title
description
}
}
}
}`,
{
variables: {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"eco-friendly",
"bamboo",
"sustainable",
"water bottle",
"reusable"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
},
},
);
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 UpdateProductComprehensive($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
vendor
productType
status
tags
seo {
title
description
}
}
}
}
QUERY
variables = {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"eco-friendly",
"bamboo",
"sustainable",
"water bottle",
"reusable"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateProductComprehensive($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
vendor
productType
status
tags
seo {
title
description
}
}
}
}`,
"variables": {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"eco-friendly",
"bamboo",
"sustainable",
"water bottle",
"reusable"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
},
},
});
Response
{
"productUpdate": {
"userErrors": [],
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Eco-Friendly Bamboo Water Bottle",
"handle": "eco-bamboo-water-bottle",
"vendor": "EcoLife Products",
"productType": "Water Bottles",
"status": "ACTIVE",
"tags": [
"bamboo",
"eco-friendly",
"reusable",
"sustainable",
"water bottle"
],
"seo": {
"title": "Eco-Friendly Bamboo Water Bottle - Sustainable Hydration | EcoLife",
"description": "Discover our premium bamboo water bottle made from 100% natural materials. Perfect for sustainable living. Free shipping available."
}
}
}
}
Update a product with custom metafields
Description
Update a product with custom metafields to track additional product information like
care instructions, material composition, and warranty details. This example returns
the product's ID, title, handle, and metafields. Learn more about using
[metafields](https://shopify.dev/docs/apps/build/custom-data).
Query
mutation UpdateProductWithMetafields($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
metafields(first: 10) {
edges {
node {
id
namespace
key
value
type
}
}
}
}
}
}
Variables
{
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": [
{
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
},
{
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
},
{
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
},
{
"namespace": "inventory",
"key": "supplier_code",
"value": "SUP-001-TCH",
"type": "single_line_text_field"
}
]
}
}
cURL
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 UpdateProductWithMetafields($product: ProductUpdateInput!) { productUpdate(product: $product) { userErrors { field message } product { id title handle metafields(first: 10) { edges { node { id namespace key value type } } } } } }",
"variables": {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": [
{
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
},
{
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
},
{
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
},
{
"namespace": "inventory",
"key": "supplier_code",
"value": "SUP-001-TCH",
"type": "single_line_text_field"
}
]
}
}
}'
Remix
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateProductWithMetafields($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
metafields(first: 10) {
edges {
node {
id
namespace
key
value
type
}
}
}
}
}
}`,
{
variables: {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": [
{
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
},
{
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
},
{
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
},
{
"namespace": "inventory",
"key": "supplier_code",
"value": "SUP-001-TCH",
"type": "single_line_text_field"
}
]
}
},
},
);
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 UpdateProductWithMetafields($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
metafields(first: 10) {
edges {
node {
id
namespace
key
value
type
}
}
}
}
}
}
QUERY
variables = {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": [
{
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
},
{
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
},
{
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
},
{
"namespace": "inventory",
"key": "supplier_code",
"value": "SUP-001-TCH",
"type": "single_line_text_field"
}
]
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateProductWithMetafields($product: ProductUpdateInput!) {
productUpdate(product: $product) {
userErrors {
field
message
}
product {
id
title
handle
metafields(first: 10) {
edges {
node {
id
namespace
key
value
type
}
}
}
}
}
}`,
"variables": {
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": [
{
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
},
{
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
},
{
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
},
{
"namespace": "inventory",
"key": "supplier_code",
"value": "SUP-001-TCH",
"type": "single_line_text_field"
}
]
}
},
},
});
Response
{
"productUpdate": {
"userErrors": [],
"product": {
"id": "gid://shopify/Product/108828309",
"title": "Premium Cotton T-Shirt",
"handle": "premium-cotton-tshirt",
"metafields": {
"edges": [
{
"node": {
"id": "gid://shopify/Metafield/61655654",
"namespace": "translations",
"key": "title_de",
"value": "produkt",
"type": "single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/147010266",
"namespace": "information",
"key": "exporters",
"value": "[\"Brazil\",\"USA\",\"Mexico\",\"Canada\"]",
"type": "list.single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/204658793",
"namespace": "information",
"key": "recyclable",
"value": "false",
"type": "boolean"
}
},
{
"node": {
"id": "gid://shopify/Metafield/485513001",
"namespace": "information",
"key": "model",
"value": "Ski Magic",
"type": "single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/632448133",
"namespace": "information",
"key": "materials",
"value": "[\"carbon fiber 4\",\"plastic - HDPE\",\"velcro\"]",
"type": "list.single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/911569663",
"namespace": "information",
"key": "competitor_cost",
"value": "50.35",
"type": "float"
}
},
{
"node": {
"id": "gid://shopify/Metafield/1007023387",
"namespace": "information",
"key": "year_released",
"value": "2019",
"type": "number_integer"
}
},
{
"node": {
"id": "gid://shopify/Metafield/1069229912",
"namespace": "custom",
"key": "care_instructions",
"value": "Machine wash cold, tumble dry low, do not bleach",
"type": "single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/1069229913",
"namespace": "custom",
"key": "material_composition",
"value": "100% Organic Cotton",
"type": "single_line_text_field"
}
},
{
"node": {
"id": "gid://shopify/Metafield/1069229914",
"namespace": "warranty",
"key": "warranty_period",
"value": "12",
"type": "number_integer"
}
}
]
}
}
}
}