Update Image src without ID changing

New Member
2 0 2



I seem to be having problems with image updates on a product in the API. If I update a products image for an image that already exists for example (it can be the same image with a new file name or a new image entirely), it uploads it no problem in place of the existing one, however the ID number changes:


  "product": {
    "id": 0000000001,
    "images": [
        "id": 0000000002,
        "src": "newimage.jpg"


Can anyone please let me know why ID numbers are changing. The problem is if software using the API is relying on the image ID as a reference and it changes at times it shouldn't then that software will break.


It would make sense for the ID number to not change. The ID number should be for the image objects existence and not be affected by the properties of it changing. A perfect example is in the case where I update with an image that is exactly the same just with a different filename there is no reason for the ID number to change.


If there is a way to avoid ID numbers of the images changing and still updating their source I would love to know. 






Shopify Partner
1836 210 425

One should never rely on IDs for any of the Shopify objects, these are internal IDs used by Shopify to uniquely identify an entity, even across stores. This is why when you say you are updating an image, actually you are creating a new image object.


Though I would love to have one another field that can be populated at the time the image is created and then used to get the image, what you are left with is, either you encode your specific image id in the image name, or use for example the alt field at the image object level for that purposes.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
49 2 8

This is a real shame, product- images need to support metafields really, then I could use that


At the moment everytime I update a product I push new images that then get new IDs. It makes it difficult to not only update the images, but also to be able to relate a variant to an uploaded image.  The only way I can think of doing this is through the altText, but that really doesn't feel right


Actually, looks like you can't update an image with the id in product update, I got this when I gave the ID and the src of teh image

"message""Either specify id to reference an existing image, or src to add new image to product. Do not specify both.",


Probably need to use this: productImageUpdate  and remove the images:[] part


You would then update the images that needed updating


I am not sure how yo would add new images though





Not applicable
1705 0 0


Could you find any way to update images via productImageUpdate?

I am using productImageUpdate and passing data as:


  "productId": "gid://shopify/Product/6166892019882",
  "image": {
      "id": "gid://shopify/ProductImage/23272594112682",
      "src": "https://cdn.shopify.com/s/files/1/0508/3516/1258/products/180622-05-2.jpg?v=1611524873"


This is what I get:


  productImageUpdate: {
    image: {
      altText: null,
      id: 'gid://shopify/ProductImage/23272594112682',
      src: 'https://cdn.shopify.com/s/files/1/0508/3516/1258/products/180622-05-2.jpg?v=1611524925'
    userErrors: []


The image id but the last part after .jpg? are different e.g. ?v1611524873  and ?v1611524925

After I call productImageUpdate it does not update my image, why? Sometimes it works