Skip to main content

Endpoint

POST /api/races/create
Create a new race record in the F1 PitLane Predict database. This endpoint requires admin authentication via JWT token.

Authentication

This endpoint requires admin privileges. Include a valid JWT token in the request body with userType set to admin.

Request body

token
string
required
JWT authentication token with admin privileges
raceId
integer
required
Unique identifier for the race
season
string
required
Season year (4-character string)
round
integer
required
Round number in the season
raceName
string
required
Name of the race
circuitId
string
required
Unique identifier for the circuit
circuitName
string
required
Name of the circuit
locality
string
required
City or locality where the race takes place
country
string
required
Country where the race takes place
date
string
required
Race date (ISO 8601 format)
time
string
required
Race time
url
string
required
URL with additional race information

Example request

curl -X POST https://api.f1pitlanepredict.com/api/races/create \
  -H "Content-Type: application/json" \
  -d '{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "raceId": 1,
    "season": "2024",
    "round": 1,
    "raceName": "Bahrain Grand Prix",
    "circuitId": "bahrain",
    "circuitName": "Bahrain International Circuit",
    "locality": "Sakhir",
    "country": "Bahrain",
    "date": "2024-03-02T00:00:00.000Z",
    "time": "15:00:00",
    "url": "https://en.wikipedia.org/wiki/2024_Bahrain_Grand_Prix"
  }'

Response

status
integer
HTTP status code
body
string
JSON stringified response containing the created race object or error message

Example response

{
  "status": 200,
  "body": "{
    \"raceId\": 1,
    \"season\": \"2024\",
    \"round\": 1,
    \"raceName\": \"Bahrain Grand Prix\",
    \"circuitId\": \"bahrain\",
    \"circuitName\": \"Bahrain International Circuit\",
    \"locality\": \"Sakhir\",
    \"country\": \"Bahrain\",
    \"date\": \"2024-03-02T00:00:00.000Z\",
    \"time\": \"15:00:00\",
    \"url\": \"https://en.wikipedia.org/wiki/2024_Bahrain_Grand_Prix\"
  }"
}

Error responses

400 Bad Request
Missing or invalid token in request body
{
  "status": 400,
  "body": "{\"error\": \"Bad Request\"}"
}
401 Unauthorized
JWT verification failed or token has expired
{
  "status": 401,
  "body": "{\"error\": \"Unauthorized\"}"
}
or
{
  "status": 401,
  "body": "{\"error\": \"Token has expired\"}"
}
403 Forbidden
User does not have admin privileges
{
  "status": 403,
  "body": "{\"error\": \"Forbidden\"}"
}

Build docs developers (and LLMs) love