Developers are struggling to link existing media files to products via Shopify’s Admin API without creating duplicates. The core issue: when creating or updating products, the API appears to require uploading images each time rather than referencing already-uploaded media.
Current Problem:
Users have images already uploaded to Shopify with known gid://shopify/MediaImage/<id> identifiers
Existing mutations (productCreateMedia, productUpdateMedia) only accept originalSource URLs, not existing media IDs
This forces re-uploading the same image across 500-1000+ products, cluttering Shopify Files Center with duplicates
Attempted Solutions:
Using productUpdateMedia with existing media IDs - unsuccessful
Providing Shopify-hosted URLs - still creates new media instances
The Shopify UI reveals a referencesToAdd field in ProductFileUpdate mutation, but this isn’t available in the public Admin API
Proposed Workaround:
One suggestion involves using the resourceUrl from initial staged upload across multiple productCreateMedia calls, though effectiveness is unconfirmed.
Status: Unresolved. Multiple users report the same issue with no working solution identified. A feature request suggests allowing originalSource to accept Shopify GIDs directly.
Summarized with AI on November 5.
AI used: claude-sonnet-4-5-20250929.
Could someone please help me out - i can’t find it.
I’m creating products via the Admin API and would like to link/add the very same image to all of these products.
The image is uploaded already to Shopify and i do have a
gid://shopify/MediaImage/<id>
id. For me it looks like that all mutations around product and images do upload a new instance of the product. Even if i provide a url that is hosted on shopify.
How can i link/set an existing image to a product?
Hey @LetterT ! Thanks for the reply!
By reading the endpoints i don’t think there is something available at all add an existing image to a product. The productCreateMedia only has an Input with
originalSource
[String! ](https://shopify.dev/docs/api/admin-graphql/2024-04/scalars/String)required
The original source of the media object. This might be an external URL or a staged upload URL.
It will always create and upload a new media even if you provide a shopify URL.
The productUpdateMedia EP will only update existing media on a product but not allow linking an existing media to a new product.
Would you know if this is achievable via REST?
I’ll be dealing with a 500-1000 products and more and would love to avoid to upload the very same image over and over
Actually I don’t think all the mutations require an image to be uploaded. In fact I think they’re very granular - I just wish it wasn’t sooo complicated, but whatever …
but adding id to media { … }, the goal is to get the id of the media created, which we’ll call media_id (we’ll need this later), (which you have).
mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {
productCreateMedia(media: $media, productId: $productId) {
media {
mediaContentType
status
id
}
mediaUserErrors {
field
message
}
product {
id
}
}
}
Input variables:
{
"media": {
"mediaContentType": "IMAGE",
"originalSource":
Now for the **productUpdateMedia** mutation:
[https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productUpdateMedia?example=Update+a+product%27s+media+fields](https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productUpdateMedia?example=Update+a+product%27s+media+fields)
The input variables don't need any more urls or anything else to be uploaded. It *seems* that all you need is your productId and the **media_id**
Plan A:
I haven't use **productUpdateMedia** myself ... but perhaps you can then use **productUpdateMedia** with **media_id** on all those 500-1000 productIds of your choosing?
Plan B:
If Shopify doesn't like that, then how about this:
There's the **resourceUrl** from Step 1. Perhaps you can just **productCreateMedia** on all productIds. Again, there's no necessity to POST any more images because you say you're using the same image, and the **resourceUrl** is the same.
Curious to see what works ...
@stolle Have you find out a solution, im having the same issue. Using Graphql admin api, and getting duplicate images over and over in my Shopify Files Center evertime i try to link images.
1.fileCreate
2.productCreateMedia, providing the URL from the media uploaded to shopify Content files
Tried productUpdateMedia supplying mediaimageid from the images uploaded feom step 1. still no success.