Skip to content

Add a picture to a product

POST
/products/{id}/images
curl --request POST \
--url https://example.com/products/019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f/images \
--header 'Content-Type: application/json' \
--cookie bottle.session_token=<bottle.session_token> \
--data '{ "dataUrl": "example", "alt": "example" }'

Added last. A JPEG, PNG, WebP, AVIF or GIF (its first frame) as a data URL, up to 15 MB and 40 megapixels, and within the request size limit of 8 MB. It is turned the right way up, everything in the file that is not the picture (camera details, where it was taken) is taken out, and sizes of 200, 600 and 1600 pixels are made, never bigger than the picture. At most 12 a product.

id
required

UUID v7

string format: uuid
Example
019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f

UUID v7

Media typeapplication/json
object
dataUrl
required

The picture as a data URL: JPEG, PNG, WebP, AVIF or the first frame of a GIF, up to 15 MB and 40 megapixels. Turned upright, stripped of everything but the pixels, and kept with sizes made for the shop.

string
<= 21000000 characters /^data:image\/(png|jpeg|webp|avif|gif);base64,/
alt
string | null
<= 300 characters
Examplegenerated
{
"dataUrl": "example",
"alt": "example"
}

The picture

Media typeapplication/json
object
id
required

UUID v7

string format: uuid
alt
required

What the picture shows, for screen readers and search.

string | null
sortOrder
required
integer
width
required

Of the original, in pixels.

integer
height
required
integer
thumb
required

Fits inside 200 pixels. WebP.

string
card
required

Fits inside 600 pixels. WebP.

string
large
required

Fits inside 1600 pixels. WebP.

string
Example
{
"id": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f"
}

Not signed in

Media typeapplication/json
object
error
required
string
message
required
string
Example
{
"error": "not_found",
"message": "Customer not found"
}

Not a member, or without the permission this needs

Media typeapplication/json
object
error
required
string
message
required
string
Example
{
"error": "not_found",
"message": "Customer not found"
}

No such product or picture

Media typeapplication/json
object
error
required
string
message
required
string
Example
{
"error": "not_found",
"message": "Customer not found"
}

The product already has 12 pictures

Media typeapplication/json
object
error
required
string
message
required
string
Example
{
"error": "not_found",
"message": "Customer not found"
}

Validation failed, or the file is not a picture Bottle takes

Media typeapplication/json
object
error
required
string
Allowed values: validation
message
required
string
issues
required
Array<object>
object
path
required
string
message
required
string
Example
{
"error": "validation",
"issues": [
{
"path": "email",
"message": "Invalid email"
}
]
}