Skip to main content

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.

Retrieve a single match by ID, including the complete list of match events (goals, cards, penalty kicks). The response shape is identical to the list endpoint with the addition of an events array. Responses are Redis-cached per match and user.

Endpoint

GET /matches/:id

Authentication

Optional. Pass a Bearer token to receive userVote for the authenticated user.

Path parameters

id
integer
required
Unique match ID.

Response

All fields from the list endpoint are present, plus:
events
object[]
Ordered list of match events (ascending by event ID).
Event types are mapped from internal Spanish names before being returned. The internal values (gol, tarjeta_amarilla, tarjeta_roja, penalti_tanda_marcado, penalti_tanda_fallado) are only relevant when writing events via the referee endpoints.

Examples

curl --request GET \
  --url 'https://api.example.com/matches/42'
{
  "id": 42,
  "date": "2026-05-20T19:00:00",
  "homeTeam": { "id": 7, "name": "FC Rápidos", "logoUrl": "https://res.cloudinary.com/example/image/upload/logo.webp" },
  "awayTeam": { "id": 11, "name": "Atlético Sur", "logoUrl": "https://res.cloudinary.com/example/image/upload/logo2.webp" },
  "homeTeamPlaceholder": null,
  "awayTeamPlaceholder": null,
  "homeGoals": 3,
  "awayGoals": 2,
  "homePenaltyGoals": null,
  "awayPenaltyGoals": null,
  "field": { "id": 2, "name": "Pabellón Central", "location": "Calle Mayor 10, Valencia" },
  "status": "finalizado",
  "phase": "fase_de_grupos",
  "groupName": "Grupo A",
  "observations": "Partido disputado sin incidencias.",
  "userVote": "local",
  "votingStats": { "local": 14, "draw": 5, "away": 3, "total": 22 },
  "events": [
    { "id": 101, "type": "goal", "player": { "id": 9, "name": "Carlos García" }, "team": "home" },
    { "id": 102, "type": "yellow_card", "player": { "id": 22, "name": "Luis Pérez" }, "team": "away" },
    { "id": 103, "type": "goal", "player": { "id": 9, "name": "Carlos García" }, "team": "home" },
    { "id": 104, "type": "goal", "player": { "id": 35, "name": "Marco Ruiz" }, "team": "away" }
  ]
}

Admin endpoints

The following endpoints require authentication with the admin role.

Create a match

POST /matches
Creates a new match with status pendiente. Invalidates the relevant season and current-season caches.

Body parameters

date
string
required
Match date and time (ISO 8601, e.g. "2026-06-01T18:00:00").
homeTeamId
integer
Home team ID. Omit or pass null for unresolved knockout slots.
awayTeamId
integer
Away team ID. Omit or pass null for unresolved knockout slots.
fieldId
integer
required
Venue field ID.
groupId
integer
required
Group ID the match belongs to.
seasonId
integer
required
Season ID.
phase
string
Competition phase. Defaults to fase_de_grupos.
homePlaceholder
string
Text label for an unresolved home slot (e.g. "Winner Group B").
awayPlaceholder
string
Text label for an unresolved away slot.
Returns 201 with { message, id } on success.

Soft-delete a match

DELETE /matches/:id
Sets is_active = false (logical deletion). The match is moved to the trash and no longer appears in public responses. Cache entries for the affected season are invalidated. Returns { message: "Partido enviado a la papelera correctamente" } on success, 404 if not found.

Restore a match from trash

POST /matches/:id/restore
Sets is_active = true, making the match visible again. Only works on matches that have already been soft-deleted. Returns { message: "Partido restaurado correctamente" } on success.

Permanently delete a match

DELETE /matches/:id/permanent
Physically removes the match record from the database. The match must already be in the trash (is_active = false); attempting to permanently delete an active match returns 400.
Permanent deletion is irreversible and may cascade to related events depending on database constraints. Soft-delete first, then permanently delete from the trash.

Update team assignments

PUT /matches/:id/teams
Updates the teams assigned to a match. Useful for populating knockout-round fixtures once the advancing teams are known.

Body parameters

homeTeamId
integer
New home team ID. Pass null to clear.
awayTeamId
integer
New away team ID. Pass null to clear.
homePlaceholder
string
Updated placeholder label for the home slot.
awayPlaceholder
string
Updated placeholder label for the away slot.
Returns { message, success: true } on success.

Build docs developers (and LLMs) love