Skip to content

Product Images — Update

Edits what is stored alongside an uploaded image: its alt text and its position.

The file itself is fixed once uploaded — to replace the picture, upload a new one and delete this one.

Endpoint

EndpointMethod
/api/admin/catalog/products/{productId}/images/{id}PUT

Request body

FieldTypeRequiredNotes
alt_textstringnoDescription of the image, stored for every locale the request covers. Send an empty string to clear it.
positionintegernoSort position within the product's gallery.

At least one of the two is required — a request carrying neither is rejected.

Alt text and locales

Alt text is translated: it is written for every locale the request covers, and read back for the locale the request is made in. The storefront returns it as altText on the product's images, and falls back to the product name where an image has none, so an image is never rendered without a description.

Images are returned in position order, so this is what decides which picture is the product's main image — the lowest position wins, and that is the one the listing and the product card show. To rearrange several at once, use reorder instead.

Response

200 OK

FieldTypeNotes
idintegerImage id.
productIdintegerParent product id.
pathstringStorage-relative file path.
positionintegerSort position.
urlstringPublic URL.
altTextstringAlt text stored for the current locale, or null.

Errors

HTTPCause
401 UnauthorizedMissing or invalid admin Bearer token.
403 ForbiddenAdmin role lacks catalog.products.edit.
404 Not FoundProduct not found, or the image does not belong to it.
422 Unprocessable EntityNeither an alt text nor a position was sent.

Released under the MIT License.