API contract
The backend exposes a single REST API, versioned in the path (/api/v2), consumed by the frontend. This page describes the rules shared by all endpoints and the API's organization by domain. It deliberately lists neither the exact paths nor the parameters: they change quickly, and the only up-to-date source of truth is the OpenAPI document generated by the backend.
Where to find endpoint details
When documentation is enabled (REGISTRY_DOCUMENTATION_ENABLED=true, in development), the backend serves the OpenAPI 3 document and Swagger UI on its management port (see Getting started). Swagger UI lets you authenticate (authorization code + PKCE) and try each endpoint. Each operation states its required permission there.
Principles
Resources nested under their owner
- Global resources (users, preferences, metadata, purges) sit directly under
/api/v2. - Everything that belongs to a project is under
/api/v2/projects/{projectId}/…. The project identifier in the path is what makes it possible to check the permission on that project (Security → Authorization). - Names are plural, lowercase and kebab-case; JSON bodies are camelCase.
Consistent verbs
| Verb | Usage |
|---|---|
GET | Read (a record, a list page, a capped search, statistics) |
POST | Create, and trigger a state transition (hide/show, block/unblock, accept an invitation, add to favorites…) |
PATCH | Change some fields |
DELETE | Permanently delete |
Each state transition is a separate endpoint, with its own access rule: (soft) delete, restore and permanently delete map to three distinct permissions (ADR 017).
Predictable responses
- A creation answers
201with the address of the created resource; a deletion answers204. - Responses contain dedicated DTOs (never the database entities); an item does not embed its whole project.
- Errors follow the standard problem details format (RFC 9457) with a stable code (for example "movement date in the future") and a message translated according to the
Accept-Languageheader (French or English). The frontend shows that message, enriched with its own text (ADR 015).
A single list grammar
All lists share the same parameters, which lets the frontend implement progressive loading, search, filters and sorting only once:
- pagination by page and page size (capped size); the response states whether there is a next page;
- text search tolerant of typos and accents (PostgreSQL trigrams, ADR 006);
- sorting on a closed list of fields,
-prefix for descending order; - visibility (visible items, deleted items, or both), taken into account only for those holding the restore permission;
- typed filters specific to each list (status, "active at this instant" date, date range, favorite…). An inverted range is refused.
Selection searches (autocomplete fields: participants to add, vehicles, reasons…) are not paginated: they return a small, capped number of results.
Bounded inputs
Every string, list and parameter has a maximum size; an oversized request body is refused (413). Sign-in redirect URLs are restricted to an allowlist. See Security → Data integrity.
Optimistic concurrency
Reads and writes of an item return an ETag derived from its last change. Sending it back in If-Match on an edit makes the write fail (412) if someone else changed it in the meantime; a lock conflict answers 409, an update that takes too long 408 (ADR 016).
Status codes to know
| Code | Meaning in Registry |
|---|---|
400 | Invalid request (validation, parameter too long, inverted range…) |
401 | Not authenticated or invalid token — the frontend tries a refresh then sends to sign-in |
403 | Insufficient permission, project option disabled or failed CSRF check |
404 | Item not found (or invisible to the caller) |
408 / 409 / 412 | Concurrency: timeout, lock unavailable or business conflict, item changed since it was read |
413 | Request body too large |
422 | Business rule violated (incompatible reason, definitive departure before other movements…) |
423 | Account blocked |
424 | The identity provider is not responding correctly |
429 | Rate limit exceeded |
The API by domain
| Domain | What it covers | Access |
|---|---|---|
| Authentication | Sign-in and sign-out URLs, token exchange and refresh, current user with their authorities and preferences | Public for the token exchange; the rest authenticated |
| Metadata | Translated labels of the enumerations (statuses, types, project options…) and features enabled by configuration | Public, no sensitive data |
| Users | Directory, application role, blocking, deletion, GDPR export; deletion and export of one's own account | Platform administrator; oneself |
| Preferences | Theme, language, refresh frequency | Oneself |
| My profiles | My memberships and invitations, accept/decline, join as support | Oneself; support: platform administrator |
| Projects | List with summary (profile, counters, alerts), CRUD, soft delete/restore, favorites | Depending on the profile; global read for the platform administrator |
| Members (project profiles) | Bulk invitation, change of role and access window, blocking, removal, user search by exact email | Project administrator; read: coordinator |
| Participants | CRUD, birthdays, movement history and presence timeline, GDPR export, selection searches | Project roles (history: administrator and coordinator) |
| Groups | CRUD, members (list, add, remove) | Project roles |
| Movements | Check-ins/check-outs of registered participants and guests, contents, live headcounts, planned arrivals and departures, selection searches | Project roles |
| Vehicles (option) | CRUD, history, timeline and usage rate | Administrator and coordinator |
| Activities (option) | CRUD, history and statistics | Administrator and coordinator |
| Communications (option) | Messages, threads of a movement or an alert | Project roles |
| Alerts (option) | List, creation, status change, soft delete/restore, permanent deletion, thread, statistics | Project roles |
| Purges | The five retention sweeps, as a dry run by default | Scheduled job permission |
The full "who can do what" matrix is in Roles and permissions.
Evolving the API
- A new endpoint is declared on a contract interface (path, access rule, validation, OpenAPI documentation) implemented by a controller that only delegates; an architecture test rejects any controller outside this pattern (Backend).
- Any extension of the list of public endpoints must be justified and approved.
- A contract break is handled in a new path version; since the frontend is the only client,
v2could replacev1in one go (ADR 015).