Skip to main content
curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-front-updated.jpg",
    "altText": "Modern grey sofa - updated front view",
    "displayOrder": 1
  }'
Updates an existing product image with the provided details.

Method and Path

PUT /api/v1/product-images/{id}

Path Parameters

id
integer
required
The unique identifier of the product image to update

Request Body

productId
integer
required
ID of the product this image belongs to
imageUrl
string
required
URL of the product image. Must be a valid and accessible URL.
altText
string
Alternative text description for accessibility
displayOrder
integer
Order in which the image should be displayed. Lower numbers appear first.

Response

ProductImageResponse
object
The updated product image object

Response Codes

200
OK
Product image successfully updated
400
Bad Request
Invalid request body or validation error
404
Not Found
Product image with the specified ID was not found

Request Example

{
  "productId": 101,
  "imageUrl": "https://example.com/images/sofa-front-updated.jpg",
  "altText": "Modern grey sofa - updated front view",
  "displayOrder": 1
}

Response Example

{
  "id": 1,
  "productId": 101,
  "imageUrl": "https://example.com/images/sofa-front-updated.jpg",
  "altText": "Modern grey sofa - updated front view",
  "displayOrder": 1
}

Error Response Examples

Validation Error

{
  "status": 400,
  "error": "Bad Request",
  "message": "Validation failed",
  "errors": [
    {
      "field": "imageUrl",
      "message": "Image URL is required"
    }
  ]
}

Not Found Error

{
  "status": 404,
  "error": "Not Found",
  "message": "Product image not found with id: 999"
}

Usage Examples

Update Image URL

curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-new-photo.jpg",
    "altText": "Modern grey sofa - front view",
    "displayOrder": 1
  }'

Update Alt Text

curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-front.jpg",
    "altText": "Luxurious modern grey sofa with chrome legs - front view",
    "displayOrder": 1
  }'

Update Display Order

curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-front.jpg",
    "altText": "Modern grey sofa - front view",
    "displayOrder": 3
  }'

Update Product Image with JavaScript

const imageData = {
  productId: 101,
  imageUrl: 'https://example.com/images/sofa-front-updated.jpg',
  altText: 'Modern grey sofa - updated front view',
  displayOrder: 1
};

fetch('https://api.example.com/api/v1/product-images/1', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(imageData)
})
  .then(response => response.json())
  .then(data => console.log('Updated:', data))
  .catch(error => console.error('Error:', error));

Update Product Image with Python

import requests

image_data = {
    'productId': 101,
    'imageUrl': 'https://example.com/images/sofa-front-updated.jpg',
    'altText': 'Modern grey sofa - updated front view',
    'displayOrder': 1
}

response = requests.put(
    'https://api.example.com/api/v1/product-images/1',
    json=image_data
)

if response.status_code == 200:
    updated_image = response.json()
    print(f"Updated image: {updated_image['imageUrl']}")
else:
    print(f"Error: {response.status_code}")

Common Use Cases

Reorder Product Images

Update the display order to change how images appear in the product gallery:
# Move an image to the first position
curl -X PUT "https://api.example.com/api/v1/product-images/3" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-detail.jpg",
    "altText": "Sofa detail view",
    "displayOrder": 1
  }'

Update Image After Re-upload

Change the URL after uploading a higher quality image:
curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-front-hq.jpg",
    "altText": "Modern grey sofa - front view",
    "displayOrder": 1
  }'

Improve Accessibility

Enhance alt text for better SEO and accessibility:
curl -X PUT "https://api.example.com/api/v1/product-images/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "imageUrl": "https://example.com/images/sofa-front.jpg",
    "altText": "Contemporary grey upholstered three-seater sofa with brushed metal legs and plush cushions",
    "displayOrder": 1
  }'

Build docs developers (and LLMs) love