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.

Teams and players are global records — they exist independently of any season. Enrolling a team in a season creates a team_stats record for that season. Enrolling a player in a season and team creates a team_players record. This separation means the same team and player profiles carry across multiple seasons without duplication.

Teams

Team fields

FieldDescription
nameDisplay name of the team. Required.
kit_colorPrimary kit colour, stored as a string (for example #e74c3c).
logo_urlCloudinary URL of the team’s badge. Upload via POST /admin/upload?folder=teams.
delegateName of the team delegate or club representative.
coachName of the head coach.
phoneContact phone number for the team.
is_activeWhether the team is active. Soft-deleted teams set this to false.

Creating a team

Send a POST request to /teams with the fields above. Only name is required. If you include a season_id in the request body, the team is immediately enrolled in that season (a team_stats record is created with all statistics at zero).

Enrolling an existing team in a season

To enroll a team that already exists into a new season without recreating it:
POST /teams/:id/register
Request body:
{ "season_id": 5 }
This creates a team_stats record for the team in the given season. If a record already exists it is replaced to avoid duplicates.

Editing a team

Send a PUT request to /teams/:id with the fields you want to update. If you change logo_url to a different Cloudinary asset, the old image is automatically deleted from Cloudinary — as long as the Cloudinary public ID has changed. If you upload a replacement image to the same path (same public ID), Cloudinary has already overwritten it and no deletion is needed.

Removing a team from a season

To remove a team from one specific season without affecting other seasons:
DELETE /teams/:id/season/:seasonId
This deletes the team’s team_stats record for that season and unlinks all its players from the team within that season (the players remain enrolled in the season, just without a team assignment).

Soft delete and trash

Deleting a team globally (DELETE /teams/:id) sets is_active = false — it does not remove the record from the database. Soft-deleted teams are excluded from all public listings and season-filtered queries. You can view them in the trash (GET /teams/admin/trash) and restore them at any time (POST /teams/:id/restore).
Permanent deletion of teams has been disabled to preserve match history and Cloudinary assets. Use soft delete and restore to manage team visibility.

Players

Player fields

FieldDescription
nameFull name of the player. Required.
birth_dateDate of birth in ISO format (YYYY-MM-DD).
photo_urlCloudinary URL of the player’s photo. Upload via POST /admin/upload?folder=players.
is_activeWhether the player is active. Soft-deleted players set this to false.

Creating a player

Send a POST request to /players with the fields above. Only name is required. If you include season_id and optionally team_id, the player is immediately enrolled in the given season and team.

Enrolling an existing player in a season

To register an existing player in a new season, or to transfer them to a different team within the same season:
POST /players/:id/register
Request body:
{
  "team_id": 7,
  "season_id": 5,
  "jersey_number": "10"
}
The endpoint first removes any existing enrollment for the player in that season, then inserts the new record. This makes it safe to use for both initial enrollment and mid-season transfers. If the jersey number is already taken by another player in the same team and season, the API returns a 400 error identifying the conflicting player by name.

Removing a player

You have three levels of removal:
ActionEndpointEffect
Remove from one team in a seasonDELETE /players/:id/unregister (body: team_id, season_id)Deletes the specific team_players row
Remove from an entire seasonDELETE /players/:id/season/:seasonIdDeletes all team_players rows for that season and removes season statistics
Soft delete globallyDELETE /players/:idSets is_active = false; player excluded from all listings
Restore a soft-deleted player with POST /players/:id/restore.
Permanent deletion of players has been disabled to preserve match history and Cloudinary assets.

Roster assignment per season

The team_players table links players to teams within a specific season. Each row stores:
ColumnDescription
player_idReference to the player
team_idReference to the team
season_idReference to the season
jersey_numberShirt number for this season (stored as a string to allow non-numeric values)
A player can only have one enrollment per season — enrolling them again replaces the previous entry. Jersey numbers are validated for uniqueness per team per season.

Carrying rosters between seasons

When you create a new season with import_from, or run POST /seasons/:id/import-structure, the platform copies every team_players row from the source season into the new season. Players retain their team assignments and jersey numbers. You can then adjust rosters manually before the new season begins — adding new signings, changing numbers, or removing players who have left.

Uploading logos and photos

Use the shared image upload endpoint for both team logos and player photos:
POST /admin/upload?folder=teams
POST /admin/upload?folder=players
Send a multipart/form-data request with a single field named image. The server processes the image with Sharp (resizing and compressing it) before uploading to Cloudinary, and returns the resulting URL:
{ "url": "https://res.cloudinary.com/..." }
Store this URL in the team’s logo_url field or the player’s photo_url field when creating or updating the record. All upload requests require an admin JWT.

Build docs developers (and LLMs) love