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 Store endpoint applies a partial update to an existing store. Only the fields you include in the request body are modified — all other fields remain unchanged. When the name field is updated, the store’s slug is automatically regenerated to match the new name. If the new name or email conflicts with another store, the request is rejected with 409 Conflict.
This endpoint requires administrator privileges. Include a valid admin JWT in the Authorization header as a Bearer token.

Endpoint

PATCH /api/v1/stores/:id

Path Parameters

id
string
required
The MongoDB ObjectId of the store to update (24-character hex string).

Request Body

All body fields are optional. Include only the fields you want to change.
name
string
New store display name. Must be 3–50 characters and unique. Updating this field also regenerates the slug.
email
string
New contact email. Must be a valid email format and unique. Stored in lowercase.
phone
string
New phone number. Must be a valid mobile phone number in any international format. Pass an empty string to clear the field.
address
object
Replaces the entire address object. All four sub-fields are required when address is provided.
location
object
Replaces the GeoJSON location. Both sub-fields are required when location is provided.
opening_hours
array
Replaces the full weekly schedule. Must be an array of exactly 7 elements (Sunday → Saturday). Each element must be [] or ["HH:MM", "HH:MM"].
is_active
boolean
Set to false to deactivate the store or true to reactivate it.

Response — 200 OK

message
string
Confirmation message ("Store updated").
store
object
The complete updated store record, reflecting all applied changes.

Error Codes

StatusDescription
400The supplied id is not a valid MongoDB ObjectId.
401No valid JWT was provided in the Authorization header.
403The authenticated user does not have admin privileges.
404No store exists with the given id.
409The updated name or email conflicts with an existing store.
422A field value failed validation (e.g. bad coordinates, malformed opening_hours).
500Unexpected server error.

Example

curl -X PATCH https://api.ocha.ch/api/v1/stores/64f1c2e9a1b2c3d4e5f12345 \
  -H "Authorization: Bearer <ADMIN_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "is_active": false,
    "opening_hours": [
      [],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      []
    ]
  }'
{
  "message": "Store updated",
  "store": {
    "_id": "64f1c2e9a1b2c3d4e5f12345",
    "name": "Ocha Neuchâtel",
    "slug": "ocha-neuchatel",
    "email": "[email protected]",
    "phone": "+41321234567",
    "address": {
      "line1": "Avenue de la Gare 1",
      "city": "Neuchâtel",
      "zipcode": "2000",
      "country": "Suisse"
    },
    "location": {
      "type": "Point",
      "coordinates": [6.93, 46.99]
    },
    "is_active": false,
    "opening_hours": [
      [],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      ["09:00", "17:00"],
      []
    ],
    "created_at": "2024-01-15T10:00:00.000Z",
    "updated_at": "2024-03-20T14:30:00.000Z"
  }
}

Build docs developers (and LLMs) love