Match management in FutsalLeague Manager spans two distinct roles: admins create and schedule matches and manage the trash cycle, while referees (and admins) take control of live officiating through a lock-based concurrency system. When a match is finalized, the platform atomically updates team standings, individual player stats, and prediction points for users who voted correctly — all inside a single database transaction.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526/llms.txt
Use this file to discover all available pages before exploring further.
Creating a match
Only admins can create matches. Send aPOST /matches request with the following fields:
| Field | Required | Description |
|---|---|---|
date | Yes | ISO 8601 datetime for the match |
homeTeamId | No | ID of the home team (can be null for knockout rounds) |
awayTeamId | No | ID of the away team (can be null for knockout rounds) |
fieldId | Yes | ID of the playing field |
groupId | No | Group this match belongs to |
seasonId | Yes | Season this match belongs to |
phase | No | Competition phase (defaults to fase_de_grupos) |
homePlaceholder | No | Text label when home team is not yet determined |
awayPlaceholder | No | Text label when away team is not yet determined |
status = 'pendiente' and is_active = true.
Match phases
| Value | Description |
|---|---|
fase_de_grupos | Group stage match |
octavos | Round of sixteen |
cuartos | Quarter-finals |
semis | Semi-finals |
final | Final |
Knockout round placeholders
For knockout matches where the opponent is not yet known at scheduling time, leavehomeTeamId and/or awayTeamId as null and use homePlaceholder / awayPlaceholder (for example "Ganador Grupo A") to display descriptive labels on the calendar. Once the teams are determined, update the assignment with PUT /matches/:id/teams.
Referee workflow
Lock the match
Before editing any match data, the referee must acquire an exclusive lock. Only one referee can hold the lock at a time; the lock expires automatically after 2 minutes of inactivity.A successful response:If another referee already holds the lock and it has not expired, the server returns
409 Conflict with the name of the current lock holder.Set the match to in progress
Update the match status to signal that play has started:Valid status values are
pendiente, en_curso, and finalizado. The lock must be held to change status.Record match events
As events occur during the match, post them to the events endpoint. The lock must be held.
Recording a
| Field | Values |
|---|---|
type | gol, tarjeta_amarilla, tarjeta_roja, penalti_tanda_marcado, penalti_tanda_fallado |
playerId | ID of the player involved |
teamSide | home or away |
gol event increments home_goals or away_goals on the match and adds a goal to the player’s player_stats. Recording tarjeta_amarilla or tarjeta_roja adds the card to both the player’s individual stats and the team’s group stats. Penalty shootout events (penalti_tanda_marcado, penalti_tanda_fallado) update home_penalty_goals / away_penalty_goals but do not affect regular player stats.Remove incorrect events
If an event was recorded by mistake, delete it. The system reverses all stat changes made by the event atomically.The response confirms deletion and the match cache is invalidated automatically.
Finalize the match
Finalization closes the match and triggers a cascade of updates in a single transaction:
statusis set tofinalizado- Any optional
observationstext is saved - The lock is released
matches_playedis incremented for every player who appeared in an eventteam_stats(played, won, drawn, lost, goals_for, goals_against, points) is updated for both teams- Prediction votes are evaluated and
user_pointsis updated for users who voted correctly
observations is optional. If the match is already marked finalizado, the request returns an error.Updating team assignments for knockout rounds
Once the teams for a knockout match are determined, fill in their IDs:Trash and restore system
DELETE /matches/:id performs a soft delete — the match’s is_active flag is set to false and it disappears from all public-facing calendars and standings calculations. The match is not permanently removed from the database.
View the trash
View the trash
Restore a match
Restore a match
is_active back to true. The match reappears in calendars and is included in report queries again.Permanent deletion
Permanent deletion
is_active = false). Attempting to permanently delete an active match returns a 400 error — you must soft-delete it first.Season report export
GET /matches/admin/report returns all finalized, active matches for a season along with every event (goals, cards) attached to each match. This payload is used by the frontend to generate PDF exports.
events array:
is_active = false are excluded from the report.