Events track everything that happens inside a match: goals, yellow cards, red cards, and penalty-shootout kicks. Every write operation updates the match scoreline, individual player statistics, and team card tallies atomically within a database transaction. All write endpoints require both a valid JWT and an active match lock held by the calling user.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta2/llms.txt
Use this file to discover all available pages before exploring further.
All write operations (POST, DELETE, PUT) require both authentication (referee or admin role) and a valid match lock. Acquire a lock with
POST /matches/:id/lock before making any changes.Add an event
gol— incrementshome_goalsoraway_goalson the match, and adds 1 goal toplayer_stats.tarjeta_amarilla/tarjeta_roja— adds 1 to the appropriate card column inplayer_statsandteam_stats.penalti_tanda_marcado— incrementshome_penalty_goalsoraway_penalty_goals. Does not affectplayer_stats.penalti_tanda_fallado— recorded for audit purposes only; no counters are incremented.
Body parameters
Event type. Must be one of:
| Value | Description |
|---|---|
gol | Regular goal |
tarjeta_amarilla | Yellow card |
tarjeta_roja | Red card |
penalti_tanda_marcado | Penalty shootout — scored |
penalti_tanda_fallado | Penalty shootout — missed |
ID of the player involved in the event.
Which side the player belongs to:
home or away.Response
400 when type, playerId, or teamSide are missing or invalid. Returns 409 when the match lock is held by a different referee.
Remove an event
- Goal removed — decrements the corresponding goal counter (floor 0).
- Penalty shootout goal removed — decrements the corresponding penalty counter (floor 0).
- Card removed — decrements the card counter in
player_statsand, where applicable,team_stats(floor 0 in both).
Path parameters
Match ID.
ID of the event to delete.
Response
500 with { message: "Evento no encontrado" } if the event does not exist in the specified match.
Update match status
Body parameters
New status. Must be one of:
pendiente, en_curso, finalizado.Response
400 for any value outside the allowed set.
Update observations
Body parameters
Referee notes. Pass
null or omit to clear existing notes.Response
Finalize a match
- Sets
status = 'finalizado'and clears the match lock. - Increments
matches_playedinplayer_statsfor every player who appeared in an event. - Calculates standings (wins, draws, losses, goals for/against, points) and upserts
team_stats. - Determines the correct vote outcome (
local,empate, orvisitante) and awards 1 prediction point to every user who voted correctly.
Body parameters
Optional referee notes to save alongside the finalization.
Response
500 with { message: "El partido ya está finalizado" } if called on an already-finished match.
Lock a match
verifyMatchLock will clean up an expired lock proactively.
Response
409 when the match is actively locked by a different referee:
Unlock a match
Query parameters
Set to
true to force-release a lock regardless of ownership. Only effective for users with the admin role.Response
403 when the calling user does not own the lock and force is not true.