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.

Admins can create, edit, and delete match fixtures at any point in the season. Deleted fixtures go to a recoverable trash bin before permanent removal. Once matches are finished, you can export a full season report for PDF generation.

Creating a fixture

To create a match, send a POST request to /matches. All fixtures start with status pendiente (pending) and remain editable until a referee locks and starts them. Required fields:
FieldTypeDescription
datedatetimeScheduled date and time of the match
fieldIdintegerID of the venue/field
groupIdintegerID of the group this match belongs to
seasonIdintegerID of the season
phasestringMatch phase (see phases)
Optional fields:
FieldTypeDescription
homeTeamIdintegerHome team ID (omit for knockout placeholders)
awayTeamIdintegerAway team ID (omit for knockout placeholders)
homePlaceholderstringDisplay text when home team is not yet known (e.g. "Winner Group A")
awayPlaceholderstringDisplay text when away team is not yet known
1

Fill in the required fields

Provide date, fieldId, groupId, seasonId, and phase in the request body. If you know both teams, include homeTeamId and awayTeamId.
2

Use placeholders for undecided opponents

For knockout fixtures where teams are not yet determined, omit the team IDs and set homePlaceholder and awayPlaceholder instead (e.g. "Ganador Grupo B"). Voting is disabled for fixtures without real team IDs.
3

Submit the request

On success the API returns the new match id with HTTP 201. The fixture appears in the calendar immediately.
POST /matches
Content-Type: application/json
Authorization: Bearer <admin_token>

{
  "date": "2025-03-15T18:00:00",
  "fieldId": 2,
  "groupId": 4,
  "seasonId": 1,
  "phase": "fase_de_grupos",
  "homeTeamId": 7,
  "awayTeamId": 12
}

Match phases

The phase field accepts the following values:
ValueDescription
fase_de_gruposGroup stage (default)
octavosRound of 16
cuartosQuarter-finals
semisSemi-finals
finalFinal

Editing team assignments

Once knockout opponents are determined, update the teams on an existing fixture using PUT /matches/:id/teams. You can assign real team IDs, update or clear placeholders, or do both at once.
PUT /matches/42/teams
Content-Type: application/json
Authorization: Bearer <admin_token>

{
  "homeTeamId": 9,
  "awayTeamId": 11,
  "homePlaceholder": null,
  "awayPlaceholder": null
}
This action is audited under the action name "Actualización de equipos".
Updating teams on a fixture that already has recorded events does not remove or recalculate those events. Only use this endpoint before the match starts, or to correct a configuration error.

Moving a fixture to trash

To soft-delete a fixture, send DELETE /matches/:id. This sets is_active = false on the record — no data is lost and the fixture can be restored.
DELETE /matches/42
Authorization: Bearer <admin_token>
The fixture disappears from the public calendar and match list immediately after deletion. The action is audited as "Eliminación lógica de partido".
You cannot permanently delete a fixture that is still active. Move it to trash first.

Managing the trash bin

Viewing trashed fixtures

Retrieve all soft-deleted fixtures with GET /matches/admin/trash. The response includes the match date, team names (or placeholders), and the season name.
GET /matches/admin/trash
Authorization: Bearer <admin_token>

Restoring a fixture

To restore a trashed fixture, send POST /matches/:id/restore. The fixture becomes active again and reappears in the calendar.
POST /matches/42/restore
Authorization: Bearer <admin_token>
This is audited as "Restauración de partido".

Permanent deletion

To permanently remove a fixture from the database, send DELETE /matches/:id/permanent. The fixture must already be in trash (is_active = false).
DELETE /matches/42/permanent
Authorization: Bearer <admin_token>
Permanent deletion is irreversible and cascades to all related match events. Only do this if you are certain the fixture and its data are no longer needed.

Generating a season report

Use GET /matches/admin/report to retrieve all finished matches for a season, including their full event lists. The frontend uses this data to generate a PDF with jsPDF.
GET /matches/admin/report?season_id=1
Authorization: Bearer <admin_token>
The response is an array of finished match objects. Each object includes:
  • Match metadata: date, teams, goals (regular and penalty shootout), observations
  • events array: each event has the player name, event type, and which team side (home or away)
Only matches with status = 'finalizado' and is_active = true appear in the report. Omitting season_id returns finished matches from all seasons.

Build docs developers (and LLMs) love