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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) { productDeleteMedia(mediaIds: $mediaIds, productId: $productId) { deletedMediaIds deletedProductImageIds mediaUserErrors { field message } product { id title media(first: 5) { nodes { alt mediaContentType status } } } } }\",\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\",\n \"gid://shopify/Video/723685877\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\",\n \"gid://shopify/Video/723685877\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"mediaIds\": [\"gid://shopify/Video/-1\", \"gid://shopify/Video/723685877\"],\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 = <<[\"gid://shopify/Video/-1\", \"gid://shopify/Video/723685877\"],\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\",\n \"gid://shopify/Video/723685877\"\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n}"
input: { "mediaIds": [ "gid://shopify/Video/-1", "gid://shopify/Video/723685877" ], "productId": "gid://shopify/Product/108828309" }
response: { "data": { "productDeleteMedia": { "deletedMediaIds": null, "deletedProductImageIds": null, "mediaUserErrors": [ { "field": [ "mediaIds" ], "message": "Media id gid://shopify/Video/-1 does not exist" } ], "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "media": { "nodes": [ { "alt": "This is a video", "mediaContentType": "EXTERNAL_VIDEO", "status": "READY" }, { "alt": "This is a video", "mediaContentType": "VIDEO", "status": "READY" }, { "alt": "This is a 3d Model", "mediaContentType": "MODEL_3D", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" } ] } } } } }
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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) { productDeleteMedia(mediaIds: $mediaIds, productId: $productId) { deletedMediaIds deletedProductImageIds mediaUserErrors { field message } product { id title media(first: 5) { nodes { alt mediaContentType status } } } } }\",\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\n ],\n \"productId\": \"gid://shopify/Product/0\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\n ],\n \"productId\": \"gid://shopify/Product/0\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"mediaIds\": [\"gid://shopify/Video/723685877\"],\n \"productId\": \"gid://shopify/Product/0\"\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 = <<[\"gid://shopify/Video/723685877\"],\n \"productId\" => \"gid://shopify/Product/0\",\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\n ],\n \"productId\": \"gid://shopify/Product/0\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n}"
input: { "mediaIds": [ "gid://shopify/Video/723685877" ], "productId": "gid://shopify/Product/0" }
response: { "data": { "productDeleteMedia": { "deletedMediaIds": null, "deletedProductImageIds": null, "mediaUserErrors": [ { "field": [ "productId" ], "message": "Product does not exist" } ], "product": null } } }
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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) { productDeleteMedia(mediaIds: $mediaIds, productId: $productId) { deletedMediaIds deletedProductImageIds mediaUserErrors { field message } product { id title media(first: 5) { nodes { alt mediaContentType status } } } } }\",\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"mediaIds\": [\"gid://shopify/Video/723685877\"],\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 = <<[\"gid://shopify/Video/723685877\"],\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"mediaIds\": [\n \"gid://shopify/Video/723685877\"\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n}"
input: { "mediaIds": [ "gid://shopify/Video/723685877" ], "productId": "gid://shopify/Product/108828309" }
response: { "data": { "productDeleteMedia": { "deletedMediaIds": [ "gid://shopify/Video/723685877" ], "deletedProductImageIds": [], "mediaUserErrors": [], "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "media": { "nodes": [ { "alt": "This is a video", "mediaContentType": "EXTERNAL_VIDEO", "status": "READY" }, { "alt": "This is a 3d Model", "mediaContentType": "MODEL_3D", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" } ] } } } } }
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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) { productDeleteMedia(mediaIds: $mediaIds, productId: $productId) { deletedMediaIds deletedProductImageIds mediaUserErrors { field message } product { id title media(first: 5) { nodes { alt mediaContentType status } } } } }\",\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\"\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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"mediaIds\": [\"gid://shopify/Video/-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 = <<[\"gid://shopify/Video/-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 productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"mediaIds\": [\n \"gid://shopify/Video/-1\"\n ],\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {\n productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {\n deletedMediaIds\n deletedProductImageIds\n mediaUserErrors {\n field\n message\n }\n product {\n id\n title\n media(first: 5) {\n nodes {\n alt\n mediaContentType\n status\n }\n }\n }\n }\n}"
input: { "mediaIds": [ "gid://shopify/Video/-1" ], "productId": "gid://shopify/Product/108828309" }
response: { "data": { "productDeleteMedia": { "deletedMediaIds": null, "deletedProductImageIds": null, "mediaUserErrors": [ { "field": [ "mediaIds" ], "message": "Media id gid://shopify/Video/-1 does not exist" } ], "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "media": { "nodes": [ { "alt": "This is a video", "mediaContentType": "EXTERNAL_VIDEO", "status": "READY" }, { "alt": "This is a video", "mediaContentType": "VIDEO", "status": "READY" }, { "alt": "This is a 3d Model", "mediaContentType": "MODEL_3D", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" }, { "alt": "", "mediaContentType": "IMAGE", "status": "READY" } ] } } } } }