TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Nyverie/reservafacil/llms.txt
Use this file to discover all available pages before exploring further.
/api/reservas endpoint lets authenticated users view and create court reservations. Role-based access controls determine the scope of what each caller can see: regular users retrieve only their own bookings, while admins and superadmins receive the full reservation list. New bookings are validated against both court availability and existing time-slot conflicts before being persisted.
GET /api/reservas
Returns a list of reservations ordered by date descending. The response shape varies by role:USUARIO receives only their own reservations with court details, while ADMIN and SUPERADMIN receive all reservations including the associated user on each record.
Requires authentication. Returns 401 if no valid session is present.
Role-based filtering
Regular users (
USUARIO role) only ever see their own reservations — filtered internally by usuarioId. There is no query parameter to override this; the server enforces it based on the session. Admins and superadmins always receive all reservations.Response 200
Array of reservation objects. Always includes the nested
cancha object. The usuario field is only populated for ADMIN and SUPERADMIN callers.CUID identifier for the reservation.
ID of the user who created the reservation.
ID of the court being reserved.
The date of the reservation, stored as a UTC midnight timestamp.
Start time of the booking slot in
HH:MM 24-hour format (e.g. "09:00").End time of the booking slot in
HH:MM 24-hour format (e.g. "10:00").Current status of the reservation. One of:
PENDIENTE, CONFIRMADA, CANCELADA, COMPLETADA.Total cost of the reservation as a floating-point number (e.g.
50.00). Defaults to 0 if not provided at creation.Optional free-text notes attached to the reservation.
Timestamp of when the reservation record was created.
Nested Cancha (court) object. Always present.
Nested Usuario object. Only present when the caller has
ADMIN or SUPERADMIN role.Error responses
| Status | Body | Description |
|---|---|---|
401 | { "error": "No autenticado" } | No valid session cookie / token. |
POST /api/reservas
Creates a new reservation for the authenticated user. The server automatically validates that the court exists and is active, and that the requested time window does not overlap with any existingPENDIENTE or CONFIRMADA booking for that court on the same date.
Requires authentication. The usuarioId is taken directly from the session — it cannot be set in the request body.
Request body
The CUID of the court to reserve. Must match an existing, active (
activa: true) Cancha record.The date for the reservation as an ISO 8601 string (e.g.
"2024-01-15T00:00:00.000Z"). Stored as a UTC DateTime.Start time of the slot in
HH:MM 24-hour format (e.g. "09:00").End time of the slot in
HH:MM 24-hour format (e.g. "10:00"). Must be later than horaInicio.Optional free-text notes for the reservation (e.g. special requests).
Total price for the booking. If omitted, the reservation is created with
total: 0.Conflict detection logic
Before creating the reservation, the API queries for any existing reservation on the same court (canchaId) and date (fecha) whose status is PENDIENTE or CONFIRMADA and whose time window overlaps the requested slot. Two time windows overlap when:
409.
All new reservations are created with estado: "PENDIENTE" regardless of the caller’s role.
Response 201
Always
true on success.The newly created reservation object. Includes the nested
cancha object. The usuario field is not included in the POST response.Error responses
| Status | Body | Description |
|---|---|---|
400 | { "error": "Faltan campos requeridos" } | One or more of canchaId, fecha, horaInicio, or horaFin is missing. |
400 | { "error": "Cancha no disponible" } | The court does not exist or has activa: false. |
401 | { "error": "No autenticado" } | Request has no valid session. |
409 | { "error": "Ya existe una reserva en ese horario" } | The time slot overlaps an active (PENDIENTE or CONFIRMADA) booking on the same court and date. |
500 | { "error": "Error interno" } | Unexpected server-side error. |