These three endpoints operate on a single court identified by its uniqueDocumentation 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.
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
| Parameter | Type | Description |
|---|---|---|
id | string | The CUID of the court to retrieve, e.g. "clx0z1abc0000defg1234hijk". |
Response — 200 OK
The matching court object.
Error response
| Status | Body | Cause |
|---|---|---|
404 | { "error": "No encontrada" } | No court with the given id was found in the database. |
Example
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, becauseprecioPorHora 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
| Parameter | Type | Description |
|---|---|---|
id | string | The CUID of the court to update. |
Request body (all fields optional)
New display name for the court.
New sport category. Must be one of the four
TipoCancha enum values.Updated description. Pass an empty string or
null to clear it.Updated hourly rental price. Accepts a number or numeric string.
Updated player capacity. Accepts a number or numeric string.
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
Always
true on a successful update.The full updated court object reflecting all persisted changes.
Error response
| Status | Body | Cause |
|---|---|---|
403 | { "error": "Sin permisos" } | No active session, or the user’s role is not ADMIN/SUPERADMIN. |
Example
DELETE /api/canchas/[id]
Permanently deletes a court record from the database. This action is restricted to SUPERADMIN accounts only and cannot be undone.Path parameter
| Parameter | Type | Description |
|---|---|---|
id | string | The CUID of the court to delete. |
Response — 200 OK
Always
true when the court was successfully deleted.Error response
| Status | Body | Cause |
|---|---|---|
403 | { "error": "Sin permisos" } | No active session, or the authenticated user’s role is not SUPERADMIN. ADMIN accounts cannot delete courts. |