productVariantDetachMedia mutation
Deletes media from product variants.
Required access
write_products access scope.
On this page
Interactive example
This is an example mutation query. Use the embedded interactive tool below to edit the query.
Hint: use Ctrl + Space for autocompleting fields.
mutation productVariantDetachMedia($productId: ID!, $variantMedia: [ProductVariantDetachMediaInput!]!) { productVariantDetachMedia(productId: $productId, variantMedia: $variantMedia) {} } { “productId”: “Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=”, “variantMedia”: [
<font style="color:#1F61A0;">product</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">id</font><font style="color:#555555;">}</font><font style="color:#1F61A0;">productVariants</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">id</font><font style="color:#555555;">}</font><font style="color:#1F61A0;">userErrors</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">code</font><font style="color:#1F61A0;">field</font><font style="color:#1F61A0;">message</font><font style="color:#555555;">}</font>
] }
<font style="color:#555555;">{</font><font style="color:#8B2BB9;">"variantId"</font><font style="color:#555555;">:</font> <font style="color:#D64292;">"Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE="</font><font style="color:#555555;">,</font><font style="color:#8B2BB9;">"mediaIds"</font><font style="color:#555555;">:</font> <font style="color:#555555;">[</font><font style="color:#D64292;">"Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE="</font><font style="color:#555555;">]</font><font style="color:#555555;">}</font>
Arguments
ProductVariantDetachMediaInput fields
- mediaIds (
[[ID!]!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01)) REQUIRED
Specifies the media to detach from the variant. - variantId (
[ID!](https://shopify.dev/docs/admin-api/graphql/reference/scalar#id-2021-01)) REQUIRED
Specifies the variant from which media will be detached. 
Return fields
- product (
[Product](https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/product))
The product associated with the variants and media. - productVariants (
[[ProductVariant!]](https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/productvariant))
The product variants that were updated. - userErrors (
[[MediaUserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/products-and-collections/mediausererror))
List of errors that occurred executing the mutation. 
