Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta/llms.txt

Use this file to discover all available pages before exploring further.

The seasons, groups, and fields endpoints expose the structural layer of the competition. Public callers can list seasons and groups; admin-only endpoints handle creating, editing, and deleting all three resource types.

Seasons

GET /seasons

Returns all seasons ordered by start date, most recent first.
cURL
curl http://localhost:3000/seasons
id
number
Season identifier.
name
string
Season name.
start_date
string
Start date (ISO 8601).
end_date
string
End date (ISO 8601).
is_active
boolean
Whether this is the currently active season. Only one season is active at a time.

GET /seasons/active

Returns the single active season.
cURL
curl http://localhost:3000/seasons/active
Returns 404 when no season has is_active = true.

POST /seasons

Creates a new season. When is_active is true, all other seasons are deactivated first. Optionally imports groups, team registrations, and squad rosters from an existing season in the same database transaction. Requires admin role.
name
string
required
Season name.
start_date
string
Start date (ISO 8601).
end_date
string
End date (ISO 8601).
is_active
boolean
default:"false"
Set to true to mark this as the active season.
import_from
number
ID of a season to import structure from. Copies groups, team registrations (with zeroed statistics), and player squad entries into the new season.
cURL
curl -X POST http://localhost:3000/seasons \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Liga 2025-26",
    "start_date": "2025-09-01",
    "end_date": "2026-06-30",
    "is_active": true,
    "import_from": 3
  }'

PUT /seasons/:id

Updates an existing season. When is_active is set to true, all other seasons are deactivated. Requires admin role.
id
number
required
Season identifier.
name
string
Season name.
start_date
string
Start date (ISO 8601).
end_date
string
End date (ISO 8601).
is_active
boolean
Whether to make this the active season.
cURL
curl -X PUT http://localhost:3000/seasons/3 \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Liga 2024-25 (revised)", "is_active": true}'
Returns the updated season object.

DELETE /seasons/:id

Permanently deletes a season. Fails if the season has dependant records (groups, matches) due to database foreign-key constraints. Requires admin role.
id
number
required
Season identifier.
cURL
curl -X DELETE http://localhost:3000/seasons/3 \
  -H "Authorization: Bearer <token>"
This is a hard delete. Remove all associated groups and matches before deleting a season.

POST /seasons/:id/import-structure

Copies the group structure, team registrations (with zeroed stats), and player squad entries from another season into an existing season. Runs in a single database transaction. Requires admin role.
id
number
required
The target season that will receive the imported data.
fromSeasonId
number
required
The source season to copy from.
cURL
curl -X POST http://localhost:3000/seasons/4/import-structure \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"fromSeasonId": 3}'
message
string
Confirmation message.
groupsImported
number
Number of groups copied from the source season.

Groups

GET /groups

Returns all groups, optionally filtered by season. Results are ordered by season start date (newest first) and then group name alphabetically.
season_id
number
Filter to groups belonging to this season.
cURL
curl "http://localhost:3000/groups?season_id=3"
id
number
Group identifier.
name
string
Group name.
season_id
number
Season this group belongs to.
season_name
string
Season name.

GET /groups/:id/teams

Returns the teams assigned to a group, ordered by points then goals scored.
id
number
required
Group identifier.
cURL
curl http://localhost:3000/groups/1/teams
Each item contains id, name, logo_url, played, and points.

Admin group endpoints

The following endpoints require the admin role.

POST /groups

Creates a new group in a season.
name
string
required
Group name.
season_id
number
required
Season to create the group in.
cURL
curl -X POST http://localhost:3000/groups \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Grupo C", "season_id": 3}'
Returns the created group object with 201 Created.

PUT /groups/:id

Updates a group’s name or season assignment.
id
number
required
Group identifier.
name
string
New group name.
season_id
number
New season assignment.

DELETE /groups/:id

Permanently deletes a group. Fails if the group has associated matches.
id
number
required
Group identifier.

POST /groups/:id/teams

Assigns a team to a group by creating a team_stats entry for the given team, group, and season.
id
number
required
Group identifier.
team_id
number
required
Team identifier.
season_id
number
required
Season identifier.

DELETE /groups/:id/teams/:teamId

Removes a team from a group by deleting the corresponding team_stats row.
id
number
required
Group identifier.
teamId
number
required
Team identifier.
season_id
number
required
Season identifier (required query parameter).

Fields

GET /fields

Returns all active playing fields ordered by name.
cURL
curl http://localhost:3000/fields
id
number
Field identifier.
name
string
Field name.
location
string | null
Physical address or location description.
is_active
boolean
Always true in this response — inactive fields are excluded.

Admin field endpoints

The following endpoints require the admin role.

POST /fields

Creates a new field.
name
string
required
Field name.
location
string
Physical address or location description.
cURL
curl -X POST http://localhost:3000/fields \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Pabellón Central", "location": "Calle Mayor 10"}'
Returns the created field object with 201 Created.

PUT /fields/:id

Updates a field’s name or location.
id
number
required
Field identifier.
name
string
Field name.
location
string
Location description.

DELETE /fields/:id

Soft-deletes a field (sets is_active = false).
id
number
required
Field identifier.

POST /fields/:id/restore

Restores a soft-deleted field.
id
number
required
Field identifier.

DELETE /fields/:id/permanent

Permanently deletes a field. The field must already be in the trash (is_active = false). Returns 400 if the field has associated matches.
id
number
required
Field identifier.
Permanently deleted fields cannot be recovered.

GET /fields/admin/trash

Returns all soft-deleted fields, ordered by name.
cURL
curl http://localhost:3000/fields/admin/trash \
  -H "Authorization: Bearer <token>"

Build docs developers (and LLMs) love