Skip to main content

Documentation 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.

The Update Order Status endpoint allows administrators to advance an order through its defined lifecycle. The order model enforces a fixed set of valid statuses and uses the setStatus method to validate and persist the transition. Only the status field is writable through this endpoint.
This endpoint requires admin privileges. Requests authenticated with a regular user JWT will receive a 403 Forbidden response.

HTTP method and path

PATCH /api/v1/orders/:id

Order status lifecycle

Orders progress through three statuses in sequence:
  1. en préparation — the default status assigned when an order is created; the store is preparing the order.
  2. prête — the order is ready for the customer to collect.
  3. récupérée — the customer has picked up the order.
The API does not enforce a strict forward-only transition; any of the three valid values can be set at any time. Submitting a value outside this set results in a 400 error.

Request parameters

Headers

Authorization
string
required
Bearer token for an admin user. Format: Bearer <token>.

Path

id
string
required
MongoDB ObjectId of the order to update.

Body

status
string
required
New status for the order. Must be one of: "en préparation", "prête", "récupérée".

Response fields

200 OK

message
string
Human-readable confirmation. Value: "Order status updated".
order
object
The updated order document.

Error codes

StatusMeaning
400status field is missing, the value is not one of the three allowed strings, or the id is not a valid ObjectId.
401Missing or invalid JWT token.
403Authenticated user does not have admin privileges.
404No order exists with the given id.
409Data conflict preventing the update.
422Mongoose validation error.
500Unexpected server error.

Example

curl --request PATCH \
  --url https://api.example.com/api/v1/orders/64f1c2e9a1b2c3d4e5f99999 \
  --header 'Authorization: Bearer <admin_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "status": "prête"
  }'
{
  "message": "Order status updated",
  "order": {
    "_id": "64f1c2e9a1b2c3d4e5f99999",
    "user_id": "64f1c2e9a1b2c3d4e5f00001",
    "store_id": "64f1c2e9a1b2c3d4e5f12345",
    "status": "prête",
    "pickup": "2026-01-10T12:30:00.000Z",
    "total_price_chf": 11.80,
    "createdAt": "2026-01-09T08:00:00.000Z",
    "updatedAt": "2026-01-09T09:15:00.000Z"
  }
}

Build docs developers (and LLMs) love