{
  "openapi": "3.1.1",
  "info": {
    "title": "Open Live Timing API",
    "description": "Public endpoints of Open Live Timing: push the data of your timing system, read the live state and the\narchived sessions of a page, list the public pages, and manage your accounts, pages and API keys.\n\nGuide with examples: https://openlivetiming.com/docs/api. Step by step: https://openlivetiming.com/connect/api.\nReal time: the SignalR hub `/racehub?instance={slug}` (described in the guide, not in this file).\n\nPush endpoints take an API key (`X-Api-Key`, created in your account). Read endpoints need no key\nfor a public page. Account endpoints take a JWT (`POST /api/auth/login`).",
    "contact": {
      "name": "Open Live Timing",
      "url": "https://openlivetiming.com/about",
      "email": "info@openlivetiming.com"
    },
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://openlivetiming.com"
    }
  ],
  "paths": {
    "/api/accounts": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "summary": "List accounts accessible to the authenticated user.",
        "description": "- **SuperAdmin** — sees all accounts.\n- **User** — sees only accounts they are a member of.",
        "operationId": "GetAccounts",
        "responses": {
          "200": {
            "description": "Returns the list of accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountResponse"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Create a new account.",
        "description": "The authenticated user is automatically added as an **Admin** member of the new account.\n\n### Example request\n\n    POST /api/accounts\n    {\n        \"slug\": \"acme-racing\",\n        \"displayName\": \"ACME Racing Team\"\n    }",
        "operationId": "CreateAccount",
        "requestBody": {
          "description": "Account creation details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Account created. The creator is assigned as Admin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid slug format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "An account with this slug already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/accounts/{accountId}": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "summary": "Get a single account by ID.",
        "operationId": "GetAccount",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDetailResponse"
                }
              }
            }
          },
          "403": {
            "description": "User is not a member of this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Account not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "put": {
        "tags": [
          "Accounts"
        ],
        "summary": "Update an account's display name.",
        "operationId": "UpdateAccount",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Updated account details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Account updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "403": {
            "description": "User does not have Admin role in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Account not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/accounts/{accountId}/members": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "summary": "List members of an account.",
        "operationId": "GetMembers",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the list of members.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountMemberResponse"
                  }
                }
              }
            }
          },
          "403": {
            "description": "User is not a member of this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Add a member to an account.",
        "description": "Requires **Admin** role in the account. If the user is already a member, returns 409.",
        "operationId": "AddMember",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Member details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddAccountMemberRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AddAccountMemberRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AddAccountMemberRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Member added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountMemberResponse"
                }
              }
            }
          },
          "403": {
            "description": "User does not have Admin role in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Target user not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "User is already a member of this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/accounts/{accountId}/members/{memberId}": {
      "put": {
        "tags": [
          "Accounts"
        ],
        "summary": "Update a member's role in an account.",
        "operationId": "UpdateMemberRole",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "description": "The account member ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Updated role.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountMemberRoleRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountMemberRoleRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountMemberRoleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Role updated.",
            "content": {
              "application/json": { }
            }
          },
          "403": {
            "description": "User does not have Admin role in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Member not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Accounts"
        ],
        "summary": "Remove a member from an account.",
        "description": "Requires **Admin** role in the account. Removing a member also revokes their\nAPI key access to all instances in the account.",
        "operationId": "RemoveMember",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "description": "The account member ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Member removed.",
            "content": {
              "application/json": { }
            }
          },
          "403": {
            "description": "User does not have Admin role in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Member not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/accounts/{accountId}/invites": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "summary": "Invite a user to an account by email.",
        "description": "If the email belongs to an existing user, they are added directly.\nOtherwise a pending invite is created. When the invited user registers,\nthe invite is auto-accepted.\n\nRequires **Admin** role in the account.",
        "operationId": "InviteUser",
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "description": "The account ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Invite details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InviteAccountMemberRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/InviteAccountMemberRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/InviteAccountMemberRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "User added directly (already registered).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountInviteResponse"
                }
              }
            }
          },
          "201": {
            "description": "Invite created (user not yet registered).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountInviteResponse"
                }
              }
            }
          },
          "403": {
            "description": "User does not have Admin role in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "User is already a member or has a pending invite.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/invites/{token}/accept": {
      "post": {
        "tags": [
          "Account Invites"
        ],
        "summary": "Accept a pending account invite by token.",
        "description": "The authenticated user accepts the invite and is added as a member of the account.\nThe invite token is typically received via email link.",
        "operationId": "AcceptInvite",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The invite token.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invite accepted. User is now a member of the account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invite has expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Invite not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Invite already accepted or user is already a member.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/auth/register": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "Register",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "Login",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/directory": {
      "get": {
        "tags": [
          "Directory"
        ],
        "summary": "List the public live timing pages.",
        "description": "Only pages that are public, without access password and listed by their owner (plus the collaborative\nsessions of the LapViz apps not marked private, and the public session of each circuit). Live: data in the\nlast 10 minutes; upcoming: a scheduled session in the next 60 days; recent: data in the last 30 days. Order:\nlive (most recent activity first), upcoming (soonest first), recent. Track, session, flag and viewers are only\ngiven for the live pages.",
        "operationId": "Get",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Optional: `live`, `upcoming` or `recent` (several separated by commas); all when omitted.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "circuits",
            "in": "query",
            "description": "Optional: LapViz circuit codes separated by commas (case-insensitive); only the pages of these circuits.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of entries: 50 by default, 200 at most.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 50
            }
          },
          {
            "name": "includeDemos",
            "in": "query",
            "description": "Also return the demo pages (true by default, `false` to exclude them); they come after the real pages of the same status.",
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The pages.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppDirectoryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Unknown status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (60 per minute per IP).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances": {
      "get": {
        "tags": [
          "Instances"
        ],
        "summary": "List instances accessible to the authenticated user.",
        "description": "Visibility is role-based:\n- **SuperAdmin** — sees all instances on the platform.\n- **User** — sees instances in accounts they belong to, plus public instances and instances they are a direct member of.",
        "operationId": "GetMyInstances",
        "responses": {
          "200": {
            "description": "Returns the list of accessible instances.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InstanceResponse"
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "post": {
        "tags": [
          "Instances"
        ],
        "summary": "Create a new live timing instance.",
        "description": "Requires the user to be a **SuperAdmin** or have **Admin** or **Manager** role in the specified account.\n\nThe slug must be 2–64 characters, lowercase alphanumeric and hyphens only,\nwith no leading or trailing hyphens. Pattern: `^[a-z0-9][a-z0-9\\-]{0,62}[a-z0-9]$`\n\n### Example request\n\n    POST /api/instances\n    {\n        \"slug\": \"ridgeway-mx-series\",\n        \"displayName\": \"Ridgeway MX Series\",\n        \"accountId\": \"abc123\"\n    }",
        "operationId": "CreateInstance",
        "requestBody": {
          "description": "Instance creation details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInstanceRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInstanceRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInstanceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Instance created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid slug format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "JWT token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have the required role in the account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "An instance with this slug already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/keys": {
      "post": {
        "tags": [
          "API Keys"
        ],
        "summary": "Create an API key for worker authentication.",
        "description": "The API key grants a worker access to push race data to the specified instances.\nThe user must have Admin or Manager role in the account(s) that own the instances.\n\n⚠️ The full key value is **only returned once** in the response. Store it securely.\n\n### Example request\n\n    POST /api/keys\n    {\n        \"label\": \"Production Worker\",\n        \"instanceSlugs\": [\"ridgeway-mx-series\", \"supercross-round-3\"],\n        \"expiresAt\": \"2027-01-01T00:00:00Z\"\n    }",
        "operationId": "CreateApiKey",
        "requestBody": {
          "description": "API key creation details.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "API key created. The full key is included in the response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreatedResponse"
                }
              }
            }
          },
          "400": {
            "description": "No instance slugs provided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "JWT token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have the required role in one or more instance accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "One or more instance slugs were not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      },
      "get": {
        "tags": [
          "API Keys"
        ],
        "summary": "List API keys owned by the current user.",
        "description": "SuperAdmins see all keys on the platform. Other users see only their own keys.\nThe full key secret is never returned — only the prefix for identification.",
        "operationId": "GetApiKeys",
        "responses": {
          "200": {
            "description": "Returns the list of API keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKeyResponse"
                  }
                }
              }
            }
          },
          "401": {
            "description": "JWT token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/keys/{keyId}": {
      "delete": {
        "tags": [
          "API Keys"
        ],
        "summary": "Revoke an API key.",
        "description": "Permanently revokes an API key. Revoked keys cannot be used for authentication.\nSuperAdmins can revoke any key. Other users can only revoke their own keys.",
        "operationId": "RevokeApiKey",
        "parameters": [
          {
            "name": "keyId",
            "in": "path",
            "description": "The unique identifier of the API key to revoke.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Key successfully revoked.",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "JWT token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "API key not found or not owned by the current user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "Bearer": [ ]
          }
        ]
      }
    },
    "/api/instances/{slug}/access-info": {
      "get": {
        "tags": [
          "Instances"
        ],
        "summary": "Get access requirements for an instance.",
        "description": "Returns whether the caller still has to enter the instance password before viewing.\n`requiresPassword` is false when the instance is public, when the caller is an account/instance\nmember, or when a valid access token is sent (`X-Instance-Token` header or `instance_token` query).\nPrivate instances without a password return 404 to callers who are not members.\n`circuitCode` (once the caller may view) is the LapViz circuit of the instance: the code stored on it, or for a\nsource-fed instance without one the circuit matched from the track name of its live state.\n`shareUrl` and `resultsUrl` (once the caller may view) are the canonical URLs of the live page and of its results\n(share button); `isViewableByAnyone` tells whether anyone can open them and their Open Graph images exist.\n`branding` (once the caller may view) is the header (logo/text, link) and the sponsors set by the organizer.\n`canManage` is true for a signed-in manager of the instance (link to the broadcast overlay control room).\n`isStopwatchSession` is true for a session timed with the LapViz Stopwatch (collaborative session, not the public\nsession of a circuit): the live page links to the Stopwatch.\nThis endpoint is publicly accessible so the client can decide whether\nto show a password prompt before connecting.",
        "operationId": "GetAccessInfo",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "The instance slug.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Access info returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceAccessInfo"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found (or not visible to the caller).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{slug}/verify-access": {
      "post": {
        "tags": [
          "Instances"
        ],
        "summary": "Verify an instance access password.",
        "description": "If the instance has a password set, viewers must verify it before accessing live timing.\nOn success, returns the password version and a short-lived signed access token bound to the\ninstance and password version. The token must be sent to the SignalR hub (`instance_token` query)\nand to the race data endpoints (`X-Instance-Token` header). Changing the password invalidates it.",
        "operationId": "VerifyAccess",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "description": "The instance slug.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The password to verify.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyInstancePasswordRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyInstancePasswordRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyInstancePasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Password correct. Store the returned token client-side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyInstanceAccessResponse"
                }
              }
            }
          },
          "401": {
            "description": "Password incorrect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Instance not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/event": {
      "post": {
        "tags": [
          "Race Data"
        ],
        "summary": "Push a race event to an instance.",
        "description": "Receives a race event from a worker and broadcasts it in real-time to all\nSignalR clients subscribed to the instance group.\n\nRequires an API key authorized for the target instance.\n\n### Event types\nEvents are polymorphic — the `type` discriminator determines the payload shape.\nSee the `RaceEvent` schema for available event types.",
        "operationId": "PostEvent",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The target instance slug (e.g. `ridgeway-mx-series`).",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The race event payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RaceEvent"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RaceEvent"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RaceEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Event accepted and broadcast to connected clients.",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "API key is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "API key is not authorized for this instance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          }
        ]
      }
    },
    "/api/instances/{instanceSlug}/race/events": {
      "post": {
        "tags": [
          "Race Data"
        ],
        "summary": "Push a batch of race events to an instance.",
        "description": "Accepts an array of race events and broadcasts them as a batch to all\nconnected SignalR clients. More efficient than sending events individually\nwhen multiple events are produced in a short window.",
        "operationId": "PostBatchEvents",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The target instance slug.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Array of race event payloads.",
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/RaceEvent"
                    }
                  }
                ]
              }
            },
            "text/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/RaceEvent"
                    }
                  }
                ]
              }
            },
            "application/*+json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/RaceEvent"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Events accepted and broadcast.",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "API key is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "API key is not authorized for this instance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          }
        ]
      },
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get buffered race events since a given timestamp.",
        "description": "Returns all timing events (sector completions, lap completions, position changes,\nflag changes, etc.) that were received after the specified UTC timestamp.\n\nDesigned for client catch-up after a brief disconnection: the client provides\nthe timestamp of the last event it received, and this endpoint returns everything\nthat happened since. Combined with the cached full state, this allows a client to\nreconstruct the complete session history (`SessionEvents`) without missing any events.\n\nThe server retains up to 5,000 events per instance (approximately 60 minutes of\ntypical timing data). If the disconnection was longer, the client should fall back\nto requesting the full state via `GET fullstate`.\n\nThis endpoint is **publicly accessible**.",
        "operationId": "GetEventsSince",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The instance slug to query.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "description": "UTC timestamp — only events after this time are returned.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the buffered events (may be empty).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RaceEvent"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/fullstate": {
      "post": {
        "tags": [
          "Race Data"
        ],
        "summary": "Push full race state to an instance.",
        "description": "Receives the complete race state from a worker. The state is:\n1. **Cached** server-side (so new clients can get the latest state immediately).\n2. **Broadcast** to all SignalR clients in the instance group.\n\nIf the session has changed (different GroupName/RunName), the previous state is\nautomatically archived to session history.\n\nRequires an API key authorized for the target instance.",
        "operationId": "PostFullState",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The target instance slug.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The complete race state: `{\"state\": {\"session\": …, \"drivers\": …}}`.",
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            },
            "text/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            },
            "application/*+json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "State accepted, cached, and broadcast.",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "API key is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "API key is not authorized for this instance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          }
        ]
      },
      "put": {
        "tags": [
          "Race Data"
        ],
        "summary": "Update the server-side state cache without broadcasting to clients.",
        "description": "Used by workers for frequent incremental updates so that new/reconnecting\nclients receive current data without flooding all connected clients.",
        "operationId": "PutFullState",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            },
            "text/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            },
            "application/*+json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/FullStateEvent"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          }
        ]
      },
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the latest cached race state for an instance.",
        "description": "Returns the last full state pushed by a worker for this instance.\nThis endpoint is **publicly accessible** (no authentication required) and is\ntypically called by clients on initial page load before the SignalR connection\nis established.\n\nReturns `404` if no worker has pushed state for this instance yet.",
        "operationId": "GetFullState",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The instance slug to query.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the latest cached state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FullStateEvent"
                }
              }
            }
          },
          "404": {
            "description": "No cached state available for this instance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/history": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "List past session snapshots for an instance.",
        "description": "Returns metadata for archived sessions, ordered by most recent first.\nUse the returned `id` to fetch the full state of a past session via the\n`GET history/{historyId}` endpoint.\n\nThis endpoint is **publicly accessible**.",
        "operationId": "GetHistory",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The instance slug to query.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of entries to return (default 20).",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the list of archived session summaries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SessionHistoryEntry"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/history/{historyId}": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the full state of a past session by history ID.",
        "description": "Returns the archived full state snapshot for a specific past session.\nThis endpoint is **publicly accessible**.",
        "operationId": "GetHistoryState",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "description": "The instance slug.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "historyId",
            "in": "path",
            "description": "The history entry ID.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the archived full state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FullStateEvent"
                }
              }
            }
          },
          "404": {
            "description": "History entry not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/archive": {
      "post": {
        "tags": [
          "Race Data"
        ],
        "summary": "Receive a detailed session archive from a worker.",
        "description": "Contains full lap/sector history for all drivers in a completed session.\nThe archive is attached to the most recent matching session in the history.\nRequires API Key authentication.",
        "operationId": "PostSessionArchive",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionArchiveEvent"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionArchiveEvent"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SessionArchiveEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": { }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          }
        ]
      }
    },
    "/api/instances/{instanceSlug}/race/history/{historyId}/laps": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the detailed lap history for an archived session.",
        "description": "Returns the full lap/sector breakdown for all drivers in the session.\nReturns 404 if the history entry doesn't exist or has no detail data.\nThis endpoint is **publicly accessible**.",
        "operationId": "GetHistoryLaps",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "historyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DriverLapHistory"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/history/{historyId}/laps/{driverNumber}": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the detailed lap history for specific drivers in an archived session.",
        "description": "Returns the lap/sector breakdown filtered to the specified driver numbers.\nThis endpoint is **publicly accessible**.",
        "operationId": "GetHistoryDriverLaps",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "historyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "driverNumber",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DriverLapHistory"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/history/{historyId}/recording": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the recording of an archived session (race replay).",
        "description": "Every timing event of the session as received (sectors, laps, positions, bests, flags, session info,\nannouncements) and its full states, thinned (one when the statuses, pits, race control notices or names change,\nat most every 10 s, and one a minute anyway): a JSON array of race events in time order, the first one the full\nstate that started the session when it was recorded from its start. Recorded since November 2026; the sessions\narchived before are rebuilt from their lap detail (laps, sectors, positions; no flags or messages), 404 without it.\nGzip when accepted. Same access as the archive.\nThis endpoint is **publicly accessible** for public instances.",
        "operationId": "GetHistoryRecording",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "historyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The recorded events.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RaceEvent"
                  }
                }
              }
            }
          },
          "404": {
            "description": "History entry not found, or without recording.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{instanceSlug}/race/history/{historyId}/timeline": {
      "get": {
        "tags": [
          "Race Data"
        ],
        "summary": "Get the race timeline of an archived session (race replay, \"Download the race\").",
        "description": "The session as a race timeline (race feed version 2 of the LapViz 3D player): title, circuit, start (UTC),\nduration, sectors, best sectors, drivers, and the events on one clock in seconds from the start (sector and lap\ncrossings with time and position, flags, messages, pits, retirements and finishes). Built from the recording\n(`GET history/{historyId}/recording`); 404 without one, or when the organiser does not allow downloading the race\ndata (instance setting). `download=1` sends it as a file. Gzip when accepted.\nThis endpoint is **publicly accessible** for public instances.",
        "operationId": "GetHistoryTimeline",
        "parameters": [
          {
            "name": "instanceSlug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "historyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "download",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The race timeline.",
            "content": {
              "application/json": { }
            }
          },
          "404": {
            "description": "History entry not found, or without recording.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccountDetailResponse": {
        "required": [
          "id",
          "slug",
          "displayName",
          "createdAt",
          "members",
          "instances"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountMemberResponse"
            }
          },
          "instances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InstanceResponse"
            }
          }
        },
        "description": "Detailed account information including members and instances."
      },
      "AccountInviteResponse": {
        "required": [
          "inviteId",
          "email",
          "role",
          "acceptedDirectly",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "inviteId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The invite ID (null if user was added directly)."
          },
          "email": {
            "type": "string",
            "description": "The invited email address."
          },
          "role": {
            "type": "string",
            "description": "The assigned role."
          },
          "acceptedDirectly": {
            "type": "boolean",
            "description": "True if the user was already registered and added directly."
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "When the invite expires (null if accepted directly).",
            "format": "date-time"
          }
        },
        "description": "Response for an account invite."
      },
      "AccountMemberResponse": {
        "required": [
          "id",
          "userId",
          "displayName",
          "email",
          "role",
          "joinedAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Membership ID."
          },
          "userId": {
            "type": "string",
            "description": "The user's ID."
          },
          "displayName": {
            "type": "string",
            "description": "The user's display name."
          },
          "email": {
            "type": "string",
            "description": "The user's email."
          },
          "role": {
            "type": "string",
            "description": "Account role (Admin, Manager, Viewer)."
          },
          "joinedAt": {
            "type": "string",
            "description": "When the user joined the account.",
            "format": "date-time"
          }
        },
        "description": "Represents an account member in API responses."
      },
      "AccountResponse": {
        "required": [
          "id",
          "slug",
          "displayName",
          "createdAt",
          "memberCount",
          "instanceCount"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the account."
          },
          "slug": {
            "type": "string",
            "description": "URL-safe identifier."
          },
          "displayName": {
            "type": "string",
            "description": "Human-readable name."
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the account was created.",
            "format": "date-time"
          },
          "memberCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Number of members in the account.",
            "format": "int32"
          },
          "instanceCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Number of instances owned by the account.",
            "format": "int32"
          }
        },
        "description": "Represents an account in API responses."
      },
      "AddAccountMemberRequest": {
        "required": [
          "userId"
        ],
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "description": "The user ID to add."
          },
          "role": {
            "type": "string",
            "description": "Account role to assign (Admin, Manager, Viewer). Defaults to Viewer.",
            "default": "Viewer"
          }
        },
        "description": "Request body for adding a member to an account by user ID."
      },
      "AnnouncementData": {
        "required": [
          "timestamp",
          "text"
        ],
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "description": "Timestamp of the announcement.",
            "format": "date-time"
          },
          "text": {
            "type": "string",
            "description": "Announcement text content."
          },
          "category": {
            "type": "string",
            "description": "Optional category (e.g. \"Penalty\", \"Track Status\").",
            "default": ""
          }
        },
        "description": "A race control or event announcement."
      },
      "ApiKeyCreatedResponse": {
        "required": [
          "id",
          "label",
          "keyPrefix",
          "instanceSlugs",
          "createdAt",
          "expiresAt",
          "key"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the API key."
          },
          "label": {
            "type": "string",
            "description": "Human-readable label for this key."
          },
          "keyPrefix": {
            "type": "string",
            "description": "First 16 characters of the key for visual identification."
          },
          "instanceSlugs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Instance slugs this key is authorized for."
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the key was created.",
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "UTC expiration date, or `null` if the key does not expire.",
            "format": "date-time"
          },
          "key": {
            "type": "string",
            "description": "The full API key secret. <b>Only returned once at creation time.</b>\nUse this value in the `X-Api-Key` header when authenticating workers."
          }
        },
        "description": "Response returned when an API key is first created.\nThis is the only time the full key secret is returned - store it securely."
      },
      "ApiKeyResponse": {
        "required": [
          "id",
          "label",
          "keyPrefix",
          "instanceSlugs",
          "createdAt",
          "expiresAt",
          "isRevoked"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the API key."
          },
          "label": {
            "type": "string",
            "description": "Human-readable label for this key."
          },
          "keyPrefix": {
            "type": "string",
            "description": "First 16 characters of the key for visual identification."
          },
          "instanceSlugs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Instance slugs this key is authorized for."
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the key was created.",
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "UTC expiration date, or `null` if the key does not expire.",
            "format": "date-time"
          },
          "isRevoked": {
            "type": "boolean",
            "description": "Whether this key has been revoked and can no longer authenticate."
          }
        },
        "description": "Represents an API key in list responses. The full key secret is never included."
      },
      "AppDirectoryEntry": {
        "required": [
          "slug",
          "title",
          "status",
          "circuitCode",
          "trackName",
          "sessionName",
          "flag",
          "viewerCount",
          "lastActivityUtc",
          "startsAtUtc",
          "url"
        ],
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "description": "Slug of the page (`/lt/{slug}`; `live-{code}` for a collaborative session)."
          },
          "title": {
            "type": "string",
            "description": "Name of the page."
          },
          "status": {
            "type": "string",
            "description": "`live` (data in the last 10 minutes), `upcoming` (scheduled session in the next 60 days) or `recent` (data in the last 30 days)."
          },
          "circuitCode": {
            "type": [
              "null",
              "string"
            ],
            "description": "LapViz circuit code (lower case, e.g. `zolder`), null when unknown."
          },
          "trackName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Track of the live state (live pages only), null when unknown."
          },
          "sessionName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Live: group › run of the live state; upcoming: the scheduled session. Null when unknown."
          },
          "flag": {
            "type": [
              "null",
              "string"
            ],
            "description": "Track flag of the live state, enum name in lower case (`green`, `yellow`, `red`, `checkered`, `safetycar`…), null when none or not live."
          },
          "viewerCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Viewers connected to the page (live pages only).",
            "format": "int32"
          },
          "lastActivityUtc": {
            "type": [
              "null",
              "string"
            ],
            "description": "Last update of the live state (UTC), null when the page never received data.",
            "format": "date-time"
          },
          "startsAtUtc": {
            "type": [
              "null",
              "string"
            ],
            "description": "Start of the next scheduled session (UTC), if any.",
            "format": "date-time"
          },
          "url": {
            "type": "string",
            "description": "Canonical URL of the page."
          },
          "eventName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event of the live state (live pages only), null when unknown."
          },
          "accountName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Organiser (owning account) of the page; null for collaborative sessions."
          },
          "isCollaborative": {
            "type": "boolean",
            "description": "A session of the LapViz apps (lap times of the phones), not a timing system.",
            "default": false
          },
          "isDemo": {
            "type": "boolean",
            "description": "One of the permanent demo pages (returned unless `includeDemos=false`, after the real pages of the same status).",
            "default": false
          }
        },
        "description": "A public live timing page of the directory of the apps."
      },
      "AppDirectoryResponse": {
        "required": [
          "generatedAtUtc",
          "entries"
        ],
        "type": "object",
        "properties": {
          "generatedAtUtc": {
            "type": "string",
            "description": "When the list was computed (UTC).",
            "format": "date-time"
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppDirectoryEntry"
            },
            "description": "Live pages first (most recent activity first), then upcoming (soonest first), then recently active."
          }
        },
        "description": "Response of `GET /api/directory`."
      },
      "AuthResponse": {
        "required": [
          "token",
          "email",
          "displayName"
        ],
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "A JWT bearer token valid for 30 days. Use in the `Authorization: Bearer {token}` header."
          },
          "email": {
            "type": "string",
            "description": "The authenticated user's email address."
          },
          "displayName": {
            "type": "string",
            "description": "The authenticated user's display name."
          }
        },
        "description": "Response returned after successful authentication (login or registration)."
      },
      "CreateAccountRequest": {
        "required": [
          "slug",
          "displayName"
        ],
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "description": "URL-safe identifier. Must be 2-64 characters, lowercase alphanumeric and hyphens."
          },
          "displayName": {
            "type": "string",
            "description": "Human-readable name for the account."
          }
        },
        "description": "Request body for creating a new account."
      },
      "CreateApiKeyRequest": {
        "required": [
          "label",
          "instanceSlugs"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "A human-readable label to identify this key (e.g. \"Production Worker\")."
          },
          "instanceSlugs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Array of instance slugs this key is authorized to push data to.\nAt least one slug is required. The user must have Admin or Manager role in the account(s) that own the instances."
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional UTC expiration date. After this date the key is no longer valid.\nIf `null`, the key does not expire (but can still be revoked).",
            "format": "date-time"
          }
        },
        "description": "Request body for creating an API key that grants worker access to one or more instances."
      },
      "CreateInstanceRequest": {
        "required": [
          "slug",
          "displayName",
          "accountId"
        ],
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "description": "URL-safe identifier (e.g. `ridgeway-mx-series`). Must be 3-64 characters,\nlowercase alphanumeric and hyphens only, with no leading or trailing hyphens.\nPattern: `^[a-z0-9][a-z0-9\\-]{1,62}[a-z0-9]$`"
          },
          "displayName": {
            "type": "string",
            "description": "Human-readable name for the instance (e.g. \"Ridgeway MX Series\")."
          },
          "accountId": {
            "type": "string",
            "description": "The ID of the account this instance belongs to."
          }
        },
        "description": "Request body for creating a new live timing instance."
      },
      "DriverLapHistory": {
        "type": "object",
        "properties": {
          "number": {
            "type": "string",
            "description": "Racing number."
          },
          "fullName": {
            "type": "string",
            "description": "Driver's full name."
          },
          "laps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LapRecord"
            },
            "description": "All completed laps in chronological order."
          }
        },
        "description": "Complete lap history for a single driver in an archived session."
      },
      "DriverState": {
        "type": "object",
        "properties": {
          "number": {
            "type": "string",
            "description": "Racing number (e.g. \"42\")."
          },
          "fullName": {
            "type": "string",
            "description": "Driver's full name."
          },
          "className": {
            "type": "string",
            "description": "Optional class/category label for the driver (provider-specific)."
          },
          "lastName": {
            "type": "string",
            "description": "Driver's last name (used for compact displays)."
          },
          "country": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code (e.g. \"DE\", \"US\")."
          },
          "position": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Current position in the classification.",
            "format": "int32"
          },
          "startPosition": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Grid/starting position.",
            "format": "int32"
          },
          "positionChange": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Positions gained (+) or lost (−) since the start.",
            "format": "int32"
          },
          "laps": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Number of completed laps.",
            "format": "int32"
          },
          "lastTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Most recent lap time."
          },
          "bestTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Personal best lap time in this session."
          },
          "speedKph": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Current speed in km/h, when provided by the timing source.",
            "format": "double"
          },
          "sectorTimes": {
            "type": "array",
            "items": {
              "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
              "type": [
                "null",
                "string"
              ]
            },
            "description": "Current/latest sector times, indexed by sector number."
          },
          "bestSectorTimes": {
            "type": "array",
            "items": {
              "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
              "type": [
                "null",
                "string"
              ]
            },
            "description": "Personal best sector times, indexed by sector number."
          },
          "isSectorOverallBest": {
            "type": "array",
            "items": {
              "type": "boolean"
            },
            "description": "Per-sector flag: `true` when the sector time is the session overall best."
          },
          "isSectorPersonalBest": {
            "type": "array",
            "items": {
              "type": "boolean"
            },
            "description": "Per-sector flag: `true` when the sector time is a personal best."
          },
          "isLastLapOverallBest": {
            "type": "boolean",
            "description": "`true` when the last lap time is the session overall best."
          },
          "isLastLapPersonalBest": {
            "type": "boolean",
            "description": "`true` when the last lap time is a personal best."
          },
          "isBestTimeOverallBest": {
            "type": "boolean",
            "description": "`true` when this driver holds the session best lap time."
          },
          "hasFinished": {
            "type": "boolean",
            "description": "`true` when the driver has crossed the finish line (race only)."
          },
          "status": {
            "description": "Driver racing status.",
            "$ref": "#/components/schemas/RaceEntryStatus"
          },
          "gap": {
            "type": "string",
            "description": "Gap to the leader as a display string (e.g. \"+12.345\" or \"+1 Lap\")."
          },
          "interval": {
            "type": "string",
            "description": "Interval to the car ahead as a display string (e.g. \"+1.234\")."
          },
          "intervalTrend": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Interval trend: -1 = closing (threat), 0 = stable, 1 = opening (safe).",
            "format": "int32"
          },
          "comment": {
            "type": [
              "null",
              "string"
            ],
            "description": "Remark of the timing on this driver's result in the current session, as published (trimmed, at most\nint DriverNotices.MaxCommentLength characters) by the timing source, typically a time\npenalty such as `5 sec`. Null when none (omitted from the JSON, absent from older archives). Shown as a\ndriver notice (DriverNotice? DriverNotices.FromComment(string driverNumber, string? comment))."
          },
          "lastCrossingUtc": {
            "type": [
              "null",
              "string"
            ],
            "description": "UTC time of the driver's latest timing line crossing in this session (the DateTime RaceEvent.Timestamp of\nits latest SectorCompletedEvent or LapCompletedEvent), stamped by\nLineCrossingTracker. Lets a viewer who joins (or reloads) resume the track progress bar at the\nfraction a viewer who stayed sees. Null when unknown (omitted from the JSON, absent from older states).",
            "format": "date-time"
          },
          "lastCrossingSectors": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Sectors of the current lap completed at DateTime? DriverState.LastCrossingUtc: 0 = finish line (a lap was completed),\nk = end of sector k (1-based, i.e. int SectorCompletedEvent.SectorIndex + 1). Null when unknown.",
            "format": "int32"
          }
        },
        "description": "Current state of a single driver/rider in the session."
      },
      "FullStateEvent": {
        "required": [
          "state"
        ],
        "type": "object",
        "properties": {
          "state": {
            "description": "The complete race state.",
            "$ref": "#/components/schemas/RaceState"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "Complete race state snapshot. Sent periodically and on initial connection.\nContains all drivers, session info, announcements, and links."
      },
      "InstanceAccessInfo": {
        "required": [
          "requiresPassword",
          "passwordVersion"
        ],
        "type": "object",
        "properties": {
          "requiresPassword": {
            "type": "boolean",
            "description": "Whether a password must be entered to view this instance."
          },
          "passwordVersion": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Current password version. Clients compare this to their stored version to detect changes.",
            "format": "int32"
          },
          "circuitCode": {
            "type": [
              "null",
              "string"
            ],
            "description": "LapViz circuit code of the instance when known (set on the instance, or matched from the track name of a source-fed instance), only once the caller may view it: the live page links to the circuit on LapViz."
          },
          "shareUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Canonical URL of the live timing page (share button), once the caller may view it."
          },
          "resultsUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Canonical URL of the results index of the instance (`{ResultsUrl}/{historyId}`: an archived session), once the caller may view it."
          },
          "isViewableByAnyone": {
            "type": "boolean",
            "description": "True for a public instance without password: anyone can open a shared link, and the Open Graph images (`/lt/{slug}/og.png`, `/lt/{slug}/results/{id}/og.png`) exist.",
            "default": false
          },
          "branding": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Header (logo/text with its link) and sponsors of the instance, only once the caller may view it; null when none is set.",
                "$ref": "#/components/schemas/InstanceBranding"
              }
            ]
          },
          "canManage": {
            "type": "boolean",
            "description": "True when the signed-in caller manages the instance (SuperAdmin, or Manager/Admin of its account): the live page links to the broadcast overlay control room.",
            "default": false
          },
          "isStopwatchSession": {
            "type": "boolean",
            "description": "True for a session timed with the LapViz Stopwatch (a collaborative session, not the public session of a circuit, which the lap timer app feeds): the live page links to the Stopwatch.",
            "default": false
          },
          "vehicleCategory": {
            "type": [
              "null",
              "string"
            ],
            "description": "Vehicle category of the instance (name of `VehicleCategory`: Karting, Car, SingleSeater, Motorcycle, Motocross, Rallycross, Other) when chosen in its settings, once the caller may view it: the 3D track map picks its models from it."
          }
        },
        "description": "Public information about an instance's access requirements."
      },
      "InstanceBranding": {
        "required": [
          "text",
          "linkUrl",
          "logoUrl",
          "logoWidth",
          "logoHeight",
          "sponsors"
        ],
        "type": "object",
        "properties": {
          "text": {
            "type": [
              "null",
              "string"
            ],
            "description": "Header text, or null."
          },
          "linkUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Link of the header (absolute http(s) URL), or null."
          },
          "logoUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Header logo (site-relative, `/brand/{id}.png`), or null."
          },
          "logoWidth": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Width of the logo image in pixels (2× its display size), 0 without logo.",
            "format": "int32"
          },
          "logoHeight": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Height of the logo image in pixels, 0 without logo.",
            "format": "int32"
          },
          "sponsors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InstanceSponsorInfo"
            },
            "description": "Sponsors in display order."
          },
          "hasHeader": {
            "type": "boolean",
            "description": "True when there is a header to show (logo or text)."
          }
        },
        "description": "Branding of an instance, set by its organizer: a header (championship, organizer or sponsor) and the sponsors band\nat the bottom of its pages."
      },
      "InstanceResponse": {
        "required": [
          "slug",
          "displayName",
          "isLive",
          "createdAt"
        ],
        "type": "object",
        "properties": {
          "slug": {
            "type": "string",
            "description": "The unique URL-safe identifier for this instance."
          },
          "displayName": {
            "type": "string",
            "description": "The human-readable name of the instance."
          },
          "isLive": {
            "type": "boolean",
            "description": "Whether a worker is currently pushing live data to this instance."
          },
          "createdAt": {
            "type": "string",
            "description": "UTC timestamp of when the instance was created.",
            "format": "date-time"
          }
        },
        "description": "Represents a live timing instance in API responses."
      },
      "InstanceSponsorInfo": {
        "required": [
          "name",
          "linkUrl",
          "logoUrl"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (alternative text of the logo, or the text shown without logo)."
          },
          "linkUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Link (absolute http(s) URL), or null."
          },
          "logoUrl": {
            "type": [
              "null",
              "string"
            ],
            "description": "Logo (site-relative, `/brand/{id}.png`), or null."
          }
        },
        "description": "A sponsor of an instance."
      },
      "InviteAccountMemberRequest": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "Email address of the user to invite."
          },
          "role": {
            "type": "string",
            "description": "Account role to assign (Admin, Manager, Viewer). Defaults to Viewer.",
            "default": "Viewer"
          }
        },
        "description": "Request body for inviting a user to an account by email."
      },
      "LapRecord": {
        "type": "object",
        "properties": {
          "lapNumber": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Lap number.",
            "format": "int32"
          },
          "lapTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Total lap time."
          },
          "sectorTimes": {
            "type": "array",
            "items": {
              "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
              "type": [
                "null",
                "string"
              ]
            },
            "description": "Sector times for this lap, indexed by sector number."
          },
          "position": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Driver's position at the end of this lap.",
            "format": "int32"
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp when this lap was completed.",
            "format": "date-time"
          }
        },
        "description": "A single lap record with sector breakdown, used in session archives."
      },
      "LinkData": {
        "required": [
          "label",
          "url"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "Display text for the link."
          },
          "url": {
            "type": "string",
            "description": "Target URL."
          }
        },
        "description": "An external link associated with an event."
      },
      "LoginRequest": {
        "required": [
          "email",
          "password"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The registered email address."
          },
          "password": {
            "type": "string",
            "description": "The user's password."
          }
        },
        "description": "Request body for user login."
      },
      "NotificationType": {
        "type": "integer",
        "description": "Types of session notifications that can be sent to subscribers."
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "RaceEntryStatus": {
        "type": "integer",
        "description": "Racing status of a competitor in a session."
      },
      "RaceEvent": {
        "required": [
          "$type"
        ],
        "type": "object",
        "anyOf": [
          {
            "$ref": "#/components/schemas/RaceEventSectorCompletedEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventLapCompletedEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventPositionChangeEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventBestLapEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventBestSectorEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventFlagChangeEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventSessionInfoUpdateEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventFullStateEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventAnnouncementEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventViewerCountUpdateEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventSessionNotificationEvent"
          },
          {
            "$ref": "#/components/schemas/RaceEventSessionArchiveEvent"
          }
        ],
        "description": "Base class for all race events. Uses JSON polymorphism with a `$type` discriminator.\nEvents are broadcast in real-time via SignalR and the REST API.",
        "discriminator": {
          "propertyName": "$type",
          "mapping": {
            "SectorCompleted": "#/components/schemas/RaceEventSectorCompletedEvent",
            "LapCompleted": "#/components/schemas/RaceEventLapCompletedEvent",
            "PositionChange": "#/components/schemas/RaceEventPositionChangeEvent",
            "BestLap": "#/components/schemas/RaceEventBestLapEvent",
            "BestSector": "#/components/schemas/RaceEventBestSectorEvent",
            "FlagChange": "#/components/schemas/RaceEventFlagChangeEvent",
            "SessionInfoUpdate": "#/components/schemas/RaceEventSessionInfoUpdateEvent",
            "FullState": "#/components/schemas/RaceEventFullStateEvent",
            "Announcement": "#/components/schemas/RaceEventAnnouncementEvent",
            "ViewerCountUpdate": "#/components/schemas/RaceEventViewerCountUpdateEvent",
            "SessionNotification": "#/components/schemas/RaceEventSessionNotificationEvent",
            "SessionArchive": "#/components/schemas/RaceEventSessionArchiveEvent"
          }
        }
      },
      "RaceEventAnnouncementEvent": {
        "required": [
          "announcementTimestamp",
          "text"
        ],
        "properties": {
          "$type": {
            "enum": [
              "Announcement"
            ],
            "type": "string"
          },
          "announcementTimestamp": {
            "type": "string",
            "description": "Timestamp of the announcement.",
            "format": "date-time"
          },
          "text": {
            "type": "string",
            "description": "Announcement text content."
          },
          "category": {
            "type": "string",
            "description": "Optional category (e.g. \"Penalty\").",
            "default": ""
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A race control or event announcement was issued."
      },
      "RaceEventBestLapEvent": {
        "required": [
          "driverNumber",
          "driverName",
          "lapTime",
          "lapNumber"
        ],
        "properties": {
          "$type": {
            "enum": [
              "BestLap"
            ],
            "type": "string"
          },
          "driverNumber": {
            "type": "string",
            "description": "Racing number of the driver who set the best lap."
          },
          "driverName": {
            "type": "string",
            "description": "Display name of the driver."
          },
          "lapTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "The new best lap time."
          },
          "lapNumber": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Lap number on which the best time was set.",
            "format": "int32"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A new session overall best lap time was set."
      },
      "RaceEventBestSectorEvent": {
        "required": [
          "driverNumber",
          "driverName",
          "sectorIndex",
          "sectorTime"
        ],
        "properties": {
          "$type": {
            "enum": [
              "BestSector"
            ],
            "type": "string"
          },
          "driverNumber": {
            "type": "string",
            "description": "Racing number of the driver who set the best sector."
          },
          "driverName": {
            "type": "string",
            "description": "Display name of the driver."
          },
          "sectorIndex": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Zero-based sector index.",
            "format": "int32"
          },
          "sectorTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "The new best sector time."
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A new session overall best sector time was set."
      },
      "RaceEventFlagChangeEvent": {
        "required": [
          "oldFlag",
          "newFlag"
        ],
        "properties": {
          "$type": {
            "enum": [
              "FlagChange"
            ],
            "type": "string"
          },
          "oldFlag": {
            "description": "Previous flag status.",
            "$ref": "#/components/schemas/RaceFlag"
          },
          "newFlag": {
            "description": "New flag status.",
            "$ref": "#/components/schemas/RaceFlag"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "The track flag status changed (e.g. Green → Yellow)."
      },
      "RaceEventFullStateEvent": {
        "required": [
          "state"
        ],
        "properties": {
          "$type": {
            "enum": [
              "FullState"
            ],
            "type": "string"
          },
          "state": {
            "description": "The complete race state.",
            "$ref": "#/components/schemas/RaceState"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "Complete race state snapshot. Sent periodically and on initial connection.\nContains all drivers, session info, announcements, and links."
      },
      "RaceEventLapCompletedEvent": {
        "required": [
          "driverNumber",
          "driverName",
          "lapNumber",
          "lapTime",
          "isPersonalBest",
          "isOverallBest",
          "position"
        ],
        "properties": {
          "$type": {
            "enum": [
              "LapCompleted"
            ],
            "type": "string"
          },
          "driverNumber": {
            "type": "string",
            "description": "Racing number of the driver."
          },
          "driverName": {
            "type": "string",
            "description": "Display name of the driver."
          },
          "lapNumber": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Lap number that was completed.",
            "format": "int32"
          },
          "lapTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Lap time."
          },
          "isPersonalBest": {
            "type": "boolean",
            "description": "Whether this is the driver's personal best lap time."
          },
          "isOverallBest": {
            "type": "boolean",
            "description": "Whether this is the session overall best lap time."
          },
          "position": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Driver's position after completing the lap.",
            "format": "int32"
          },
          "gap": {
            "type": "string",
            "description": "Gap to leader.",
            "default": ""
          },
          "interval": {
            "type": "string",
            "description": "Interval to car ahead.",
            "default": ""
          },
          "hasFinished": {
            "type": "boolean",
            "description": "Whether the driver has crossed the finish line (race completed).",
            "default": false
          },
          "positionChange": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Positions gained (+) or lost (−) since start.",
            "format": "int32",
            "default": 0
          },
          "startPosition": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Driver's grid/starting position.",
            "format": "int32",
            "default": 0
          },
          "intervalTrend": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Interval trend: −1 = gap closing (threat), 0 = stable, +1 = gap opening (safe).",
            "format": "int32",
            "default": 0
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A driver completed a lap."
      },
      "RaceEventPositionChangeEvent": {
        "required": [
          "driverNumber",
          "driverName",
          "oldPosition",
          "newPosition"
        ],
        "properties": {
          "$type": {
            "enum": [
              "PositionChange"
            ],
            "type": "string"
          },
          "driverNumber": {
            "type": "string",
            "description": "Racing number of the driver."
          },
          "driverName": {
            "type": "string",
            "description": "Display name of the driver."
          },
          "oldPosition": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Previous position.",
            "format": "int32"
          },
          "newPosition": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "New position.",
            "format": "int32"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A driver's position changed in the classification."
      },
      "RaceEventSectorCompletedEvent": {
        "required": [
          "driverNumber",
          "driverName",
          "sectorIndex",
          "sectorTime",
          "isPersonalBest",
          "isOverallBest"
        ],
        "properties": {
          "$type": {
            "enum": [
              "SectorCompleted"
            ],
            "type": "string"
          },
          "driverNumber": {
            "type": "string",
            "description": "Racing number of the driver."
          },
          "driverName": {
            "type": "string",
            "description": "Display name of the driver."
          },
          "sectorIndex": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Zero-based sector index (0 = S1, 1 = S2, etc.).",
            "format": "int32"
          },
          "sectorTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Sector time."
          },
          "isPersonalBest": {
            "type": "boolean",
            "description": "Whether this is the driver's personal best for this sector."
          },
          "isOverallBest": {
            "type": "boolean",
            "description": "Whether this is the session overall best for this sector."
          },
          "position": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Driver's current position.",
            "format": "int32",
            "default": 0
          },
          "positionChange": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Positions gained (+) or lost (−) since start.",
            "format": "int32",
            "default": 0
          },
          "gap": {
            "type": "string",
            "description": "Gap to leader.",
            "default": ""
          },
          "interval": {
            "type": "string",
            "description": "Interval to car ahead.",
            "default": ""
          },
          "intervalTrend": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Interval trend: −1 = gap closing (threat), 0 = stable, +1 = gap opening (safe).",
            "format": "int32",
            "default": 0
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A driver completed a timing sector."
      },
      "RaceEventSessionArchiveEvent": {
        "required": [
          "session",
          "driverHistories"
        ],
        "properties": {
          "$type": {
            "enum": [
              "SessionArchive"
            ],
            "type": "string"
          },
          "session": {
            "$ref": "#/components/schemas/SessionInfo"
          },
          "driverHistories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DriverLapHistory"
            }
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "Detailed session archive containing full lap/sector history for all drivers.\nSent by the worker when a session ends (session change or idle timeout)."
      },
      "RaceEventSessionInfoUpdateEvent": {
        "required": [
          "session"
        ],
        "properties": {
          "$type": {
            "enum": [
              "SessionInfoUpdate"
            ],
            "type": "string"
          },
          "session": {
            "description": "The updated session info.",
            "$ref": "#/components/schemas/SessionInfo"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "Session metadata was updated (e.g. time remaining, lap count)."
      },
      "RaceEventSessionNotificationEvent": {
        "required": [
          "notificationType",
          "instanceSlug",
          "title",
          "message"
        ],
        "properties": {
          "$type": {
            "enum": [
              "SessionNotification"
            ],
            "type": "string"
          },
          "notificationType": {
            "description": "The type of notification.",
            "$ref": "#/components/schemas/NotificationType"
          },
          "instanceSlug": {
            "type": "string",
            "description": "The instance this notification belongs to."
          },
          "title": {
            "type": "string",
            "description": "Short notification title."
          },
          "message": {
            "type": "string",
            "description": "Notification body text."
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "A session notification event (e.g. session started, drivers on track).\nUsed for push notifications and in-app toasts."
      },
      "RaceEventViewerCountUpdateEvent": {
        "required": [
          "viewerCount"
        ],
        "properties": {
          "$type": {
            "enum": [
              "ViewerCountUpdate"
            ],
            "type": "string"
          },
          "viewerCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Current number of connected viewers.",
            "format": "int32"
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "The number of connected viewers changed."
      },
      "RaceFlag": {
        "type": "integer",
        "description": "Track flag status during a race session."
      },
      "RaceRunType": {
        "type": "integer",
        "description": "Type of a session or run within an event."
      },
      "RaceState": {
        "type": "object",
        "properties": {
          "session": {
            "description": "Current session metadata.",
            "$ref": "#/components/schemas/SessionInfo"
          },
          "drivers": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/DriverState"
            },
            "description": "All drivers keyed by their racing number."
          },
          "announcements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnnouncementData"
            },
            "description": "Race control announcements (e.g. penalties, track status changes)."
          },
          "links": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkData"
            },
            "description": "External links related to this event (e.g. results PDFs, event website)."
          },
          "lastUpdated": {
            "type": "string",
            "description": "UTC timestamp of the last update to this state.",
            "format": "date-time"
          }
        },
        "description": "Complete race state snapshot containing session info, all drivers, announcements and links.\nPushed periodically by workers and cached server-side for new client connections."
      },
      "RegisterRequest": {
        "required": [
          "email",
          "displayName",
          "password"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "description": "The user's email address. Must be unique across the platform."
          },
          "displayName": {
            "type": "string",
            "description": "The user's display name shown in the UI and race data."
          },
          "password": {
            "type": "string",
            "description": "The user's password. Stored as a BCrypt hash."
          },
          "inviteToken": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional invite token. Required unless the caller is a SuperAdmin."
          }
        },
        "description": "Request body for user registration."
      },
      "SessionArchiveEvent": {
        "required": [
          "session",
          "driverHistories"
        ],
        "type": "object",
        "properties": {
          "session": {
            "$ref": "#/components/schemas/SessionInfo"
          },
          "driverHistories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DriverLapHistory"
            }
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "Event type name derived from the concrete class (e.g. \"SectorCompleted\")."
          },
          "timestamp": {
            "type": "string",
            "description": "UTC timestamp of when the event was created.",
            "format": "date-time"
          }
        },
        "description": "Detailed session archive containing full lap/sector history for all drivers.\nSent by the worker when a session ends (session change or idle timeout)."
      },
      "SessionHistoryEntry": {
        "required": [
          "id",
          "eventName",
          "groupName",
          "runName",
          "archivedAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "History entry ID (use to fetch full state)."
          },
          "eventName": {
            "type": "string",
            "description": "Event name at the time."
          },
          "groupName": {
            "type": "string",
            "description": "Class/group name."
          },
          "runName": {
            "type": "string",
            "description": "Session/run name."
          },
          "archivedAt": {
            "type": "string",
            "description": "When the session was archived (UTC).",
            "format": "date-time"
          },
          "hasDetail": {
            "type": "boolean",
            "description": "Whether detailed lap history is available for this session.",
            "default": false
          }
        },
        "description": "Summary of an archived session for the history list endpoint."
      },
      "SessionInfo": {
        "type": "object",
        "properties": {
          "trackName": {
            "type": "string",
            "description": "Name of the track/circuit (e.g. \"Möggers\")."
          },
          "trackLength": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "number",
              "string"
            ],
            "description": "Track length in kilometers.",
            "format": "double"
          },
          "eventName": {
            "type": "string",
            "description": "Name of the event (e.g. \"Ridgeway MX Series 2025\")."
          },
          "groupName": {
            "type": "string",
            "description": "Name of the class/group (e.g. \"MX2\")."
          },
          "runName": {
            "type": "string",
            "description": "Name of the current run/session (e.g. \"Race 1\")."
          },
          "runType": {
            "description": "Type of the current session (Practice, Qualifying, Race, etc.).",
            "$ref": "#/components/schemas/RaceRunType"
          },
          "flag": {
            "description": "Current track flag status.",
            "$ref": "#/components/schemas/RaceFlag"
          },
          "raceTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Elapsed race/session time."
          },
          "timeToGo": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Remaining time. Null if lap-based."
          },
          "timeOfDay": {
            "type": [
              "null",
              "string"
            ],
            "description": "Current local time of day at the track.",
            "format": "date-time"
          },
          "laps": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Current lap number of the leader.",
            "format": "int32"
          },
          "totalLaps": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Total laps in the race. 0 if time-based.",
            "format": "int32"
          },
          "bestLapTime": {
            "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
            "type": [
              "null",
              "string"
            ],
            "description": "Overall best lap time in the session."
          },
          "bestLapByNumber": {
            "type": "string",
            "description": "Racing number of the driver who set the overall best lap."
          },
          "bestLapBy": {
            "type": "string",
            "description": "Display name of the driver who set the overall best lap."
          },
          "sectorCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Number of timing sectors on the track (typically 3).",
            "format": "int32"
          },
          "bestSectorTimes": {
            "type": "array",
            "items": {
              "pattern": "^-?(\\d+\\.)?\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,7})?$",
              "type": [
                "null",
                "string"
              ]
            },
            "description": "Overall best sector times in the session, indexed by sector."
          },
          "viewerCount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "Number of currently connected viewers.",
            "format": "int32"
          },
          "weather": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Current weather conditions at the track, if available.",
                "$ref": "#/components/schemas/WeatherInfo"
              }
            ]
          },
          "sourceType": {
            "type": "string",
            "description": "Source type that provides the timing data (identifier of the source integration)."
          },
          "copyright": {
            "type": "string",
            "description": "Copyright notice for the timing data provider."
          },
          "circuitCode": {
            "type": [
              "null",
              "string"
            ],
            "description": "LapViz circuit code (lower case, `lapviz.com/circuit/{code}`) of the live run, null when unknown. Not sent\nby the timing sources: the App stamps it when the run starts (scheduled session, instance circuit, track name)\nand keeps it for the run, a manager of the instance may correct it. Omitted from both JSON formats when null,\nabsent from the states and archives written before it existed."
          }
        },
        "description": "Current session metadata: track info, timing, flags, weather, and overall bests.\nUpdated by the worker on each timing cycle. The names read null as \"\" (the worker sends null when the\nsource has none, e.g. an event without class): they are compared, displayed and archived in NOT NULL columns."
      },
      "TemperatureUnit": {
        "type": "integer",
        "description": "Units for expressing temperature values."
      },
      "TrackCondition": {
        "type": "integer",
        "description": "Track surface condition."
      },
      "UpdateAccountMemberRoleRequest": {
        "required": [
          "role"
        ],
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "description": "New account role (Admin, Manager, Viewer)."
          }
        },
        "description": "Request body for updating a member's role."
      },
      "UpdateAccountRequest": {
        "required": [
          "displayName"
        ],
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string",
            "description": "Updated display name."
          }
        },
        "description": "Request body for updating an account."
      },
      "VerifyInstanceAccessResponse": {
        "required": [
          "passwordVersion",
          "accessToken",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "passwordVersion": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "description": "The password version that was verified. Store this client-side.",
            "format": "int32"
          },
          "accessToken": {
            "type": [
              "null",
              "string"
            ],
            "description": "Short-lived signed token granting access to a password-protected instance. Pass it as the\n`instance_token` query parameter to the SignalR hub, and as the `X-Instance-Token` header\n(or `instance_token` query parameter) to the race data REST endpoints. Null when not required."
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "UTC expiry of AccessToken.",
            "format": "date-time"
          }
        },
        "description": "Response returned by verify-access. Superset of VerifyInstancePasswordResponse."
      },
      "VerifyInstancePasswordRequest": {
        "required": [
          "password"
        ],
        "type": "object",
        "properties": {
          "password": {
            "type": "string",
            "description": "The access password to verify."
          }
        },
        "description": "Request body for verifying an instance access password."
      },
      "WeatherInfo": {
        "type": "object",
        "properties": {
          "temperature": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Ambient temperature at the track, in the given TemperatureUnit WeatherInfo.Unit.",
            "format": "double"
          },
          "unit": {
            "description": "Unit of the double? WeatherInfo.Temperature value.",
            "$ref": "#/components/schemas/TemperatureUnit"
          },
          "humidity": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Relative humidity in percent (0–100).",
            "format": "double"
          },
          "pressure": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Atmospheric pressure in hPa (hectopascals).",
            "format": "double"
          },
          "precipitation": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Precipitation amount in millimeters per hour, if available.",
            "format": "double"
          },
          "windSpeed": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Wind speed in kilometers per hour (or the preferred unit).",
            "format": "double"
          },
          "cloudCover": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Cloud cover in percent (0–100).",
            "format": "double"
          },
          "conditions": {
            "type": "string",
            "description": "Free-text description of conditions (e.g. \"Sunny\", \"Overcast\", \"Light rain\")."
          },
          "icon": {
            "type": "string",
            "description": "Identifier for a weather icon (e.g. \"sunny.png\" or a weather API icon code)."
          },
          "windDirection": {
            "type": "string",
            "description": "Wind direction as a compass bearing (e.g. \"NW\", \"SSE\")."
          },
          "feelsLike": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "\"Feels like\" temperature, accounting for wind chill or heat index.",
            "format": "double"
          },
          "trackTemperature": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Track surface temperature, if available.",
            "format": "double"
          },
          "trackCondition": {
            "description": "Track surface condition.",
            "$ref": "#/components/schemas/TrackCondition"
          },
          "weatherCode": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Numeric weather code from the timing source or weather API.\nUsed to derive icon and description when free-text is not available.",
            "format": "int32"
          }
        },
        "description": "Represents weather conditions associated with a session.\nCan be populated from a weather API, manual input, or device sensors."
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "JWT token obtained from `POST /api/auth/login` or `POST /api/auth/register`. Valid for 24 hours by default.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "ApiKey": {
        "type": "apiKey",
        "description": "API key created via `POST /api/keys`. Used by workers to push race data to authorized instances.",
        "name": "X-Api-Key",
        "in": "header"
      }
    }
  },
  "tags": [
    {
      "name": "Accounts"
    },
    {
      "name": "Account Invites"
    },
    {
      "name": "Authentication"
    },
    {
      "name": "Directory"
    },
    {
      "name": "Instances"
    },
    {
      "name": "API Keys"
    },
    {
      "name": "Race Data"
    }
  ]
}