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.

These three endpoints operate on a single court identified by its unique id. Retrieval is public and requires no session. Updating a court requires an ADMIN or SUPERADMIN role, while deletion is restricted exclusively to SUPERADMIN accounts. The token HTTP-only cookie is read automatically on same-origin requests for the authenticated operations.

GET /api/canchas/[id]

Returns a single court by its unique identifier. This endpoint is public — no authentication is required.

Path parameter

ParameterTypeDescription
idstringThe CUID of the court to retrieve, e.g. "clx0z1abc0000defg1234hijk".

Response — 200 OK

{
  "cancha": {
    "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"
  }
}
cancha
Cancha
required
The matching court object.

Error response

StatusBodyCause
404{ "error": "No encontrada" }No court with the given id was found in the database.

Example

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

PUT /api/canchas/[id]

Updates one or more fields on an existing court. The authenticated user must have the ADMIN or SUPERADMIN role. Only the fields present in the request body are changed; however, because precioPorHora and capacidad are coerced via parseFloat/parseInt, omitting them from the body will store NaN — include only the fields you intend to update or provide all fields.
Send only the fields you want to change. The server passes all body fields directly to Prisma’s update, so omitting a field means its existing value is preserved only for string/boolean fields. Always include precioPorHora and capacidad when updating numeric fields to avoid coercion issues.

Path parameter

ParameterTypeDescription
idstringThe CUID of the court to update.

Request body (all fields optional)

nombre
string
New display name for the court.
tipo
'FUTBOL' | 'TENIS' | 'BASQUET' | 'VOLLEYBALL'
New sport category. Must be one of the four TipoCancha enum values.
descripcion
string
Updated description. Pass an empty string or null to clear it.
precioPorHora
number
Updated hourly rental price. Accepts a number or numeric string.
capacidad
number
Updated player capacity. Accepts a number or numeric string.
activa
boolean
Set to false to deactivate the court and prevent new reservations, or true to reactivate it. This is the preferred alternative to permanent deletion.

Response — 200 OK

{
  "ok": true,
  "cancha": {
    "id": "clx0z1abc0000defg1234hijk",
    "nombre": "Cancha Fútbol Norte — Remodelada",
    "tipo": "FUTBOL",
    "descripcion": "Ahora con vestuarios renovados.",
    "precioPorHora": 40000,
    "capacidad": 14,
    "activa": true,
    "imagen": null,
    "creadoEn": "2024-03-15T10:00:00.000Z"
  }
}
ok
true
required
Always true on a successful update.
cancha
Cancha
required
The full updated court object reflecting all persisted changes.

Error response

StatusBodyCause
403{ "error": "Sin permisos" }No active session, or the user’s role is not ADMIN/SUPERADMIN.

Example

curl -X PUT https://your-domain.com/api/canchas/clx0z1abc0000defg1234hijk \
  -H "Content-Type: application/json" \
  --cookie "token=<your_jwt_token>" \
  -d '{
    "nombre": "Cancha Fútbol Norte — Remodelada",
    "descripcion": "Ahora con vestuarios renovados.",
    "precioPorHora": 40000,
    "capacidad": 14
  }'

DELETE /api/canchas/[id]

Permanently deletes a court record from the database. This action is restricted to SUPERADMIN accounts only and cannot be undone.
Deletion is permanent. Once a court is deleted, all associated data (including reservation history referencing it) may be affected by database cascade rules. If you simply want to stop accepting new bookings, prefer setting activa: false via PUT /api/canchas/[id] instead — this preserves all historical data while hiding the court from the booking flow.

Path parameter

ParameterTypeDescription
idstringThe CUID of the court to delete.

Response — 200 OK

{
  "ok": true
}
ok
true
required
Always true when the court was successfully deleted.

Error response

StatusBodyCause
403{ "error": "Sin permisos" }No active session, or the authenticated user’s role is not SUPERADMIN. ADMIN accounts cannot delete courts.

Example

curl -X DELETE https://your-domain.com/api/canchas/clx0z1abc0000defg1234hijk \
  --cookie "token=<your_jwt_token>"

Build docs developers (and LLMs) love