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.

The matches endpoints cover the full fixture lifecycle: browsing the match calendar, viewing match detail with events, casting prediction votes, and — for referees and admins — creating, locking, updating, and finishing matches.

GET /matches

Returns the match calendar for a season. Authentication is optional — when a valid token is provided, the response includes the authenticated user’s vote for each match.
season_id
number
Filter by season. When omitted, matches from the currently active season are returned.
cURL
curl http://localhost:3000/matches?season_id=3

Response fields

id
number
Match identifier.
date
string
ISO 8601 datetime of the match.
homeTeam
object | null
Home team object, or null if not yet assigned.
awayTeam
object | null
Away team object with the same shape as homeTeam, or null.
homeTeamPlaceholder
string | null
Label shown when the home team is not yet determined (e.g. “Winner Group A”).
awayTeamPlaceholder
string | null
Label shown when the away team is not yet determined.
homeGoals
number | null
Home team goals. null when the match has not started.
awayGoals
number | null
Away team goals. null when the match has not started.
homePenaltyGoals
number | null
Home team goals scored in a penalty shootout.
awayPenaltyGoals
number | null
Away team goals scored in a penalty shootout.
field
object
Playing field.
status
string
One of pendiente, en_curso, or finalizado.
phase
string
Competition phase, e.g. fase_de_grupos or eliminatorias.
groupName
string | null
Name of the group this match belongs to.
dayOfWeek
string | null
Localised weekday name in Spanish (e.g. Sábado).
observations
string | null
Referee notes added at the end of the match.
userVote
string | null
The authenticated user’s vote (local, empate, or visitante), or null when unauthenticated or not yet voted.
votingStats
object
Aggregated prediction votes for this match.

GET /matches/last-activity

Returns the Unix timestamp of the last global match update. Use this for long-polling to detect score or event changes without fetching the full match list.
cURL
curl http://localhost:3000/matches/last-activity
timestamp
number | null
Unix millisecond timestamp of the most recent activity, or null when no activity has been recorded.

GET /matches/:id

Returns full detail for a single match, including the events array. Authentication is optional.
id
number
required
Match identifier.
cURL
curl http://localhost:3000/matches/42
All fields from GET /matches are included. The following field is added:
events
object[]
Ordered list of match events.

POST /matches/:id/vote

Submits or updates the authenticated user’s pre-match prediction. Voting is only allowed while the match status is pendiente and both teams are assigned. Requires authentication.
id
number
required
Match identifier.
vote
string
required
The prediction. Must be one of local (home win), empate (draw), or visitante (away win).
cURL
curl -X POST http://localhost:3000/matches/42/vote \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"vote": "local"}'
message
string
Confirmation message.
votingStats
object
Updated vote counts after the submission.

POST /matches

Creates a new match. Requires admin role.
date
string
required
ISO 8601 datetime of the match.
seasonId
number
required
Season the match belongs to.
fieldId
number
required
Playing field identifier.
groupId
number
Group identifier for group-stage matches.
homeTeamId
number
Home team identifier. Omit if the team is not yet determined.
awayTeamId
number
Away team identifier. Omit if the team is not yet determined.
homePlaceholder
string
Label to display when the home team is not yet set (e.g. “Winner Group A”).
awayPlaceholder
string
Label to display when the away team is not yet set.
phase
string
default:"fase_de_grupos"
Competition phase.
cURL
curl -X POST http://localhost:3000/matches \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2025-05-10T18:00:00",
    "seasonId": 3,
    "fieldId": 2,
    "groupId": 1,
    "homeTeamId": 7,
    "awayTeamId": 12,
    "phase": "fase_de_grupos"
  }'

DELETE /matches/:id

Soft-deletes (moves to trash) a match. Requires admin role.
id
number
required
Match identifier.
cURL
curl -X DELETE http://localhost:3000/matches/42 \
  -H "Authorization: Bearer <token>"
Returns { "message": "Partido enviado a la papelera correctamente" }.

POST /matches/:id/restore

Restores a trashed match. Requires admin role.
id
number
required
Match identifier.
cURL
curl -X POST http://localhost:3000/matches/42/restore \
  -H "Authorization: Bearer <token>"

DELETE /matches/:id/permanent

Permanently deletes a match from the database. Requires admin role. The match must already be in the trash (is_active = false).
id
number
required
Match identifier.
cURL
curl -X DELETE http://localhost:3000/matches/42/permanent \
  -H "Authorization: Bearer <token>"
This action is irreversible. All associated events are deleted in cascade.

GET /matches/admin/trash

Returns all soft-deleted matches. Requires admin role.
cURL
curl http://localhost:3000/matches/admin/trash \
  -H "Authorization: Bearer <token>"
id
number
Match identifier.
date
string
Match datetime.
home_team_name
string | null
Home team name.
away_team_name
string | null
Away team name.
home_team_placeholder
string | null
Home team placeholder label.
away_team_placeholder
string | null
Away team placeholder label.
season_name
string
Name of the season.

GET /matches/admin/report

Returns all finished matches with their events for the specified season. Requires admin role.
season_id
number
Season to report on. When omitted, all finished matches across all seasons are returned.
cURL
curl "http://localhost:3000/matches/admin/report?season_id=3" \
  -H "Authorization: Bearer <token>"

PUT /matches/:id/teams

Updates the teams assigned to a match. Used to fill in knockout-stage slots once qualifiers are known. Requires admin role.
id
number
required
Match identifier.
homeTeamId
number
Home team identifier. Pass null to clear.
awayTeamId
number
Away team identifier. Pass null to clear.
homePlaceholder
string
Home team placeholder label.
awayPlaceholder
string
Away team placeholder label.
cURL
curl -X PUT http://localhost:3000/matches/42/teams \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"homeTeamId": 7, "awayTeamId": 12}'

POST /matches/:id/lock

Acquires an exclusive editing lock on a match. The lock is held for 2 minutes and must be renewed by repeated calls. Returns a conflict if another user holds an active lock. Requires referee or admin role.
id
number
required
Match identifier.
cURL
curl -X POST http://localhost:3000/matches/42/lock \
  -H "Authorization: Bearer <token>"

POST /matches/:id/unlock

Releases the editing lock on a match. A referee can only release a lock they own. Admins can force-release any lock. Requires referee or admin role.
id
number
required
Match identifier.
force
boolean
default:"false"
Set to true to force-release a lock owned by another user (admin only).
cURL
curl -X POST "http://localhost:3000/matches/42/unlock?force=true" \
  -H "Authorization: Bearer <token>"

PUT /matches/:id/status

Updates the match status. Requires referee or admin role and an active lock.
id
number
required
Match identifier.
status
string
required
New status. One of pendiente, en_curso, or finalizado.
cURL
curl -X PUT http://localhost:3000/matches/42/status \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"status": "en_curso"}'

PUT /matches/:id/observations

Sets or clears the referee observations for a match. Requires referee or admin role and an active lock.
id
number
required
Match identifier.
observations
string
Referee notes. Pass null or omit to clear.
cURL
curl -X PUT http://localhost:3000/matches/42/observations \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"observations": "Brief scuffle in the second half."}'

POST /matches/:id/events

Records a match event. Goals and penalty shootout goals automatically increment the corresponding goal counter on the match row. Goals and cards also update the player’s season statistics. Requires referee or admin role and an active lock.
id
number
required
Match identifier.
type
string
required
Event type. One of: gol, tarjeta_amarilla, tarjeta_roja, penalti_tanda_marcado, penalti_tanda_fallado.
playerId
number
required
Player who caused the event.
teamSide
string
required
home or away.
cURL
curl -X POST http://localhost:3000/matches/42/events \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"type": "gol", "playerId": 5, "teamSide": "home"}'

DELETE /matches/:matchId/events/:eventId

Removes a match event and reverses its effect on goal counts and player statistics. Requires referee or admin role and an active lock.
matchId
number
required
Match identifier.
eventId
number
required
Event identifier.
cURL
curl -X DELETE http://localhost:3000/matches/42/events/101 \
  -H "Authorization: Bearer <token>"

PUT /matches/:id/finish

Finalises a match: sets status to finalizado, releases the lock, updates team standings, awards prediction points to users who voted correctly, and increments matches_played for all players who appeared in events. Requires referee or admin role and an active lock.
id
number
required
Match identifier.
observations
string
Optional final referee notes.
cURL
curl -X PUT http://localhost:3000/matches/42/finish \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"observations": "Clean game."}'

Build docs developers (and LLMs) love