The create product endpoint adds a new product to the catalogue. Only administrators may call this endpoint — a valid JWT with admin privileges must be supplied 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.
Authorization header. Upon success, the server broadcasts a new_product WebSocket event to all connected clients so UIs can update in real time. The slug field must be unique; if a product with the same slug or name already exists, the request is rejected with a 409 conflict.
Endpoint
Request headers
Bearer token for authentication, e.g.
Bearer <JWT>.Must be
application/json.Request body
URL-friendly unique identifier for the product. Must be unique across all products (e.g.
"matcha-latte").Display name of the product. Must be unique across all products.
Category the product belongs to (e.g.
"Hot drinks").Full description of the product.
Base price in Swiss francs (CHF). Must be
0 or greater. The price a customer pays for a given size is basePriceCHF plus the relevant extra_chf surcharge.URL of the product image. Must be a valid URL string.
Whether the product should be visible and available. Defaults to
true if omitted.Available sizes for this product. Each element must be one of
"S", "M", or "L". Defaults to all three sizes if omitted.Price surcharges in CHF added to
basePriceCHF for each size.Response
201 CreatedA human-readable confirmation, e.g.
"Product created".The newly created product document, including all stored fields and MongoDB-generated
_id, createdAt, and updatedAt timestamps.After a successful creation, the server emits a
new_product WebSocket event containing the full product object to all connected clients.Error codes
| Status | Meaning |
|---|---|
400 | Missing required fields — slug, name, category, description, basePriceCHF, or image was not provided. |
401 | Unauthorized — no token or an invalid token was supplied. |
403 | Forbidden — the authenticated user does not have admin privileges. |
409 | Conflict — a product with the same slug or name already exists. |
422 | Unprocessable entity — the request body failed schema validation. |
500 | Internal server error — an unexpected error occurred. |