The upload image endpoint replaces a product’s image. You provide the image as a base64 data URI or a publicly accessible URL in the JSON request body. The value is passed to Cloudinary, which stores it in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/floriansalvi/HEIG-VD_Ocha-api/llms.txt
Use this file to discover all available pages before exploring further.
products/ folder using the product’s slug as the public ID — so re-uploading always overwrites the previous image. Cloudinary automatically resizes the image to 500×500 pixels, crops to fill, and selects the optimal format and quality. The resulting Cloudinary URL is then persisted to product.image. Only administrators may call this endpoint.
Endpoint
Request headers
Bearer token for authentication, e.g.
Bearer <JWT>.Must be
application/json.Path parameters
The MongoDB ObjectId of the product whose image should be updated (e.g.
64f1c2e9a1b2c3d4e5f12345).Request body
The image source to upload. Accepted values:
- A publicly accessible image URL (e.g.
"https://example.com/image.jpg") - A base64-encoded data URI (e.g.
"data:image/jpeg;base64,/9j/4AAQSk...")
Cloudinary processing
Once received, the image is uploaded to Cloudinary with the following transformations applied automatically:- Crop:
fillat 500×500 px with auto gravity - Format: auto-selected for best browser compatibility
- Quality: auto-optimised by Cloudinary
secure_url returned by Cloudinary is saved to product.image.
Response
200 OKA human-readable confirmation, e.g.
"Image uploaded successfully".The Cloudinary
secure_url of the uploaded image now stored on the product.Error codes
| Status | Meaning |
|---|---|
400 | Invalid ID format, or the image field was missing from the request body. |
401 | Unauthorized — no token or an invalid token was supplied. |
403 | Forbidden — the authenticated user does not have admin privileges. |
404 | Product not found — no product exists with the given id. |
500 | Internal server error — an unexpected error occurred, including Cloudinary upload failures. |