Replace product media
Replaces the media of the Product and of its Variants at once.
This is the only route that writes Product and Variant media. Create and update do not accept media: sending the key gives 400.
It is a PUT: the Product's list and the list of each Variant you send replace the stored ones. A Variant not in the body stays as it is.
productis the whole Product list.[]removes its media.variantsis required and carries only the Variants to write. A Variant that is not listed keeps its media. To clear a Variant's media, send it withmedia: [].- Each Variant appears once per call.
- Archived Variants (and those of an archived Product) are accepted like any other.
positioncannot repeat within the samerole.- Up to 100 items per list and 100 Variants per call. A Product with more Variants is updated in several calls, each with the complete
product.
Accepted types per role:
role | Accepts |
|---|---|
image | JPEG, PNG or WebP |
video | MP4 |
size_chart | image or PDF |
document |
video accepts MP4 video only: HEIC photos, M4A audio, and MOV do not pass as MP4 (the upload ends failed with unsupported_content).
All or nothing: if one item is refused, nothing is written. Nothing is published. But content that was published and is clean and uses this media becomes dirty when the new media differs from the published one (marketplace_product.updated, behavior: "product_changed", changes.paths product.media or variant.media). To carry the change to listings, use Propagate changes.
curl -X PUT "$API/v1/products/$PRODUCT_ID/media" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"product": [{ "assetId": "'$ASSET_ID'", "role": "image", "position": 0 }],
"variants": [
{
"variantId": "'$VARIANT_ID'",
"media": [{ "assetId": "'$ASSET_ID'", "role": "image", "position": 0 }]
}
]
}'The other Variants of the Product stay as they are.
The response is the complete media after the swap, same as Get media. If the Product media changed, product.updated is emitted; for each Variant that changed, variant.updated.
Common errors
Asset errors carry details: { reason, assetId }:
400asset_not_found: the asset does not exist in this account.400asset_seller_mismatch: the asset belongs to another seller. Copy it first with Copy media (POST /v1/sellers/{sellerId}/media-copies) and use the new id.400asset_not_product_media: the asset is confidential. Only media assets can be cited.409asset_not_ready: the asset is notreadyyet. If the upload is pending, finish it or wait and retry. If it endedfailed, it never becomesready: upload a new file.400asset_type_mismatch: the file type is not valid for therole(see the table).400variant_not_in_product: avariantIdis not a Variant of this Product.
api_keyAuthorizationBearer <token>API key (mk_...)
productId*string^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidapplication/json- body
The complete media of a product, and the complete media of each listed variant. It replaces what is stored for them; variants left out are not touched.
product*array<>Complete media list of the product; an empty list removes its media.
items <= 100variants*array<>Media of the variants to write, at most 100 per request, archived ones included. A variant left out keeps its media; send media: [] to remove it. To write more than 100 variants, send several requests.
items <= 100The complete media after replacement.
application/json- response
The media of a product and of each of its variants.
productId*stringProduct the media belongs to.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$uuidproduct*array<>Ordered product media.
variants*array<>Every variant of the product, in the order GET /v1/products/{productId}/variants lists them.
curl -X PUT "https://example.com/v1/products/497f6eca-6276-4993-bfeb-53cbbbba6f08/media" \ -H "Content-Type: application/json" \ -d '{ "product": [ { "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80", "role": "image", "position": 0 } ], "variants": [ { "variantId": "47c9f819-fcf6-4478-b21a-678ecc594a11", "media": [ { "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80", "role": "image", "position": 0 } ] } ] }'{ "productId": "a0f0ce59-5d17-49bf-8b45-d1dc057daab4", "product": [ { "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80", "role": "image", "position": 0 } ], "variants": [ { "variantId": "47c9f819-fcf6-4478-b21a-678ecc594a11", "media": [ { "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80", "role": "image", "position": 0 } ] } ]}