I am trying to use an existing image from one SKU and add it to another SKU. For example:

SKU0 -> Image uploaded via Admin
SKU1 -> Copy image details from SKU0 to SKU1 via API

I've tried using a PUT request to endpoint https://www.domain.com/rest/V1/products/SKU1 with input:

"product"=> [
    "sku" => "SKU1,
    "media_gallery_entries" => [
            "id" => "id of image from SKU0",
            "media_type" => "image",
            "label" => "label",
            "position" => 1,
            "disabled" => false,
            "types" => ["image"],
            "file" => "filename_sku0.jpg"

The above is also described in another example How to add product image when creating via rest api?

But I keep getting error The image content is invalid. Verify the content and try again." So I've tried adding:

"content" => [
                "base64_encoded_data" => 'encoded string here',
                "type" => "image/jpeg",
                "name" => "name of SKU0.jpg"

But all this does is duplicates the same image which is what I'm trying to avoid. Does anyone know a way of using the same image for multiple SKUS via API?


  • I see it's been quite a while since this was posted. I'm running into the same situation. I've tried multiple permutations of the API calls and the contents of the put/post, but have run into the same roadblock. Have you had any luck with this? - I've even tried adding the entry to the media_gallery_entries property on the sku and running the sku update PUT. It returns a 'successful update' but does not contain the added image – Nieminen Apr 20 at 16:13
  • I am using Magento 2.3.4 and I am facing the exact same problem. I think I tried all API routes too... @OP, did you ever find the answer? – max Apr 26 at 22:13
  • I'm not sure if a behaviour like this should be allowed, if you use the same image for multiple products and at some point you delete one of the products, probably the image would be deleted, affecting the other products using it. Anyways, if i had to do this I'd use a custom module to extend an api endpoint – SantiBM May 1 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.