The Matches API is the operational core of FutsalLeague Manager. It exposes a complete set of endpoints for browsing the calendar, recording live events such as goals and cards, managing editorial locks so that only one referee edits a match at a time, and finalizing results — which automatically updates the standings and distributes prediction points to users.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.
Public endpoints
List matches
GET /matches
Returns all active matches for the requested season (or the currently active season if no season_id is provided). Each object includes team details, the current score, field information, phase, group name, aggregated voting statistics, and the authenticated user’s own vote when a valid token is present.
Filter matches by season. Omit to return matches for the currently active season.
Responses are cached in Redis per season and per user. The cache is invalidated automatically when match data changes.
Get match detail
GET /matches/:id
Returns the full match object plus an ordered array of events. The userVote field is populated when a valid Authorization header is included.
Match ID.
events field.
Match identifier.
ISO 8601 datetime string.
Label shown when the home team slot is not yet filled (knockout rounds).
Label shown when the away team slot is not yet filled (knockout rounds).
Goals scored by the home team.
null before the match starts.Goals scored by the away team.
Penalty shootout goals for the home side.
Penalty shootout goals for the away side.
pendiente | en_curso | finalizadofase_de_grupos or knockout phase identifier.Group name, e.g.
"Grupo A".Referee notes.
local | empate | visitante | null| Status | Meaning |
|---|---|
404 | Match not found. |
Get last activity timestamp
GET /matches/last-activity
Returns the Unix timestamp (milliseconds) of the most recent change to any match. Useful for polling-based live updates without fetching the full calendar.
Response
Vote on a match
POST /matches/:id/vote
Cast or update a prediction vote for a pending match. A user can vote only once; submitting again overwrites the previous vote. Authentication is required.
Match ID.
"local" — home win, "empate" — draw, "visitante" — away win.| Status | Meaning |
|---|---|
400 | Invalid vote value. |
400 | Match has already started or finished. |
400 | One or both teams are not yet defined (placeholder match). |
401 | No valid token provided. |
404 | Match not found. |
Referee / admin endpoints
These endpoints require a valid token with at leastreferee role. Operations that modify live match state also require an active edit lock on the match.
Claim edit lock
POST /matches/:id/lock
Claim exclusive editing rights for a match. The lock expires automatically after 2 minutes of inactivity, after which any referee can claim it. Calling this endpoint again renews the lock.
Match ID.
| Status | Meaning |
|---|---|
409 | Match is currently locked by another user. |
Release edit lock
POST /matches/:id/unlock
Release the lock on a match. Admins can force-release any lock.
Match ID.
Set to
true to override another user’s lock (admin only).Update match status
PUT /matches/:id/status
Change the match lifecycle status. Requires an active lock.
Match ID.
"pendiente" | "en_curso" | "finalizado"Update match observations
PUT /matches/:id/observations
Save free-text referee notes on a match. Requires an active lock.
Match ID.
Free-text notes. Send
null or omit to clear.Add a match event
POST /matches/:id/events
Record a goal, card, or penalty shootout event. Automatically increments the corresponding score field and updates player_stats and team_stats. Requires an active lock.
Match ID.
"gol" | "tarjeta_amarilla" | "tarjeta_roja" | "penalti_tanda_marcado" | "penalti_tanda_fallado"ID of the player who performed the action.
"home" or "away" — determines which score column is incremented.Remove a match event
DELETE /matches/:matchId/events/:eventId
Reverses a previously recorded event, decrementing the relevant score and stat counters. Requires an active lock.
Match ID.
Event ID to remove.
Finalize match
PUT /matches/:id/finish
Closes the match, sets status to finalizado, releases the lock, recalculates standings (team_stats), and distributes prediction points to users who voted correctly. This action is atomic — all changes roll back if any step fails.
Match ID.
Optional final referee notes saved alongside the result.
| Status | Meaning |
|---|---|
400 | Match is already finalized. |
Admin-only endpoints
Create match
POST /matches
Create a new match entry. Either homeTeamId/awayTeamId or placeholder strings must be provided for knockout-round matches where teams are not yet known.
ISO 8601 datetime string.
Home team ID. Omit for placeholder matches.
Away team ID. Omit for placeholder matches.
Field (venue) ID.
Group ID for group-stage matches.
Season ID.
Phase identifier, e.g.
"cuartos", "semifinal", "final".Display label when home team is unknown, e.g.
"Ganador Grupo A".Display label when away team is unknown.
Update team assignments
PUT /matches/:id/teams
Assign or update real team IDs for knockout-round matches once the qualifying teams are known.
Match ID.
Home team ID.
Away team ID.
Clears the home placeholder when a real team is assigned. Pass
null to remove.Clears the away placeholder when a real team is assigned. Pass
null to remove.Soft-delete match
DELETE /matches/:id
Moves a match to the trash (is_active = false). The match no longer appears in public endpoints but can be restored.
Restore match from trash
POST /matches/:id/restore
Restores a soft-deleted match.
Permanently delete match
DELETE /matches/:id/permanent
Physically removes a match and all its events from the database. The match must already be in the trash (is_active = false).
List trashed matches
GET /matches/admin/trash
Returns soft-deleted matches with basic team and season information.
Response — array of objects:
Season match report
GET /matches/admin/report
Returns all finalized matches for a season, each with its full events list. Intended for generating official season reports.
Filter by season. Returns finalized matches across all seasons if omitted.
events array.