Skip to main content

Endpoint

POST /api/teams/create
Creates a new Formula 1 team. This endpoint requires admin authentication via JWT token.

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

teamId
string
required
Unique identifier for the team. This will be used as the primary key.
name
string
required
Full name of the team (max 100 characters)
nationality
string
Team’s nationality (max 50 characters)
url
string
URL to the team’s official page (max 255 characters)
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 created team data.
status
number
HTTP status code (200 for success)
body
string
JSON stringified 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/create \
  -H "Content-Type: application/json" \
  -d '{
    "teamId": "aston_martin",
    "name": "Aston Martin Aramco Cognizant F1 Team",
    "nationality": "British",
    "url": "https://www.astonmartinf1.com",
    "teamLogo": "https://example.com/logos/aston_martin.png",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }'

Response

{
  "status": 200,
  "body": "{\"teamId\":\"aston_martin\",\"name\":\"Aston Martin Aramco Cognizant F1 Team\",\"nationality\":\"British\",\"url\":\"https://www.astonmartinf1.com\",\"teamLogo\":\"https://example.com/logos/aston_martin.png\"}"
}

Build docs developers (and LLMs) love