Skip to main content

Endpoint

POST /api/teams/update
Despite being a POST request, this endpoint performs an update operation. It’s configured this way in the Nitro.js handler.
Updates an existing Formula 1 team’s information. This endpoint requires admin authentication via JWT token and allows updating the team ID along with other fields.

Authentication

This endpoint requires an admin JWT token. The token must:
  • Be valid and not expired
  • Contain a userType field with value "admin"
  • Be signed with the application’s secret key

Request

oldTeamId
string
required
Current team ID to identify which team to update
newTeamId
string
required
New team ID (can be the same as oldTeamId if not changing)
name
string
required
Updated full name of the team (max 100 characters)
nationality
string
Updated team nationality (max 50 characters)
url
string
Updated URL to the team’s official page (max 255 characters)
Updated URL to the team’s logo image (max 255 characters)
token
string
required
JWT authentication token with admin privileges

Response

Success (200)

Returns an object containing the status and updated team data.
status
number
HTTP status code (200 for success)
body
string
JSON stringified updated team object containing:

Error responses

400 - Bad Request
Returned when no token is provided in the request body
{
  "status": 400,
  "body": "{\"error\":\"Bad Request\"}"
}
401 - Unauthorized
Returned when:
  • JWT verification fails
  • Token has expired
{
  "status": 401,
  "body": "{\"error\":\"Unauthorized\"}"
}
or
{
  "status": 401,
  "body": "{\"error\":\"Token has expired\"}"
}
403 - Forbidden
Returned when the authenticated user does not have admin privileges
{
  "status": 403,
  "body": "{\"error\":\"Forbidden\"}"
}

Example

curl -X POST https://your-domain.com/api/teams/update \
  -H "Content-Type: application/json" \
  -d '{
    "oldTeamId": "red_bull",
    "newTeamId": "red_bull",
    "name": "Oracle Red Bull Racing",
    "nationality": "Austrian",
    "url": "https://www.redbullracing.com",
    "teamLogo": "https://example.com/logos/red_bull_new.png",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }'

Response

{
  "status": 200,
  "body": "{\"teamId\":\"red_bull\",\"name\":\"Oracle Red Bull Racing\",\"nationality\":\"Austrian\",\"url\":\"https://www.redbullracing.com\",\"teamLogo\":\"https://example.com/logos/red_bull_new.png\"}"
}

Implementation notes

The update operation is performed using Prisma’s update method as shown in /home/daytona/workspace/source/server/api/teams/update.ts:41-52:
const updatedTeam = await db.teams.update({
    where: {
        teamId: oldTeamId,
    },
    data: {
        teamId: newTeamId,
        name: name,
        nationality: nationality,
        url: url,
        teamLogo: teamLogo,
    },
});
This allows updating the team ID itself, which is useful for correcting team identifiers while maintaining database relationships.

Build docs developers (and LLMs) love