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.

Referees (and admins) control the entire live match workflow: acquiring the editing lock, starting the match, recording events, and finalising the result. All write operations require an active lock on the match.
Every endpoint that modifies live match data — changing status, adding or removing events, updating observations, and finishing the match — requires you to hold the match lock. Acquire and renew the lock before performing any of these operations.

Full workflow

1

Acquire the lock

Send POST /matches/:id/lock to claim exclusive editing rights on the match. If the lock is free (or has expired), you acquire it immediately. If another referee holds the lock, the API returns 409 with the current owner’s username.
POST /matches/42/lock
Authorization: Bearer <referee_token>
The lock expires after 2 minutes of inactivity. You must renew it by calling the same endpoint again before it lapses — otherwise another referee can claim it. Call the lock endpoint periodically while you are actively editing.
If you navigate away or close the browser without unlocking, the lock will be released automatically after the 2-minute expiry. Only you (the lock owner) or an admin can force-unlock before expiry.
2

Start the match

Change the match status to en_curso using PUT /matches/:id/status. Valid statuses are pendiente, en_curso, and finalizado.
PUT /matches/42/status
Content-Type: application/json
Authorization: Bearer <referee_token>

{
  "status": "en_curso"
}
Changing the status invalidates the match cache and updates the global last-activity timestamp, which triggers connected clients to refresh.
3

Record match events

Add events during the match with POST /matches/:id/events. You must hold the lock to use this endpoint.
POST /matches/42/events
Content-Type: application/json
Authorization: Bearer <referee_token>

{
  "type": "gol",
  "playerId": 17,
  "teamSide": "home"
}
Required fields:
FieldTypeDescription
typestringEvent type (see table below)
playerIdintegerID of the player involved
teamSidestring"home" or "away"
Event types:
TypeEffect
golIncrements home_goals or away_goals; updates player and team stats
tarjeta_amarillaRecords a yellow card; updates player and team stats
tarjeta_rojaRecords a red card; updates player and team stats
penalti_tanda_marcadoIncrements home_penalty_goals or away_penalty_goals only — not counted in regular goals or player stats
penalti_tanda_falladoRecords a missed penalty shootout attempt — no score or stat update
Penalty shootout events (penalti_tanda_marcado and penalti_tanda_fallado) are tracked separately in home_penalty_goals / away_penalty_goals and do not affect player statistics or the regular scoreline.
4

Correct mistakes by removing events

If you record an event in error, remove it with DELETE /matches/:matchId/events/:eventId. You must hold the lock. Removing an event reverses its effect on the scoreline and on player and team statistics.
DELETE /matches/42/events/301
Authorization: Bearer <referee_token>
5

Add referee observations (optional)

Record any referee notes using PUT /matches/:id/observations. You must hold the lock. Observations are stored as free text and appear on the match detail page and in the season report.
PUT /matches/42/observations
Content-Type: application/json
Authorization: Bearer <referee_token>

{
  "observations": "Player #5 received a second yellow card at minute 38."
}
Send null or an empty string to clear existing observations.
6

Finish the match

Finalise the match with PUT /matches/:id/finish. You must hold the lock. This endpoint:
  • Sets status to finalizado
  • Saves any final observations you pass in the body
  • Calculates and updates league standings (team_stats) based on the scoreline
  • Increments matches_played for all players who participated
  • Awards porra (voting) points to users who correctly predicted the result
  • Releases the lock automatically
PUT /matches/42/finish
Content-Type: application/json
Authorization: Bearer <referee_token>

{
  "observations": "Good fair play throughout."
}
Points allocation: win = 3 points, draw = 1 point each, loss = 0 points. The porra winner determination compares home_goals vs away_goals — penalty shootout goals are not used to determine the result for porra or standings purposes.
You cannot finish a match that is already in finalizado status. Attempting to do so returns an error. Verify the current status before calling this endpoint.
7

Release the lock

After finishing, the lock is released automatically. If you need to release it manually at any point (e.g. you are done editing before finishing), call POST /matches/:id/unlock.
POST /matches/42/unlock
Authorization: Bearer <referee_token>
Only the lock owner or an admin can unlock. Admins can also pass ?force=true to override the lock regardless of ownership.

Lock conflict handling

If you attempt to acquire a lock that another referee holds, the API responds with 409:
{
  "message": "El partido está siendo editado por ref_username",
  "success": false,
  "owner": "ref_username"
}
Contact the current lock owner to release it, wait for the 2-minute expiry, or ask an admin to force-unlock.

Build docs developers (and LLMs) love