Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) { productUpdateMedia(media: $media, productId: $productId) { media { alt } } }\",\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n media {\n alt\n }\n }\n }`,\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n media {\n alt\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": [{\"alt\"=>\"Some alt text\", \"id\"=>\"gid://shopify/Video/723685877\"}, {\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/853695510\"}],\n \"productId\": \"gid://shopify/Product/108828309\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[{\"alt\"=>\"Some alt text\", \"id\"=>\"gid://shopify/Video/723685877\"}, {\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/853695510\"}],\n \"productId\" => \"gid://shopify/Product/108828309\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n media {\n alt\n }\n }\n }`,\n {\n variables: {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n media {\n alt\n }\n }\n}"
input: { "media": [ { "alt": "Some alt text", "id": "gid://shopify/Video/723685877" }, { "alt": "Some more alt text", "id": "gid://shopify/MediaImage/853695510" } ], "productId": "gid://shopify/Product/108828309" }
response: { "data": { "productUpdateMedia": { "media": [ { "alt": "Some alt text" }, { "alt": "Some more alt text" } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) { productUpdateMedia(media: $media, productId: $productId) { product { id title } media { alt } mediaUserErrors { field message } } }\",\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": [{\"alt\"=>\"Some alt text\", \"id\"=>\"gid://shopify/Video/723685877\"}, {\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/853695510\"}],\n \"productId\": \"gid://shopify/Product/-1\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[{\"alt\"=>\"Some alt text\", \"id\"=>\"gid://shopify/Video/723685877\"}, {\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/853695510\"}],\n \"productId\" => \"gid://shopify/Product/-1\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"media\": [\n {\n \"alt\": \"Some alt text\",\n \"id\": \"gid://shopify/Video/723685877\"\n },\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/853695510\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n }\n }\n}"
input: { "media": [ { "alt": "Some alt text", "id": "gid://shopify/Video/723685877" }, { "alt": "Some more alt text", "id": "gid://shopify/MediaImage/853695510" } ], "productId": "gid://shopify/Product/-1" }
response: { "data": { "productUpdateMedia": { "product": null, "media": null, "mediaUserErrors": [ { "field": [ "productId" ], "message": "Product does not exist" } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) { productUpdateMedia(media: $media, productId: $productId) { product { id title } media { alt } mediaUserErrors { field message code } } }\",\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": [{\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/-1\"}],\n \"productId\": \"gid://shopify/Product/-1\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[{\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/-1\"}],\n \"productId\" => \"gid://shopify/Product/-1\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/-1\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n}"
input: { "media": [ { "alt": "Some more alt text", "id": "gid://shopify/MediaImage/-1" } ], "productId": "gid://shopify/Product/-1" }
response: { "data": { "productUpdateMedia": { "product": null, "media": null, "mediaUserErrors": [ { "field": [ "productId" ], "message": "Product does not exist", "code": "PRODUCT_DOES_NOT_EXIST" } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) { productUpdateMedia(media: $media, productId: $productId) { product { id title } media { alt } mediaUserErrors { field message code } } }\",\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": [{\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/-1\"}],\n \"productId\": \"gid://shopify/Product/108828309\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<[{\"alt\"=>\"Some more alt text\", \"id\"=>\"gid://shopify/MediaImage/-1\"}],\n \"productId\" => \"gid://shopify/Product/108828309\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"media\": [\n {\n \"alt\": \"Some more alt text\",\n \"id\": \"gid://shopify/MediaImage/-1\"\n }\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {\n productUpdateMedia(media: $media, productId: $productId) {\n product {\n id\n title\n }\n media {\n alt\n }\n mediaUserErrors {\n field\n message\n code\n }\n }\n}"
input: { "media": [ { "alt": "Some more alt text", "id": "gid://shopify/MediaImage/-1" } ], "productId": "gid://shopify/Product/108828309" }
response: { "data": { "productUpdateMedia": { "product": { "id": "gid://shopify/Product/108828309", "title": "Draft" }, "media": null, "mediaUserErrors": [ { "field": [ "media" ], "message": "Media id gid://shopify/MediaImage/-1 does not exist", "code": "MEDIA_DOES_NOT_EXIST" } ] } } }