Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) { productCreateMedia(media: $media, productId: $productId) { media { alt mediaContentType status } mediaUserErrors { field message } product { id title } } }\",\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n }\n ],\n \"productId\": \"gid://shopify/Product/121709582\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n \"variables\": {\n \"media\": [\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n }\n ],\n \"productId\": \"gid://shopify/Product/121709582\"\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": [{\"alt\"=>\"Image\", \"mediaContentType\"=>\"EXTERNAL_VIDEO\", \"originalSource\"=>\"https://youtu.be/32mGBDk3LSo\"}, {\"alt\"=>\"Image\", \"mediaContentType\"=>\"IMAGE\", \"originalSource\"=>\"invalid_img\"}],\n \"productId\": \"gid://shopify/Product/121709582\"\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 = <<<QUERY\n mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY;\n\n$variables = [\n \"media\" => [{\"alt\"=>\"Image\", \"mediaContentType\"=>\"EXTERNAL_VIDEO\", \"originalSource\"=>\"https://youtu.be/32mGBDk3LSo\"}, {\"alt\"=>\"Image\", \"mediaContentType\"=>\"IMAGE\", \"originalSource\"=>\"invalid_img\"}],\n \"productId\" => \"gid://shopify/Product/121709582\",\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n {\n variables: {\n \"media\": [\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n }\n ],\n \"productId\": \"gid://shopify/Product/121709582\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n}"
input: { "media": [ { "alt": "Image", "mediaContentType": "EXTERNAL_VIDEO", "originalSource": "https://youtu.be/32mGBDk3LSo" }, { "alt": "Image", "mediaContentType": "IMAGE", "originalSource": "invalid_img" } ], "productId": "gid://shopify/Product/121709582" }
response: { "data": { "productCreateMedia": { "media": [ { "alt": "Image", "mediaContentType": "EXTERNAL_VIDEO", "status": "UPLOADED" } ], "mediaUserErrors": [ { "field": [ "media", "1", "originalSource" ], "message": "Image URL is invalid" } ], "product": { "id": "gid://shopify/Product/121709582", "title": "Boots" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) { productCreateMedia(media: $media, productId: $productId) { media { alt mediaContentType status } mediaUserErrors { field message } product { id title } } }\",\n \"variables\": {\n \"media\": {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n \"variables\": {\n \"media\": {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\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 = <<<QUERY\n mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY;\n\n$variables = [\n \"media\" => [\n \"alt\" => \"Image\",\n \"mediaContentType\" => \"IMAGE\",\n \"originalSource\" => \"invalid_img\",\n ],\n \"productId\" => \"gid://shopify/Product/121709582\",\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n {\n variables: {\n \"media\": {\n \"alt\": \"Image\",\n \"mediaContentType\": \"IMAGE\",\n \"originalSource\": \"invalid_img\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n}"
input: { "media": { "alt": "Image", "mediaContentType": "IMAGE", "originalSource": "invalid_img" }, "productId": "gid://shopify/Product/121709582" }
response: { "data": { "productCreateMedia": { "media": [], "mediaUserErrors": [ { "field": [ "media", "0", "originalSource" ], "message": "Image URL is invalid" } ], "product": { "id": "gid://shopify/Product/121709582", "title": "Boots" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) { productCreateMedia(media: $media, productId: $productId) { media { alt mediaContentType status } mediaUserErrors { field message } product { id title } } }\",\n \"variables\": {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n \"variables\": {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\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 = <<<QUERY\n mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY;\n\n$variables = [\n \"media\" => [\n \"alt\" => \"Video\",\n \"mediaContentType\" => \"EXTERNAL_VIDEO\",\n \"originalSource\" => \"https://youtu.be/32mGBDk3LSo\",\n ],\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n {\n variables: {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n \"productId\": \"gid://shopify/Product/-1\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n}"
input: { "media": { "alt": "Video", "mediaContentType": "EXTERNAL_VIDEO", "originalSource": "https://youtu.be/32mGBDk3LSo" }, "productId": "gid://shopify/Product/-1" }
response: { "data": { "productCreateMedia": { "media": null, "mediaUserErrors": [ { "field": [ "productId" ], "message": "Product does not exist" } ], "product": null } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) { productCreateMedia(media: $media, productId: $productId) { media { alt mediaContentType status } mediaUserErrors { field message } product { id title } } }\",\n \"variables\": {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n \"variables\": {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY\n\nvariables = {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\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 = <<<QUERY\n mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }\nQUERY;\n\n$variables = [\n \"media\" => [\n \"alt\" => \"Video\",\n \"mediaContentType\" => \"EXTERNAL_VIDEO\",\n \"originalSource\" => \"https://youtu.be/32mGBDk3LSo\",\n ],\n \"productId\" => \"gid://shopify/Product/121709582\",\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 productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n }`,\n {\n variables: {\n \"media\": {\n \"alt\": \"Video\",\n \"mediaContentType\": \"EXTERNAL_VIDEO\",\n \"originalSource\": \"https://youtu.be/32mGBDk3LSo\"\n },\n \"productId\": \"gid://shopify/Product/121709582\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {\n productCreateMedia(media: $media, productId: $productId) {\n media {\n alt\n mediaContentType\n status\n }\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n }\n }\n}"
input: { "media": { "alt": "Video", "mediaContentType": "EXTERNAL_VIDEO", "originalSource": "https://youtu.be/32mGBDk3LSo" }, "productId": "gid://shopify/Product/121709582" }
response: { "data": { "productCreateMedia": { "media": [ { "alt": "Video", "mediaContentType": "EXTERNAL_VIDEO", "status": "UPLOADED" } ], "mediaUserErrors": [], "product": { "id": "gid://shopify/Product/121709582", "title": "Boots" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ProductImageCreate($id: ID!) { productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \\\"https://path.to/image.jpg\\\", alt: \\\"Alt text.\\\"}]) { media { id alt status ... on MediaImage { image { url } } } mediaUserErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Product/121709582\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation ProductImageCreate($id: ID!) {\n productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \"https://path.to/image.jpg\", alt: \"Alt text.\"}]) {\n media {\n id\n alt\n status\n ... on MediaImage {\n image {\n url\n }\n }\n }\n mediaUserErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Product/121709582\"\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 ProductImageCreate($id: ID!) {\n productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \"https://path.to/image.jpg\", alt: \"Alt text.\"}]) {\n media {\n id\n alt\n status\n ... on MediaImage {\n image {\n url\n }\n }\n }\n mediaUserErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Product/121709582\"\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 = <<<QUERY\n mutation ProductImageCreate($id: ID!) {\n productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \"https://path.to/image.jpg\", alt: \"Alt text.\"}]) {\n media {\n id\n alt\n status\n ... on MediaImage {\n image {\n url\n }\n }\n }\n mediaUserErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/Product/121709582\",\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 ProductImageCreate($id: ID!) {\n productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \"https://path.to/image.jpg\", alt: \"Alt text.\"}]) {\n media {\n id\n alt\n status\n ... on MediaImage {\n image {\n url\n }\n }\n }\n mediaUserErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Product/121709582\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ProductImageCreate($id: ID!) {\n productCreateMedia(productId: $id, media: [{mediaContentType: IMAGE, originalSource: \"https://path.to/image.jpg\", alt: \"Alt text.\"}]) {\n media {\n id\n alt\n status\n ... on MediaImage {\n image {\n url\n }\n }\n }\n mediaUserErrors {\n field\n message\n }\n }\n}"
input: { "id": "gid://shopify/Product/121709582" }
response: { "data": { "productCreateMedia": { "media": [ { "id": "gid://shopify/MediaImage/1072273196", "alt": "Alt text.", "status": "UPLOADED", "image": null } ], "mediaUserErrors": [] } } }