Skip to main content

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

The Courts API lets you retrieve every registered court on the platform and, if you hold an administrative role, create new ones. Courts are the central resource in ReservaFácil — each court (Cancha) has a type, pricing, capacity, and an active flag that controls availability for booking.

GET /api/canchas

Returns all courts stored in the database, sorted alphabetically by name. This endpoint is public — no authentication or session cookie is required.
The response always includes every court regardless of its activa status. Client-side code should filter on activa: true when displaying bookable courts to end users.

Response — 200 OK

{
  "canchas": [
    {
      "id": "clx0z1abc0000defg1234hijk",
      "nombre": "Cancha Fútbol Norte",
      "tipo": "FUTBOL",
      "descripcion": "Cancha de fútbol 7 con césped sintético.",
      "precioPorHora": 35000,
      "capacidad": 14,
      "activa": true,
      "imagen": "https://cdn.example.com/canchas/futbol-norte.jpg",
      "creadoEn": "2024-03-15T10:00:00.000Z"
    }
  ]
}

Response fields

canchas
Cancha[]
required
Array of all court objects ordered by nombre ascending.

Examples

curl -X GET https://your-domain.com/api/canchas

POST /api/canchas

Creates a new court record. The authenticated user must have the ADMIN or SUPERADMIN role. The session is read from the HTTP-only token cookie, which is sent automatically on same-origin requests.
The token cookie is set at login and is HTTP-only, meaning it cannot be read from JavaScript. It is forwarded automatically by the browser on every same-origin fetch or XMLHttpRequest.

Request body

nombre
string
required
Display name for the court. Must be a non-empty string, e.g. "Cancha Tenis Sur".
tipo
'FUTBOL' | 'TENIS' | 'BASQUET' | 'VOLLEYBALL'
required
Sport category for this court. Must be exactly one of the four TipoCancha enum values:
ValueSport
FUTBOLFootball
TENISTennis
BASQUETBasketball
VOLLEYBALLVolleyball
descripcion
string
Optional description of the court’s facilities or specific rules. Stored as null if omitted.
precioPorHora
number
required
Hourly rental price. Accepts a number or numeric string — the API calls parseFloat() internally. Example: 35000 or "35000.50".
capacidad
number
required
Maximum player capacity. Accepts a number or numeric string — the API calls parseInt() internally. Example: 14 or "14".

Response — 201 Created

{
  "ok": true,
  "cancha": {
    "id": "clx1a2bcd0001efgh5678ijkl",
    "nombre": "Cancha Tenis Sur",
    "tipo": "TENIS",
    "descripcion": null,
    "precioPorHora": 28000,
    "capacidad": 4,
    "activa": true,
    "imagen": null,
    "creadoEn": "2024-06-01T14:30:00.000Z"
  }
}
ok
true
required
Always true on a successful creation response.
cancha
Cancha
required
The newly created court object. See the Cancha fields listed under GET /api/canchas above for the full field descriptions.

Error responses

StatusBodyCause
400{ "error": "Faltan campos requeridos" }One or more of nombre, tipo, precioPorHora, or capacidad is missing from the request body.
403{ "error": "Sin permisos" }No active session, or the authenticated user’s role is neither ADMIN nor SUPERADMIN.
500{ "error": "Error interno" }Unexpected server-side error (e.g. database failure).

Examples

curl -X POST https://your-domain.com/api/canchas \
  -H "Content-Type: application/json" \
  --cookie "token=<your_jwt_token>" \
  -d '{
    "nombre": "Cancha Tenis Sur",
    "tipo": "TENIS",
    "descripcion": "Cancha de tenis con iluminación nocturna.",
    "precioPorHora": 28000,
    "capacidad": 4
  }'

Build docs developers (and LLMs) love