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 Create Store endpoint registers a new physical store in the Ocha platform. The store name and email address must each be unique across all existing stores — the API returns 409 Conflict if either is already in use. A URL-friendly slug is automatically derived from the name and does not need to be supplied in the request body.
This endpoint requires administrator privileges. Include a valid admin JWT in the Authorization header as a Bearer token.

Endpoint

POST /api/v1/stores

Request Body

name
string
required
Store display name. Must be between 3 and 50 characters and unique across all stores.
email
string
required
Contact email address for the store. Must be a valid email format and unique across all stores. Stored in lowercase.
phone
string
Store phone number. Optional. Must be a valid mobile phone number in any international format (validated by validator.isMobilePhone).
address
object
required
Physical address of the store. All four sub-fields are required.
location
object
required
GeoJSON Point representing the store’s geographic position.
opening_hours
array
Weekly schedule. Must be an array of exactly 7 elements, one per day starting with Sunday (index 0) through Saturday (index 6). Each element is either:
  • [] — the store is closed that day
  • ["HH:MM", "HH:MM"] — opening time then closing time in 24-hour format
When omitted, the default schedule sets Sunday as closed and Monday–Saturday to 09:0017:00.

Response — 201 Created

message
string
Confirmation message ("Store created").
store
object
The newly created store record, including the auto-generated slug, is_active flag, and timestamps.

Error Codes

StatusDescription
400One or more required fields (name, email, address, location) are missing.
401No valid JWT was provided in the Authorization header.
403The authenticated user does not have admin privileges.
409A store with the same name or email already exists.
422A field value failed validation (e.g. invalid email format, bad coordinates, malformed opening_hours).
500Unexpected server error.

Example

curl -X POST https://api.ocha.ch/api/v1/stores \
  -H "Authorization: Bearer <ADMIN_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ocha Neuchâtel",
    "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]
    },
    "opening_hours": [
      [],
      ["08:00", "18:00"],
      ["08:00", "18:00"],
      ["08:00", "18:00"],
      ["08:00", "20:00"],
      ["08:00", "20:00"],
      ["09:00", "17:00"]
    ]
  }'
{
  "message": "Store created",
  "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": true,
    "opening_hours": [
      [],
      ["08:00", "18:00"],
      ["08:00", "18:00"],
      ["08:00", "18:00"],
      ["08:00", "20:00"],
      ["08:00", "20:00"],
      ["09:00", "17:00"]
    ],
    "created_at": "2024-01-15T10:00:00.000Z",
    "updated_at": "2024-01-15T10:00:00.000Z"
  }
}

Build docs developers (and LLMs) love