{
  "openapi": "3.1.0",
  "info": {
    "title": "PokerLeagueOS API",
    "version": "1.0.0",
    "description": "REST API for PokerLeagueOS: multi-tenant poker league management, designed so an AI agent can run a tournament end to end on behalf of a human.\n\n**Start here:** `POST /api/quickstart` returns a trial organization, a demo tournament, and an admin-role API key in a single call. Store the `api_key` value from the response — it is shown exactly once. Then follow `next_actions[0]` to start the clock.\n\n**Authentication.** All endpoints except `/api/quickstart`, `/api/health`, and the public read endpoints require `Authorization: Bearer <ck_live_...>`. Keys are org-scoped; requests to a different org's URLs return 404.\n\n**Agent-friendly conventions.**\n- Every error response includes `code`, `hint`, `doc_url`, and `next_actions` fields to guide the next call.\n- Mutating endpoints accept `Idempotency-Key` header — identical requests within 24h replay the cached response.\n- Rate-limit responses (429) include a `Retry-After` header.\n- A list endpoint returns a bare JSON array and a single-resource endpoint returns the resource directly. `GET /api/orgs/{slug}/api-keys` is the one exception and wraps its rows in `{ data, total }`.\n- Every request body and every response is fully typed below. The request schemas are the Zod validators the routes actually run, so a field here is a field the API accepts.\n\n**See also:** `/llms.txt` for a short reference and `/llms-full.txt` for fully worked agent workflows.",
    "contact": {
      "name": "PokerLeagueOS",
      "url": "https://pokerleagueos.com"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://pokerleagueos.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "apiKey": []
    },
    {
      "cookieAuth": []
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "tags": [
          "System"
        ],
        "summary": "Liveness probe",
        "description": "Returns 200 if the service is alive. Does not check database connectivity. Use for uptime monitoring.",
        "operationId": "get__api_health",
        "responses": {
          "200": {
            "description": "Service is alive.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "ts": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "ts"
                  ]
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/live-tournament": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Live tournament snapshot",
        "description": "Single-request snapshot of all live tournament state — clock, blinds, players, eliminations, prize pool, table stats. Designed for polling (recommended interval: 5s). Private, not-yet-started and deleted-league sessions return 404.",
        "operationId": "get__api_live_tournament",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tournament snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveTournament"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Session not found, private, not started yet (status scheduled), or its league is pending deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/clock": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public clock state",
        "description": "Read-only clock state for a session. Private, not-yet-started and deleted-league sessions return 404. The keys are camelCase; `timeRemaining` is already drift-corrected against `lastUpdatedAt` on the server.",
        "operationId": "get__api_clock",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public clock snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicClock"
                }
              }
            }
          },
          "404": {
            "description": "Session not found, private, not started yet (status scheduled), or its league is pending deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-table-assignments": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public table assignments",
        "description": "Who is sitting at which table and seat, eliminated players excluded, capped at 500. Pass `includeAll=true` for the roll call instead: every checked-in player with their seat (possibly null), elimination state, finish position, and whether they have set a PIN. Private, not-yet-started and deleted-league sessions return 404.",
        "operationId": "get__api_public_table_assignments",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "includeAll",
            "in": "query",
            "required": false,
            "description": "`true` switches to the roll call of every checked-in player.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Seats, or the roll call when `includeAll=true`.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "table_number": {
                            "type": "integer"
                          },
                          "seat_number": {
                            "type": "integer"
                          },
                          "nickname": {
                            "type": "string"
                          },
                          "roster_player_id": {
                            "type": "string",
                            "format": "uuid"
                          }
                        },
                        "required": [
                          "table_number",
                          "seat_number",
                          "nickname",
                          "roster_player_id"
                        ]
                      }
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "roster_player_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "nickname": {
                            "type": "string"
                          },
                          "is_eliminated": {
                            "type": "boolean"
                          },
                          "has_pin": {
                            "type": "boolean",
                            "description": "Whether this player has set an at-table PIN. The PIN itself is never returned."
                          },
                          "table_number": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "seat_number": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "finish_position": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "roster_player_id",
                          "nickname",
                          "is_eliminated",
                          "has_pin",
                          "table_number",
                          "seat_number",
                          "finish_position"
                        ]
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Session not found, private, not started yet (status scheduled), or its league is pending deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-player-requests": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Submit a player self-service request",
        "description": "Requires a valid PIN for `submitterId`. Files a knockout, rebuy or minigame request; both `submitterId` and `targetPlayerId` (and `eliminatedById`, when given) must already be checked into this session. `imageDataUrl` is only meaningful when `requestType` is `minigame`. The account-authenticated twin, `POST /api/orgs/{slug}/me/requests`, takes the same fields minus `sessionId`/`submitterId`/`pin` (see the Me family below).",
        "operationId": "post__api_public_player_requests",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requestType": {
                    "type": "string",
                    "enum": [
                      "knockout",
                      "rebuy",
                      "minigame"
                    ]
                  },
                  "targetPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "eliminatedById": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payload": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "imageDataUrl": {
                    "type": "string",
                    "maxLength": 220000,
                    "pattern": "^data:image\\/(jpeg|webp|png);base64,"
                  },
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "submitterId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "pin": {
                    "type": "string",
                    "pattern": "^\\d{4}$"
                  }
                },
                "required": [
                  "requestType",
                  "targetPlayerId",
                  "sessionId",
                  "submitterId",
                  "pin"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A pending request for the same target already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "duplicate": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "duplicate",
                    "message"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Request created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlayerRequest"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Invalid PIN.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Submitter is not checked into this tournament.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-player-pin": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Set or verify a player PIN",
        "description": "`set-pin` requires a matching `nickname`, which is what stops PIN-spraying across player ids, and only succeeds while no PIN is set (409 `pin_already_set` otherwise); a successful set also clears that player's verify lockout. `verify-pin` checks the 4-digit PIN. Both require the player to be checked into a non-private session that is active or paused, and both are rate-limited per player and per IP; the limiter is the only protection on a plaintext PIN.",
        "operationId": "post__api_public_player_pin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "rosterPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "pin": {
                    "type": "string",
                    "pattern": "^\\d{4}$"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "set-pin",
                      "verify-pin"
                    ]
                  },
                  "nickname": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "sessionId",
                  "rosterPlayerId",
                  "pin",
                  "action"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PIN verified.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verified": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "playerId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "nickname": {
                      "type": "string"
                    },
                    "tableNumber": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Null when the player has not been seated."
                    },
                    "seatNumber": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "verified",
                    "playerId",
                    "nickname",
                    "tableNumber",
                    "seatNumber"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "PIN set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verified": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "playerId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "nickname": {
                      "type": "string"
                    },
                    "tableNumber": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "seatNumber": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "verified",
                    "playerId",
                    "nickname",
                    "tableNumber",
                    "seatNumber"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Invalid PIN.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "`nickname_mismatch`: the nickname sent with `set-pin` is not this player's.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "`pin_already_set`. Ask the host to reset it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-cohost-invite": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Fetch the co-host handoff link aimed at this player",
        "description": "The companion's half of a targeted co-host handoff. The host creates the invite with `POST /api/orgs/{slug}/sessions/{id}/managers/handoff` naming a `rosterPlayerId`; that player's companion is nudged over Broadcast and calls this with the player's 4-digit PIN to get the `/handoff/{token}` URL. The URL is never broadcast, because the topic is public. Requires a non-private session that is active or paused; rate-limited like `public-player-pin`. Claimed members use `GET /api/orgs/{slug}/me/cohost-invite` instead.",
        "operationId": "post__api_public_cohost_invite",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "rosterPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "pin": {
                    "type": "string",
                    "pattern": "^\\d{4}$"
                  }
                },
                "required": [
                  "sessionId",
                  "rosterPlayerId",
                  "pin"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The open invite for this player.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "description": "The handoff link. Opening it while logged in makes that account a session manager."
                    },
                    "expiresAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "expiresAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "`pin_incorrect` or `pin_not_set`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Session not found or private, player not in this org, or no open invite for this player.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-feed": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public activity feed",
        "description": "The 50 most recent tournament moments (eliminations and accepted minigame results), newest first. Useful for a live commentary agent. Edge-cached for 10 seconds.",
        "operationId": "get__api_public_feed",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activity feed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "elimination",
                          "minigame"
                        ]
                      },
                      "at": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "actor_nickname": {
                        "type": "string",
                        "description": "For an elimination, the player who busted."
                      },
                      "actor_roster_player_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "target_nickname": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "Who did the knocking out, when it was not a walk-away."
                      },
                      "target_roster_player_id": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "format": "uuid"
                      },
                      "table_number": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      },
                      "label": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "The minigame's name, on a minigame row."
                      }
                    },
                    "required": [
                      "type",
                      "at",
                      "actor_nickname",
                      "actor_roster_player_id",
                      "target_nickname",
                      "target_roster_player_id",
                      "table_number",
                      "label"
                    ]
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/rsvp/{code}": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Read an RSVP invite",
        "description": "Public tournament details behind an RSVP code, plus the responses so far. Names and responses only: no email addresses. No auth.",
        "operationId": "get__api_rsvp__code_",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "RSVP code printed on the invite (uppercase, from the session's rsvp_code).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invite details.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "name": {
                          "type": "string"
                        },
                        "buy_in_amount": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "starting_stack": {
                          "type": "integer"
                        },
                        "level_duration_minutes": {
                          "type": "integer"
                        },
                        "rebuy_allowed": {
                          "type": "boolean"
                        },
                        "addon_allowed": {
                          "type": "boolean"
                        },
                        "started_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "scheduled_for": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time",
                          "description": "When a scheduled tournament is set to start; null for one set up to start now."
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "scheduled",
                            "active",
                            "paused",
                            "completed",
                            "cancelled"
                          ]
                        },
                        "org_name": {
                          "type": "string"
                        },
                        "league_slug": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "The slug of the league's public page at /league/{slug}; null when the league has turned that page off."
                        },
                        "locale": {
                          "type": "string",
                          "enum": [
                            "en",
                            "de",
                            "fr",
                            "es"
                          ]
                        },
                        "currency": {
                          "type": "string",
                          "enum": [
                            "USD",
                            "GBP",
                            "EUR"
                          ]
                        },
                        "timezone": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "buy_in_amount",
                        "starting_stack",
                        "level_duration_minutes",
                        "rebuy_allowed",
                        "addon_allowed",
                        "started_at",
                        "scheduled_for",
                        "status",
                        "org_name",
                        "league_slug",
                        "locale",
                        "currency",
                        "timezone"
                      ]
                    },
                    "rsvps": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "response": {
                            "type": "string",
                            "enum": [
                              "yes",
                              "no",
                              "maybe"
                            ]
                          },
                          "responded_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "name",
                          "response",
                          "responded_at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "session",
                    "rsvps"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Submit an RSVP",
        "description": "Records a walk-up RSVP against the code. No auth, and no roster row is required: a response from someone not on the roster is stored under the name they gave. A response with an email replaces that email's earlier one. A response without one replaces the email-less response whose `id` is sent back as `rsvp_id`; otherwise it is a new response.",
        "operationId": "post__api_rsvp__code_",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "RSVP code printed on the invite (uppercase, from the session's rsvp_code).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "response": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no",
                      "maybe"
                    ]
                  },
                  "rsvp_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "name",
                  "response"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "RSVP recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "ok",
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-claim-otp": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Request a self-claim OTP",
        "description": "Self-claim (CLAUDE.md, Members, claim path 3): the first of two steps that let a player link their own account to a roster row from the companion, without a host-sent invite. Silently checks whether `email` matches exactly one active, unclaimed roster row in the session's org and, only then, sends an 8-digit email OTP via Supabase Auth (`shouldCreateUser: true`, since claiming can create the account). The response is always the same regardless of whether a match was found or a code was sent, so the shape of the answer never reveals who is on a league's roster. Works for a session in any status, not only `active`/`paused`: claiming is the between-games credential, so the public league page can link a claim URL against last week's completed session and it still works. Rate-limited tighter than other public writes because Supabase auth mail shares one quota with password resets.",
        "operationId": "post__api_public_claim_otp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                },
                "required": [
                  "sessionId",
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Always this body, whether or not a code was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Session not found, or session is private.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-claim-complete": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Complete a self-claim",
        "description": "Self-claim (CLAUDE.md, Members, claim path 3), second step. Called after the browser has completed `verifyOtp` against the code from POST /api/public-claim-otp, so a Supabase session cookie already proves the caller's email. Matches that authenticated email against the session's org roster and links the caller's account to the one active, unclaimed roster row it finds, adding the account to the org at role \"player\" without lowering any existing role. Requires authentication (the just-established session). Like the OTP request step, this has no session-status gate: claiming works between games, keyed only on the session not being private. Fails with 404 if the session does not exist or is private, 409 `no_unique_claimable_player` if zero or more than one roster row matches, and 409 `user_already_linked_elsewhere` if the account already holds a different active roster row in this org.",
        "operationId": "post__api_public_claim_complete",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "sessionId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Claimed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "org_slug": {
                      "type": "string"
                    },
                    "nickname": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "org_slug",
                    "nickname"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Session not found, or session is private.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "No unique claimable roster row, or the account already holds a different player in this org.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-season-standings": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public season standings",
        "description": "Standings for the season the given tournament belongs to, honouring that season's best-N-of-M rule, plus `projection`: what a player would score at each possible finishing position in this session. Keyed by the live session UUID (the public access token), not by season id. `season` is null and `standings` empty when the session belongs to no season.",
        "operationId": "get__api_public_season_standings",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Standings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "season": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "year": {
                              "type": "integer"
                            },
                            "scoringConfig": {
                              "type": [
                                "object",
                                "null"
                              ],
                              "description": "`{ bestNOfM: { best, of } | null }`.",
                              "additionalProperties": true
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "year",
                            "scoringConfig"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "standings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "roster_player_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "nickname": {
                            "type": "string"
                          },
                          "games_played": {
                            "type": "integer"
                          },
                          "wins": {
                            "type": "integer"
                          },
                          "podiums": {
                            "type": "integer"
                          },
                          "total_points": {
                            "type": "integer"
                          },
                          "best_finish": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "roster_player_id",
                          "nickname",
                          "games_played",
                          "wins",
                          "podiums",
                          "total_points",
                          "best_finish"
                        ]
                      }
                    },
                    "projection": {
                      "type": "object",
                      "properties": {
                        "checkedIn": {
                          "type": "integer"
                        },
                        "remaining": {
                          "type": "integer"
                        },
                        "pointsByPosition": {
                          "type": "object",
                          "description": "Finish position (as a string key) to the points it would award in this session.",
                          "additionalProperties": {
                            "type": "integer"
                          }
                        }
                      },
                      "required": [
                        "checkedIn",
                        "remaining",
                        "pointsByPosition"
                      ]
                    },
                    "locale": {
                      "type": "string",
                      "enum": [
                        "en",
                        "de",
                        "fr",
                        "es"
                      ]
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "GBP",
                        "EUR"
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "season",
                    "standings",
                    "projection",
                    "locale",
                    "currency",
                    "timezone"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/orgs/{slug}/clock": {
      "get": {
        "tags": [
          "Clock"
        ],
        "summary": "Read authenticated clock state",
        "description": "Same shape as public clock but requires org membership and returns 403 for non-members. Read `effective_remaining`, not `time_remaining_seconds`: the stored value is only correct as of `last_updated_at`.",
        "operationId": "get__api_orgs__slug__clock",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Clock state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClockState"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Clock"
        ],
        "summary": "Control the clock",
        "description": "Start, pause, resume, advance, rewind, or adjust the tournament clock. Requires the `canControlClock` permission. Returns 409 if session is already in the target state. Rate-limited to 30 req/min per IP.",
        "operationId": "post__api_orgs__slug__clock",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClockAction"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Clock state after the action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClockState"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input — check the `hint` for which parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "You don't have `canControlClock` permission for this session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Session or clock not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Already in the target state, or another device advanced the level within the 2-second cooldown. Retry with `force: true` only behind a confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List tournaments",
        "description": "List sessions for this org, newest first. Filter by `status` (scheduled/active/paused/completed/cancelled). Returns a bare array, capped at 50 unfiltered and 100 filtered.",
        "operationId": "get__api_orgs__slug__sessions",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status.",
            "schema": {
              "type": "string",
              "enum": [
                "scheduled",
                "active",
                "paused",
                "completed",
                "cancelled"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Session"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Create a tournament",
        "description": "Creates a new tournament session. Most fields optional; sensible defaults apply (15-level blind structure, 15-minute levels). Set `is_private: true` to keep it off every public surface (TV clock, player companion, all `/api/public-*` endpoints return 404 for it). Set `is_championship: true` (only meaningful with a `season_id`) to link it to the season without counting it toward season points: it still shows in season history and can earn badges. Set `scheduled_for` (ISO datetime) to create it `scheduled` instead of `active` for a future date; the host starting the game (`PATCH` status to `active`) is the only thing that moves it to `active`. Omitting `scheduled_for` is unchanged: `active` with `started_at` set to now.",
        "operationId": "post__api_orgs__slug__sessions",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "buy_in_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "starting_stack": {
                    "default": 3500,
                    "type": "integer",
                    "minimum": 100
                  },
                  "level_duration_minutes": {
                    "default": 15,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 120
                  },
                  "blinds_config": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 200
                        },
                        "small_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "big_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "ante": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "duration_minutes": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 600
                        },
                        "is_break": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "level",
                        "small_blind",
                        "big_blind"
                      ]
                    }
                  },
                  "rebuy_allowed": {
                    "default": false,
                    "type": "boolean"
                  },
                  "rebuy_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_rebuys": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_allowed": {
                    "default": false,
                    "type": "boolean"
                  },
                  "addon_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_structure": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "positions": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "position": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 1000
                                },
                                "percentage": {
                                  "default": 0,
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 100
                                },
                                "amount": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "position"
                              ]
                            }
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "rows": {
                                "maxItems": 500,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "players": {
                                      "type": "integer",
                                      "minimum": 2,
                                      "maximum": 500
                                    },
                                    "prize_pool": {
                                      "type": "number",
                                      "minimum": 0
                                    },
                                    "positions": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "position": {
                                            "type": "integer",
                                            "minimum": 1
                                          },
                                          "amount": {
                                            "type": "number",
                                            "minimum": 0
                                          }
                                        },
                                        "required": [
                                          "position",
                                          "amount"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "players",
                                    "prize_pool",
                                    "positions"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "name",
                              "rows"
                            ]
                          }
                        },
                        "required": [
                          "positions"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "prize_pool_deduction": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "manual_prize_pool": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "table_names": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_players_per_table": {
                    "default": 10,
                    "type": "integer",
                    "minimum": 6,
                    "maximum": 12
                  },
                  "planned_table_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expected_player_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "standard",
                          "progressive"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "minigames": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "tally",
                                    "ranked",
                                    "judged"
                                  ]
                                }
                              },
                              "required": [
                                "name"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "seating_mode": {
                    "default": "all_at_once",
                    "type": "string",
                    "enum": [
                      "on_pay",
                      "all_at_once",
                      "manual"
                    ]
                  },
                  "record_to_career": {
                    "default": true,
                    "type": "boolean"
                  },
                  "is_private": {
                    "default": false,
                    "type": "boolean"
                  },
                  "is_championship": {
                    "default": false,
                    "type": "boolean"
                  },
                  "complexity": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "casual",
                          "pro"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "season_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "color": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 40
                            },
                            "denomination": {
                              "type": "number"
                            },
                            "quantity": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000
                            }
                          },
                          "required": [
                            "color",
                            "denomination",
                            "quantity"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_distribution": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "denomination": {
                              "type": "number"
                            },
                            "count": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 10000
                            }
                          },
                          "required": [
                            "denomination",
                            "count"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "blind_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "point_chart_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "scheduled_for": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Get a tournament",
        "description": "Full session detail including blind structure and payout structure.",
        "operationId": "get__api_orgs__slug__sessions__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Sessions"
        ],
        "summary": "Update a tournament",
        "description": "Partial update. Only fields present in the body are changed. `is_private` toggles every public surface for this tournament on or off and is recorded on the session timeline. `is_championship` toggles whether this session is the season championship — linked to its season but excluded from season points. `status: \"active\"` on a `scheduled` session starts it for real: `started_at` is re-stamped to now and the clock's `last_updated_at` is reset, so it begins at level 1 with no elapsed time regardless of how long it sat scheduled. A `scheduled` session only accepts `status: \"active\"` or `status: \"cancelled\"`; any other status value is rejected with a clear message rather than being applied early. Sending `status: \"scheduled\"` is always rejected, since a session becomes scheduled only at creation. `scheduled_for` can be changed only while the session is still `scheduled`; once it starts, when it was going to start is no longer editable.",
        "operationId": "patch__api_orgs__slug__sessions__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "scheduled",
                      "active",
                      "paused",
                      "completed",
                      "cancelled"
                    ]
                  },
                  "table_names": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dealer_draws": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_structure": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "positions": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "position": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 1000
                                },
                                "percentage": {
                                  "default": 0,
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 100
                                },
                                "amount": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "position"
                              ]
                            }
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "rows": {
                                "maxItems": 500,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "players": {
                                      "type": "integer",
                                      "minimum": 2,
                                      "maximum": 500
                                    },
                                    "prize_pool": {
                                      "type": "number",
                                      "minimum": 0
                                    },
                                    "positions": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "position": {
                                            "type": "integer",
                                            "minimum": 1
                                          },
                                          "amount": {
                                            "type": "number",
                                            "minimum": 0
                                          }
                                        },
                                        "required": [
                                          "position",
                                          "amount"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "players",
                                    "prize_pool",
                                    "positions"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "name",
                              "rows"
                            ]
                          }
                        },
                        "required": [
                          "positions"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "minigames": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "active": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "name",
                                "active"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "seating_mode": {
                    "type": "string",
                    "enum": [
                      "on_pay",
                      "all_at_once",
                      "manual"
                    ]
                  },
                  "planned_table_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expected_player_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "manual_prize_pool": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "prize_pool_deduction": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "is_private": {
                    "type": "boolean"
                  },
                  "is_championship": {
                    "type": "boolean"
                  },
                  "scheduled_for": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Delete a tournament",
        "description": "Hard delete. Cascades to check-ins, eliminations, clock state, table assignments. Irreversible.",
        "operationId": "delete__api_orgs__slug__sessions__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/clone": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Clone a tournament for re-run",
        "description": "Creates a new session copying blinds, payouts, and configuration. Does NOT copy check-ins, eliminations, or results.",
        "operationId": "post__api_orgs__slug__sessions__id__clone",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Cloned session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/check-in": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Check a player in",
        "description": "Two operations behind one body, discriminated on whether `paymentStatus` is present. Without it: creates the check-in row and answers 201 with it, or `{ already_checked_in: true }` if the player was already in. With it: sets the payment status of an existing or new check-in and answers 200 `{ updated: true }`. When the session's `seating_mode` is `on_pay`, marking a player `paid` also seats them and marking them `unpaid` takes the seat away.",
        "operationId": "post__api_orgs__slug__sessions__id__check_in",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "rosterPlayerId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "paymentStatus": {
                        "type": "string",
                        "enum": [
                          "paid",
                          "unpaid"
                        ]
                      }
                    },
                    "required": [
                      "rosterPlayerId",
                      "paymentStatus"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "rosterPlayerId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      }
                    },
                    "required": [
                      "rosterPlayerId"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment status set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "updated"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Check-in created, or already present.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/CheckIn"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "already_checked_in": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "already_checked_in"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Undo a check-in",
        "description": "Removes a player's check-in for this session, and their seat with it. The player is named in the query string; this route takes no body. 404 when that player is not checked into this session, so a retry or a wrong id is never reported as a removal.",
        "operationId": "delete__api_orgs__slug__sessions__id__check_in",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "rosterPlayerId",
            "in": "query",
            "required": true,
            "description": "UUID of the roster player.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check-in removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "removed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/participants": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List session participants",
        "description": "All players on this session's participant list, with their check-in, rebuy and elimination state joined on. Returns a bare array ordered by nickname.",
        "operationId": "get__api_orgs__slug__sessions__id__participants",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Participants.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SessionParticipant"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Add a player to a tournament",
        "description": "Adds a roster player to the participant list. Set `checkIn: true` to also check them in.",
        "operationId": "post__api_orgs__slug__sessions__id__participants",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rosterPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "checkIn": {
                    "default": false,
                    "type": "boolean"
                  }
                },
                "required": [
                  "rosterPlayerId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Participant added, or already on the list.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/SessionParticipant"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "already_exists": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "already_exists"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Remove a player from a tournament",
        "description": "Drops the participant row, the check-in, the seat and any elimination for this session. The player is named in the query string; this route takes no body. 404 when the player has nothing in this session.",
        "operationId": "delete__api_orgs__slug__sessions__id__participants",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "rosterPlayerId",
            "in": "query",
            "required": true,
            "description": "UUID of the roster player.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Participant removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/rebuys": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Record or undo a rebuy or addon",
        "description": "Moves the player's rebuy or addon count by one. `action: \"add\"` is blocked past `rebuy_cutoff_level` / `addon_cutoff_level` and past `max_rebuys`; `action: \"remove\"` is guarded in the UPDATE, so it 409s rather than driving the counter below zero.",
        "operationId": "post__api_orgs__slug__sessions__id__rebuys",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rosterPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "rebuy",
                      "addon"
                    ]
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "add",
                      "remove"
                    ]
                  }
                },
                "required": [
                  "rosterPlayerId",
                  "type",
                  "action"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Past cutoff level, at the rebuy limit, or nothing left to remove.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/results": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Get tournament results",
        "description": "Final standings with points and payouts, ordered by finish position. The body is shaped so it can be fed straight back into the POST for a read-modify-write.",
        "operationId": "get__api_orgs__slug__sessions__id__results",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Result"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Save tournament results",
        "description": "Replaces the session's results with the rows in the body: every existing result row is deleted and the body's rows inserted, in one transaction. The session's status is not changed; the final knockout completes it, or PATCH the session. Each row takes `rosterPlayerId` and `finishPosition`; `points` and `payoutAmount` are resolved from the session's point chart and payout structure when omitted. `pointsOverride` replaces the scored points for that player's season standing and requires `pointsOverrideReason`, which is shown to the player; it is org-admin only, and sending `null` clears a previous adjustment.",
        "operationId": "post__api_orgs__slug__sessions__id__results",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "results": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "rosterPlayerId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        },
                        "finishPosition": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000
                        },
                        "points": {
                          "default": 0,
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000000
                        },
                        "payoutAmount": {
                          "anyOf": [
                            {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 10000000
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "pointsOverride": {
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "pointsOverrideReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "rosterPlayerId",
                        "finishPosition"
                      ]
                    }
                  }
                },
                "required": [
                  "results"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Results saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "saved": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "saved"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/notify": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Send tournament notifications",
        "description": "Sends reminder emails. `audience` is required and has no default, so a whole-league send is always something a caller asked for by name: `rsvp_yes` (RSVP'd yes to this session), `checked_in` (checked in to this session), `roster` (every active roster player with an email), or `custom` with `playerIds`, which are roster player ids and are ignored if they belong to another org. One address receives one email however many rows match. Rate-limited to 3/min.",
        "operationId": "post__api_orgs__slug__sessions__id__notify",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "audience": {
                    "type": "string",
                    "enum": [
                      "rsvp_yes",
                      "checked_in",
                      "roster",
                      "custom"
                    ]
                  },
                  "playerIds": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  }
                },
                "required": [
                  "audience"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Send attempted; the body reports what happened.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audience": {
                      "type": "string",
                      "enum": [
                        "rsvp_yes",
                        "checked_in",
                        "roster",
                        "custom"
                      ]
                    },
                    "sent": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer",
                      "description": "Distinct addresses the audience resolved to."
                    }
                  },
                  "required": [
                    "audience",
                    "sent",
                    "failed",
                    "total"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/recap": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Send the results recap email now",
        "description": "Manually sends the results recap (finishing order, payouts, season standings, next game) to every checked-in player with an email address. The org's `recap_emails_enabled` toggle governs only the automatic send on completion and is ignored here — this route is an explicit request. The session must be completed with results saved. Each session's recap goes out once: a recap that already went out (automatically or manually) answers 409 `recap_already_sent`. Manager role or above. Rate-limited to 3/min.",
        "operationId": "post__api_orgs__slug__sessions__id__recap",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recap sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recipients": {
                      "type": "integer"
                    },
                    "sent": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "recipients",
                    "sent",
                    "failed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "`recap_already_sent`: this session's recap has gone out once already.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/managers": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List session managers",
        "description": "Members delegated manager permissions for this specific session, oldest delegation first. The email field is null for callers below the manager role.",
        "operationId": "get__api_orgs__slug__sessions__id__managers",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session managers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SessionManager"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Add a session manager",
        "description": "Grants per-session manager permissions to an existing org member. Every permission defaults to true; send `false` to withhold one.",
        "operationId": "post__api_orgs__slug__sessions__id__managers",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "nickname": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "canControlClock": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canCheckInPlayers": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canAssignTables": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canRecordEliminations": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canEnterResults": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "userId",
                  "nickname"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Manager added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionManager"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Remove a session manager",
        "description": "Revokes per-session manager permissions. The manager is named in the query string; this route takes no body.",
        "operationId": "delete__api_orgs__slug__sessions__id__managers",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "managerId",
            "in": "query",
            "required": true,
            "description": "UUID of the session_managers row, as returned by the GET.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Manager removed. 404 when no manager with that id is on this session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "removed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/managers/handoff": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Issue a co-host handoff link",
        "description": "Mints a single-use link (default 30 minutes) that makes whoever opens it a session manager with the permissions in the body. Optional `rosterPlayerId` also pushes the link to that player's companion page.",
        "operationId": "post__api_orgs__slug__sessions__id__managers_handoff",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "canControlClock": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canCheckInPlayers": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canAssignTables": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canRecordEliminations": {
                    "default": true,
                    "type": "boolean"
                  },
                  "canEnterResults": {
                    "default": true,
                    "type": "boolean"
                  },
                  "expiresMinutes": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 180
                  },
                  "rosterPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Handoff link minted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "description": "Full URL to hand to the co-host. Single use."
                    },
                    "token": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "broadcasted": {
                      "type": "boolean",
                      "description": "True when `rosterPlayerId` was set and the link was pushed to that player's companion."
                    }
                  },
                  "required": [
                    "url",
                    "token",
                    "expiresAt",
                    "broadcasted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/player-requests": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List player requests (host view)",
        "description": "Pending player self-service requests for the host to approve or reject, plus the minigame results already accepted for this session.",
        "operationId": "get__api_orgs__slug__sessions__id__player_requests",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Player requests.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pending": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PlayerRequest"
                      }
                    },
                    "acceptedMinigames": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PlayerRequest"
                      }
                    }
                  },
                  "required": [
                    "pending",
                    "acceptedMinigames"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Sessions"
        ],
        "summary": "Approve/reject a player request",
        "description": "Resolve a pending player self-service request. Requires `canRecordEliminations` for knockout requests and `canCheckInPlayers` for the rest.",
        "operationId": "patch__api_orgs__slug__sessions__id__player_requests",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "accept",
                      "decline",
                      "revoke"
                    ]
                  }
                },
                "required": [
                  "requestId",
                  "action"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "resolved": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted",
                        "declined"
                      ]
                    }
                  },
                  "required": [
                    "resolved",
                    "status"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "`not_pending` on accept/decline, or `not_accepted` on revoke: someone else resolved it first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Record a minigame result",
        "description": "Records an already-accepted minigame result for a player. This is not the resolve endpoint; use PATCH for that. Requires `canCheckInPlayers`.",
        "operationId": "post__api_orgs__slug__sessions__id__player_requests",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "targetPlayerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "minigame": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "hand": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": [
                  "targetPlayerId",
                  "minigame"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlayerRequest"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/rsvp": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List RSVPs",
        "description": "Everyone who has RSVP'd yes/no/maybe for this session, oldest response first.",
        "operationId": "get__api_orgs__slug__sessions__id__rsvp",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "RSVPs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Rsvp"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Get or mint this session's RSVP code",
        "description": "Returns the session's RSVP code, generating one on the first call. The code is what `/api/rsvp/{code}` is keyed on. Takes no body. Manager role or above.",
        "operationId": "post__api_orgs__slug__sessions__id__rsvp",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The RSVP code.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rsvpCode": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "rsvpCode"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players": {
      "get": {
        "tags": [
          "Players"
        ],
        "summary": "List roster players",
        "description": "All players in this org's roster, ordered by nickname. A non-manager caller (role \"player\") receives only id, nickname, first_name and status per player; manager and above receive the full record, including pin. Filter with `status` and `search`.",
        "operationId": "get__api_orgs__slug__players",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Roster status to list. Defaults to `active`.",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived"
              ],
              "default": "active"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive substring match on nickname. Caps the result at 100.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Roster. Field set depends on caller role; see description.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RosterPlayer"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Players"
        ],
        "summary": "Add roster players",
        "description": "Creates one player, or a batch of up to 200 when the body is `{ players: [...] }`. A batch is deduplicated against the existing roster and within itself by nickname, and returns one entry per input row, so a repeated nickname resolves to the same player rather than failing the batch. A single create rejects a nickname already active in this org with 409.",
        "operationId": "post__api_orgs__slug__players",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/CreatePlayer"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "players": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 200,
                        "items": {
                          "$ref": "#/components/schemas/CreatePlayer"
                        }
                      }
                    },
                    "required": [
                      "players"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Player created, or the batch resolved.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/RosterPlayer"
                    },
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RosterPlayer"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Nickname already exists in this org.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players/{playerId}": {
      "get": {
        "tags": [
          "Players"
        ],
        "summary": "Get a roster player",
        "description": "Single player detail. A non-manager caller (role \"player\") receives only id, nickname, first_name and status; manager and above receive the full record, including pin.",
        "operationId": "get__api_orgs__slug__players__playerId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Player. Field set depends on caller role; see description.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Players"
        ],
        "summary": "Update a roster player",
        "description": "Partial update of nickname/email/phone/pin. Setting status to \"archived\" also clears the account link on the same row, since the active-only unique index requires it to be free before the player can be re-claimed. Rejected with `code: \"player_erased\"` on a row that has been erased: erasure is final and a CHECK on the table enforces it.",
        "operationId": "patch__api_orgs__slug__players__playerId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nickname": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "first_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "last_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "archived"
                    ]
                  },
                  "reset_pin": {
                    "type": "boolean"
                  },
                  "pin": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d{4}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players/{playerId}/erase": {
      "post": {
        "tags": [
          "Players"
        ],
        "summary": "Erase a roster player",
        "description": "Admin-only, and irreversible. Nulls the player's contact details, PIN, notes and account link for good, archives the row, and stamps `erased_at`; a CHECK on the table then refuses to let the row hold any of them again, and PATCH on it is rejected from that point on. The row itself survives because `results.roster_player_id` is NO ACTION: every finish this player ever recorded points at it, so deleting it would take the league's season standings with it. `tier` picks how much of the name survives. \"removed\" (the default) keeps a first name and last initial so standings stay legible, which is the league holding a partial identifier under its own legitimate interest. \"erased\" keeps only a tombstone, and is what a data subject's erasure request gets. The tombstone is written in the org's locale at the time of erasure and never re-translated.",
        "operationId": "post__api_orgs__slug__players__playerId__erase",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tier": {
                    "default": "removed",
                    "type": "string",
                    "enum": [
                      "removed",
                      "erased"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Erased.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Already erased. See `code: \"player_erased\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players/{playerId}/link": {
      "put": {
        "tags": [
          "Players"
        ],
        "summary": "Link a roster player to an account",
        "description": "Admin only. Links this roster row to a user account that already belongs to the organization. Fails with 409 `user_already_linked_elsewhere` if the account already holds a different active roster row in this org, and 409 `roster_not_linkable` if the row already holds a link, is archived, or the account is no longer a member of this org.",
        "operationId": "put__api_orgs__slug__players__playerId__link",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "user_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Linked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Not linkable: already linked, archived, or the account is no longer a member of this org (or already linked to a different player).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Players"
        ],
        "summary": "Unlink a roster player from its account",
        "description": "Admin only. Clears the account link on this roster row, for example to fix a link that pointed at the wrong account. Fails with 409 `roster_not_linked` if the row is not currently linked.",
        "operationId": "delete__api_orgs__slug__players__playerId__link",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Unlinked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Not currently linked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players/{playerId}/claim-link": {
      "post": {
        "tags": [
          "Players"
        ],
        "summary": "Create a host-sent claim link",
        "description": "Manager and above. Mints (or reuses, if one is already outstanding) a claim link for this roster player: a link the player can use to connect their own account to this roster row and see their own tournament history. Unlike a plain org invite, opening the link is not enough on its own — /api/invites/{token}/claim refuses to write unless the authenticated caller's own email matches the roster player's email. Fails with 404 if the player does not exist in this org, 409 `roster_not_active` if it is archived, 409 `roster_already_linked` if it already holds a link, and 400 if the player has no email on file.",
        "operationId": "post__api_orgs__slug__players__playerId__claim_link",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An existing unexpired, unaccepted claim link was reused.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "invite_url"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Claim link created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invite_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "invite_url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "The player is archived or already linked to an account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/players/{playerId}/merge": {
      "post": {
        "tags": [
          "Players"
        ],
        "summary": "Merge a duplicate roster player",
        "description": "Admin only. Collapses source_player_id into the survivor named by the path. Repoints results, check-ins, session participants, table assignments, eliminations, RSVPs and player requests from the source to the survivor, keeping the survivor's row wherever both already have one for the same session. eliminated_by_id (on eliminations and player_requests) repoints the same way, except a row that would then point at itself (one duplicate busted the other) is set to null instead. The survivor keeps its own nickname, names and PIN; email, phone and notes fill in from the source only where the survivor's are blank. The source is archived with its account link and PIN cleared. Fails with 400 if source_player_id equals the path player, 404 if either does not exist in this org, 409 `survivor_archived` if the survivor is not active, and 409 `roster_merge_link_conflict` if both are linked to different accounts (unlink one first).",
        "operationId": "post__api_orgs__slug__players__playerId__merge",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "playerId",
            "in": "path",
            "required": true,
            "description": "Roster player UUID that survives the merge.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_player_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "source_player_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Merged.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "merged": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "survivor_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "archived_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "link_carried_over": {
                      "type": "boolean",
                      "description": "True when the source's account link moved to the survivor because the survivor had none."
                    },
                    "counts": {
                      "type": "object",
                      "description": "Per-table row counts, keyed by table name (results, check_ins, session_participants, table_assignments, eliminations, session_rsvps, player_requests).",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "repointed": {
                            "type": "integer"
                          },
                          "collisions_deleted": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "repointed",
                          "collisions_deleted"
                        ]
                      }
                    },
                    "eliminated_by_repointed": {
                      "type": "integer"
                    },
                    "player_requests_eliminated_by_repointed": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "merged",
                    "survivor_id",
                    "archived_id",
                    "link_carried_over",
                    "counts",
                    "eliminated_by_repointed",
                    "player_requests_eliminated_by_repointed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Both players are linked to different accounts, or the survivor is archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/eliminations": {
      "get": {
        "tags": [
          "Eliminations"
        ],
        "summary": "List eliminations",
        "description": "Eliminations for a specific session, newest first. Pass `type=remaining` instead to get the players who are checked in and still alive, ordered by nickname.",
        "operationId": "get__api_orgs__slug__eliminations",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "`all` (default) returns eliminations; `remaining` returns the check-in rows of players not yet eliminated.",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "remaining"
              ],
              "default": "all"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Eliminations, or remaining players when `type=remaining`.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Elimination"
                      }
                    },
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CheckIn"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Eliminations"
        ],
        "summary": "Record an elimination",
        "description": "Records that a player busted from the tournament. Optionally records who eliminated them. Finishing position is not sent and not stored: it falls out of elimination order when the tournament is finalized. The final knockout completes the session on its own.",
        "operationId": "post__api_orgs__slug__eliminations",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordElimination"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Elimination recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Elimination"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Player already eliminated in this session.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Eliminations"
        ],
        "summary": "Undo an elimination",
        "description": "Removes an elimination record, putting the player back in the tournament. Requires the `canRecordEliminations` permission for the session.",
        "operationId": "delete__api_orgs__slug__eliminations",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "eliminationId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "eliminationId",
                  "sessionId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Elimination undone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "No elimination with that id in that session; nothing was undone.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/table-assignments": {
      "get": {
        "tags": [
          "Tables"
        ],
        "summary": "List table assignments",
        "description": "Seat assignments for a specific session, ordered by table then seat. Eliminated players keep their seat so an undo can put them back, so read `is_eliminated` rather than assuming everyone listed is still playing.",
        "operationId": "get__api_orgs__slug__table_assignments",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Table assignments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableAssignment"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "summary": "Assign seats",
        "description": "Three operations behind one body. `{ action: \"random-draw\", sessionId, maxPerTable? }` reseats every checked-in, non-eliminated player across a freshly calculated set of tables and returns the new assignments. `{ action: \"break-table\", sessionId, tableNumber, maxPerTable? }` closes one table, relocating just its live players onto open seats at the remaining tables and leaving everyone else where they sit; it 409s if the other tables can't fit them. Anything else is a single move: `{ sessionId, rosterPlayerId, tableNumber, seatNumber }` seats one player, swapping with whoever is in that seat inside a transaction. Requires the `canAssignTables` permission.",
        "operationId": "post__api_orgs__slug__table_assignments",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "random-draw"
                      },
                      "sessionId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "maxPerTable": {
                        "default": 10,
                        "type": "integer",
                        "minimum": 6,
                        "maximum": 12
                      }
                    },
                    "required": [
                      "action",
                      "sessionId"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "break-table"
                      },
                      "sessionId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "tableNumber": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "maxPerTable": {
                        "default": 10,
                        "type": "integer",
                        "minimum": 6,
                        "maximum": 12
                      }
                    },
                    "required": [
                      "action",
                      "sessionId",
                      "tableNumber"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "sessionId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "rosterPlayerId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "tableNumber": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "seatNumber": {
                        "type": "integer",
                        "minimum": 1
                      }
                    },
                    "required": [
                      "sessionId",
                      "rosterPlayerId",
                      "tableNumber",
                      "seatNumber"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Seats written. A random draw returns the full new seating; a single move returns an acknowledgement.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TableAssignment"
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "assigned": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "assigned"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs": {
      "post": {
        "tags": [
          "Organizations"
        ],
        "summary": "Create an organization",
        "description": "Creates a new org with the current user as owner. Rate-limited to 5/min per IP. Optional `timezone` (IANA zone from the curated allowlist in lib/timezones.ts) sets the zone session dates render in; the onboarding form sends the browser's own zone. `currency` is not a body field: it is guessed from the Accept-Language header and changed in settings.",
        "operationId": "post__api_orgs",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "slug": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 50
                  },
                  "timezone": {
                    "type": "string",
                    "enum": [
                      "America/New_York",
                      "America/Chicago",
                      "America/Denver",
                      "America/Phoenix",
                      "America/Los_Angeles",
                      "America/Anchorage",
                      "Pacific/Honolulu",
                      "Europe/London",
                      "Europe/Dublin",
                      "Europe/Lisbon",
                      "Europe/Paris",
                      "Europe/Berlin",
                      "Europe/Madrid",
                      "Europe/Rome",
                      "Europe/Amsterdam",
                      "Europe/Brussels",
                      "Europe/Vienna",
                      "Europe/Zurich",
                      "Europe/Warsaw",
                      "Europe/Stockholm",
                      "Europe/Copenhagen",
                      "Europe/Oslo",
                      "Europe/Helsinki",
                      "Europe/Athens",
                      "Atlantic/Canary"
                    ]
                  }
                },
                "required": [
                  "name",
                  "slug"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Org created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "slug": {
                      "type": "string",
                      "description": "The org's slug, which every other org-scoped path is keyed on."
                    }
                  },
                  "required": [
                    "slug"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Slug already taken.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}": {
      "delete": {
        "tags": [
          "Organizations"
        ],
        "summary": "Delete an organization",
        "description": "Owner-only, and rejected for API-key callers: destroying a league is an interactive-session action, not something a ck_live_ token should be able to do to the org it was issued for. The body must carry `confirm` set to the org's own slug, so a click aimed at the wrong league cannot go through. A live Stripe subscription is cancelled first, and the delete is refused with `code: \"org_subscription_active\"` if Stripe cannot be reached, so a league is never deleted while it keeps billing. The league is marked deleted rather than removed: every surface stops serving it immediately, its API keys are deleted outright, and the row is hard-deleted by the daily cron 15 days later, taking every org-scoped table with it. Restoring within the window is platform-admin only. The slug stays claimed until the sweep.",
        "operationId": "delete__api_orgs__slug_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "League scheduled for deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "purge_after": {
                      "type": "string",
                      "format": "date-time",
                      "description": "When the league stops being recoverable."
                    },
                    "purge_days": {
                      "type": "integer",
                      "description": "Length of the recovery window in days."
                    }
                  },
                  "required": [
                    "deleted",
                    "purge_after",
                    "purge_days"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Confirmation did not match, or the league is already scheduled for deletion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "The league still has a live subscription and Stripe could not cancel it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/export": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "Export the whole league",
        "description": "Admin-only. Every org-scoped row this league holds, as a JSON attachment: members, invites, roster, seasons, tournaments and all their children, plus the reusable Library entities. Answers a data-access request, a portability request and a processor's return-at-end-of-engagement obligation with one call, and gives a host something to press before the delete button. Deliberately excluded, because none of it is league record: API keys (credentials), idempotency keys (request plumbing) and telemetry (diagnostics on a rolling budget). Admin rather than manager because the file carries every member's email and every player's contact details, which is more than the members list shows a manager. Sent `no-store`.",
        "operationId": "get__api_orgs__slug__export",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The league, as a downloadable JSON document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "exported_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "organization": {
                      "type": "object"
                    },
                    "tables": {
                      "type": "object",
                      "description": "One key per exported table, each an array of rows."
                    }
                  },
                  "required": [
                    "exported_at",
                    "organization",
                    "tables"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/members": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "List org members",
        "description": "All members of this org, owner first then by join date. Non-admins receive a null email on every row (PII protection).",
        "operationId": "get__api_orgs__slug__members",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Members.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "org_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "user_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "role": {
                        "type": "string",
                        "enum": [
                          "owner",
                          "admin",
                          "manager",
                          "player"
                        ]
                      },
                      "joined_at": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "invited_by": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "format": "uuid"
                      },
                      "nickname": {
                        "type": "string"
                      },
                      "email": {
                        "type": [
                          "string",
                          "null"
                        ],
                        "description": "Null for callers below admin: member emails are not exposed to managers or players."
                      }
                    },
                    "required": [
                      "id",
                      "org_id",
                      "user_id",
                      "role",
                      "joined_at",
                      "invited_by",
                      "nickname",
                      "email"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Organizations"
        ],
        "summary": "Change a member's role",
        "description": "Owner-only. The owner's own role cannot be changed here.",
        "operationId": "patch__api_orgs__slug__members",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "memberId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "manager",
                      "player"
                    ]
                  }
                },
                "required": [
                  "memberId",
                  "role"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Role updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "updated": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "updated"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Organizations"
        ],
        "summary": "Remove org member",
        "description": "Admin-only. Cannot remove the owner. The member's roster link is cleared in the same transaction, so the roster row goes back to unclaimed rather than pointing at an account that is no longer in the org.",
        "operationId": "delete__api_orgs__slug__members",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "memberId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "memberId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "removed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/settings": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "Get org settings",
        "description": "Non-Stripe settings only — billing data is retrieved via Stripe Portal. Includes `public_page_enabled`, the opt-out for the org's public league page at /league/{slug}, `recap_emails_enabled`, the opt-in for automatically emailing players the results recap when a tournament completes (defaults off; POST /sessions/{id}/recap sends one manually regardless), `player_money`, how much of the money players see (`none`, `winnings` or `all`), `timezone`, the IANA zone used to render session dates in that email and in the notify reminder, and `locale` and `currency`, the language and currency the league's dates, ordinals and money render in. `stripe_subscription_id` is null for everyone but the owner. `role` is the caller's own role in this org.",
        "operationId": "get__api_orgs__slug__settings",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "tier": {
                      "type": "string",
                      "enum": [
                        "home",
                        "league",
                        "pro"
                      ]
                    },
                    "trial_ends_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "subscription_status": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Stripe subscription status as last seen. Only `active` and `trialing` count as paid up."
                    },
                    "comp_until": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time",
                      "description": "End of a hand-granted plan; 9999-12-31 when open-ended."
                    },
                    "settings_json": {
                      "type": "object",
                      "description": "Free-form org settings blob: payout schedules, adaptive-UI default, league-rules document.",
                      "additionalProperties": true
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "stripe_subscription_id": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Owner only; null for every other role."
                    },
                    "clock_background_url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "public_page_enabled": {
                      "type": "boolean"
                    },
                    "recap_emails_enabled": {
                      "type": "boolean"
                    },
                    "player_money": {
                      "type": "string",
                      "enum": [
                        "none",
                        "winnings",
                        "all"
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "locale": {
                      "type": "string",
                      "enum": [
                        "en",
                        "de",
                        "fr",
                        "es"
                      ]
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "GBP",
                        "EUR"
                      ]
                    },
                    "standings_mode": {
                      "type": "string",
                      "enum": [
                        "season",
                        "rolling"
                      ],
                      "description": "What the league's standings rank: its active season, or its last `rolling_window` tournaments."
                    },
                    "rolling_window": {
                      "type": "integer",
                      "description": "How many of the league's most recent completed tournaments a rolling ranking counts. 2 to 100; default 12."
                    },
                    "rolling_best": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Count only each player's best this many results in the window; null counts them all."
                    },
                    "role": {
                      "type": "string",
                      "enum": [
                        "owner",
                        "admin",
                        "manager",
                        "player"
                      ],
                      "description": "The caller's own role in this org."
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "slug",
                    "tier",
                    "trial_ends_at",
                    "subscription_status",
                    "comp_until",
                    "settings_json",
                    "created_at",
                    "stripe_subscription_id",
                    "clock_background_url",
                    "public_page_enabled",
                    "recap_emails_enabled",
                    "player_money",
                    "timezone",
                    "locale",
                    "currency",
                    "standings_mode",
                    "rolling_window",
                    "rolling_best",
                    "role"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Organizations"
        ],
        "summary": "Update org settings",
        "description": "Admin-only. Accepts `public_page_enabled` (boolean) to toggle the public league page at /league/{slug}; it defaults to true. Accepts `recap_emails_enabled` (boolean) to toggle the automatic results recap email on completion; it defaults to false, and POST /sessions/{id}/recap sends one manually regardless. Accepts `player_money` (`none`, `winnings` or `all`; defaults to `none`): what players see of the money on the companion, the league page, their league home and the results recap. `winnings` shows what each player won; `all` also shows each player what they spent and their net. Host screens and the tournament's payout structure always show it. Accepts `timezone` (IANA zone name, e.g. \"America/Denver\"), the zone session dates render in for the recap email and the notify reminder; restricted to a curated allowlist (lib/timezones.ts, US and European zones) and defaults to \"America/Denver\". Accepts `locale` (one of `en`, `de`, `fr`, `es`; defaults to `en`), the language dates, times and ordinals render for. Accepts `currency` (one of `USD`, `GBP`, `EUR`; defaults to `USD`), the currency buy-ins, prize pools and payouts display in; it is display only and nothing is converted, and subscription billing stays in US dollars. Accepts `standings_mode` (`season` or `rolling`), `rolling_window` (2 to 100) and `rolling_best` (null, or 1 up to the window): a rolling league ranks each player's points from its last `rolling_window` completed tournaments on every standings surface, with no season needed. A `rolling_best` above the window is refused with 400 and nothing in the request is written.",
        "operationId": "patch__api_orgs__slug__settings",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "clock_background_url": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2048,
                        "format": "uri"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_schedule": {
                    "anyOf": [
                      {
                        "maxItems": 500,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "players": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 500
                            },
                            "prize_pool": {
                              "type": "number",
                              "minimum": 0
                            },
                            "positions": {
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "position": {
                                    "type": "integer",
                                    "minimum": 1
                                  },
                                  "amount": {
                                    "type": "number",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "position",
                                  "amount"
                                ]
                              }
                            }
                          },
                          "required": [
                            "players",
                            "prize_pool",
                            "positions"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_schedules": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            },
                            "rows": {
                              "maxItems": 500,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "players": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 500
                                  },
                                  "prize_pool": {
                                    "type": "number",
                                    "minimum": 0
                                  },
                                  "positions": {
                                    "maxItems": 20,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "position": {
                                          "type": "integer",
                                          "minimum": 1
                                        },
                                        "amount": {
                                          "type": "number",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "position",
                                        "amount"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "players",
                                  "prize_pool",
                                  "positions"
                                ]
                              }
                            }
                          },
                          "required": [
                            "name",
                            "rows"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "default_complexity": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "casual",
                      "pro"
                    ]
                  },
                  "public_page_enabled": {
                    "type": "boolean"
                  },
                  "recap_emails_enabled": {
                    "type": "boolean"
                  },
                  "player_money": {
                    "type": "string",
                    "enum": [
                      "none",
                      "winnings",
                      "all"
                    ]
                  },
                  "timezone": {
                    "type": "string",
                    "enum": [
                      "America/New_York",
                      "America/Chicago",
                      "America/Denver",
                      "America/Phoenix",
                      "America/Los_Angeles",
                      "America/Anchorage",
                      "Pacific/Honolulu",
                      "Europe/London",
                      "Europe/Dublin",
                      "Europe/Lisbon",
                      "Europe/Paris",
                      "Europe/Berlin",
                      "Europe/Madrid",
                      "Europe/Rome",
                      "Europe/Amsterdam",
                      "Europe/Brussels",
                      "Europe/Vienna",
                      "Europe/Zurich",
                      "Europe/Warsaw",
                      "Europe/Stockholm",
                      "Europe/Copenhagen",
                      "Europe/Oslo",
                      "Europe/Helsinki",
                      "Europe/Athens",
                      "Atlantic/Canary"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "enum": [
                      "en",
                      "de",
                      "fr",
                      "es"
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "USD",
                      "GBP",
                      "EUR"
                    ]
                  },
                  "standings_mode": {
                    "type": "string",
                    "enum": [
                      "season",
                      "rolling"
                    ]
                  },
                  "rolling_window": {
                    "type": "integer",
                    "minimum": 2,
                    "maximum": 100
                  },
                  "rolling_best": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "saved": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "saved"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/invites": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "List invites",
        "description": "Outstanding invite tokens for this org: unaccepted and unexpired only, newest first. Admin role required.",
        "operationId": "get__api_orgs__slug__invites",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invites.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrgInvite"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Organizations"
        ],
        "summary": "Create an invite",
        "description": "Generates a 128-bit crypto-random token with a 72-hour expiry, and returns the URL to share. Invites are not emailed: the host passes the link on. Putting an email on the invite is a delivery label, but accepting one does auto-link the accepting account to a roster row when their own verified email matches exactly one active player. Capped at 20 outstanding invites per org (429 `too_many_invites`).",
        "operationId": "post__api_orgs__slug__invites",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "role": {
                    "default": "player",
                    "type": "string",
                    "enum": [
                      "admin",
                      "manager",
                      "player"
                    ]
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invite created.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/OrgInvite"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "inviteUrl": {
                          "type": "string",
                          "format": "uri"
                        }
                      },
                      "required": [
                        "inviteUrl"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded, or `too_many_invites`: 20 invites are already outstanding.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/invites/{inviteId}": {
      "delete": {
        "tags": [
          "Organizations"
        ],
        "summary": "Revoke an invite",
        "description": "Admin-only. Deletes an invite that has not been accepted, so its link stops working and it no longer counts toward the 20 outstanding. Covers claim links and the invites made by putting an email on a roster player. 404 if the invite is not this org's, or was already accepted.",
        "operationId": "delete__api_orgs__slug__invites__inviteId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "description": "Invite UUID, from GET /api/orgs/{slug}/invites.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revoked": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "revoked"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/invites/{token}/claim": {
      "post": {
        "tags": [
          "Organizations"
        ],
        "summary": "Accept a host-sent claim link",
        "description": "Not org-scoped in the URL: the token alone resolves the org, the same as opening the invite page. Requires authentication. Links the caller's account to the roster player named by the claim link (see POST /api/orgs/{slug}/players/{playerId}/claim-link) and adds the account to the org at role \"player\" — never lowering an existing role. Refuses with 403 unless the authenticated user's own email case-insensitively matches the invite's email; a forwarded link is otherwise inert. Fails with 404 for a token that is not a claim link, 409 `invite_already_accepted` or `invite_expired`, 409 `roster_not_linkable` if the player was linked or archived after the link was sent, and 409 `user_already_linked_elsewhere` if the caller's account already holds a different active roster row in this org.",
        "operationId": "post__api_invites__token__claim",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "The claim link's token.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Claimed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "org_slug": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "org_slug"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "The authenticated account's email does not match the invite.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not a claim link (unknown token, or the token belongs to a plain invite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Already accepted, expired, no longer linkable, or the account already holds a different player in this org.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/setups": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "List tournament templates",
        "description": "Reusable tournament configurations, most recently updated first. Manager role or above. Returns a bare array.",
        "operationId": "get__api_orgs__slug__setups",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SetupTemplate"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Create a template",
        "description": "Save a tournament configuration as a reusable template. Pass `sessionId` to copy an existing tournament, or the config fields directly. A template carries everything a tournament is created with — blinds, chips, payouts, rebuy and add-on rules with their cutoff levels, bounties, minigames, points, seating, persona and expected size. It deliberately does not carry `is_private`: privacy is a per-event decision.",
        "operationId": "post__api_orgs__slug__setups",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_distribution": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "denomination": {
                              "type": "number"
                            },
                            "count": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 10000
                            }
                          },
                          "required": [
                            "denomination",
                            "count"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "color": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 40
                            },
                            "denomination": {
                              "type": "number"
                            },
                            "quantity": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000
                            }
                          },
                          "required": [
                            "color",
                            "denomination",
                            "quantity"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sessionId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "buy_in_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "starting_stack": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 100000000
                  },
                  "level_duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "blinds_config": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 200
                        },
                        "small_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "big_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "ante": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "duration_minutes": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 600
                        },
                        "is_break": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "level",
                        "small_blind",
                        "big_blind"
                      ]
                    }
                  },
                  "rebuy_allowed": {
                    "type": "boolean"
                  },
                  "rebuy_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_rebuys": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_allowed": {
                    "type": "boolean"
                  },
                  "addon_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_players_per_table": {
                    "type": "integer",
                    "minimum": 6,
                    "maximum": 12
                  },
                  "seating_mode": {
                    "type": "string",
                    "enum": [
                      "on_pay",
                      "all_at_once",
                      "manual"
                    ]
                  },
                  "payout_structure": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "positions": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "position": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 1000
                                },
                                "percentage": {
                                  "default": 0,
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 100
                                },
                                "amount": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "position"
                              ]
                            }
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "rows": {
                                "maxItems": 500,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "players": {
                                      "type": "integer",
                                      "minimum": 2,
                                      "maximum": 500
                                    },
                                    "prize_pool": {
                                      "type": "number",
                                      "minimum": 0
                                    },
                                    "positions": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "position": {
                                            "type": "integer",
                                            "minimum": 1
                                          },
                                          "amount": {
                                            "type": "number",
                                            "minimum": 0
                                          }
                                        },
                                        "required": [
                                          "position",
                                          "amount"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "players",
                                    "prize_pool",
                                    "positions"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "name",
                              "rows"
                            ]
                          }
                        },
                        "required": [
                          "positions"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "standard",
                          "progressive"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "minigames": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "tally",
                                    "ranked",
                                    "judged"
                                  ]
                                }
                              },
                              "required": [
                                "name"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "record_to_career": {
                    "type": "boolean"
                  },
                  "complexity": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "casual",
                          "pro"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "planned_table_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expected_player_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "prize_pool_deduction": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "table_names": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "blind_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "point_chart_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Template created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/setups/{setupId}": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Get a template",
        "description": "Single tournament template.",
        "operationId": "get__api_orgs__slug__setups__setupId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "setupId",
            "in": "path",
            "required": true,
            "description": "Template UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Template.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Templates"
        ],
        "summary": "Update a template",
        "description": "Partial update of a tournament template. Omitted fields are left as they are. `blind_schedule_id`, `payout_schedule_id` and `chip_set_id` point the template at a Library block, which wins over the embedded `blinds_config` / `payout_structure` / `chip_set` snapshot when the template is used; send null to detach. Omit them and the reference is dropped only if you send a snapshot that differs from the stored one. A reference to a block another org owns is stored as null. `chip_set` and `chip_distribution` are the embedded snapshots, named as they are on create.",
        "operationId": "put__api_orgs__slug__setups__setupId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "setupId",
            "in": "path",
            "required": true,
            "description": "Template UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "buy_in_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "starting_stack": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 100000000
                  },
                  "level_duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "blinds_config": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 200
                        },
                        "small_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "big_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "ante": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "duration_minutes": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 600
                        },
                        "is_break": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "level",
                        "small_blind",
                        "big_blind"
                      ]
                    }
                  },
                  "rebuy_allowed": {
                    "type": "boolean"
                  },
                  "rebuy_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_rebuys": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_allowed": {
                    "type": "boolean"
                  },
                  "addon_price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_chips": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_players_per_table": {
                    "type": "integer",
                    "minimum": 6,
                    "maximum": 12
                  },
                  "seating_mode": {
                    "type": "string",
                    "enum": [
                      "on_pay",
                      "all_at_once",
                      "manual"
                    ]
                  },
                  "payout_structure": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "positions": {
                            "maxItems": 1000,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "position": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 1000
                                },
                                "percentage": {
                                  "default": 0,
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 100
                                },
                                "amount": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "position"
                              ]
                            }
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "rows": {
                                "maxItems": 500,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "players": {
                                      "type": "integer",
                                      "minimum": 2,
                                      "maximum": 500
                                    },
                                    "prize_pool": {
                                      "type": "number",
                                      "minimum": 0
                                    },
                                    "positions": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "position": {
                                            "type": "integer",
                                            "minimum": 1
                                          },
                                          "amount": {
                                            "type": "number",
                                            "minimum": 0
                                          }
                                        },
                                        "required": [
                                          "position",
                                          "amount"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "players",
                                    "prize_pool",
                                    "positions"
                                  ]
                                }
                              }
                            },
                            "required": [
                              "name",
                              "rows"
                            ]
                          }
                        },
                        "required": [
                          "positions"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rebuy_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "addon_cutoff_level": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_amount": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "bounty_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "standard",
                          "progressive"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "minigames": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "tally",
                                    "ranked",
                                    "judged"
                                  ]
                                }
                              },
                              "required": [
                                "name"
                              ]
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "record_to_career": {
                    "type": "boolean"
                  },
                  "complexity": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "casual",
                          "pro"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "planned_table_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expected_player_count": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "prize_pool_deduction": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10000000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "table_names": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "point_chart_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "color": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 40
                            },
                            "denomination": {
                              "type": "number"
                            },
                            "quantity": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 1000000
                            }
                          },
                          "required": [
                            "color",
                            "denomination",
                            "quantity"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_distribution": {
                    "anyOf": [
                      {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "denomination": {
                              "type": "number"
                            },
                            "count": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 10000
                            }
                          },
                          "required": [
                            "denomination",
                            "count"
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "blind_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_schedule_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chip_set_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Delete a template",
        "description": "Removes a tournament template.",
        "operationId": "delete__api_orgs__slug__setups__setupId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "setupId",
            "in": "path",
            "required": true,
            "description": "Template UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/leaderboard": {
      "get": {
        "tags": [
          "Stats"
        ],
        "summary": "Org leaderboard",
        "description": "Aggregated stats across every completed session: wins, points, podiums, best and average finish, earnings. Pass `season` to scope it to one season, which also applies that season's best-N-of-M scoring rule; the all-time view counts every event. `season=rolling` ranks the league's last `rolling_window` tournaments (best `rolling_best` of them when set), when its `standings_mode` is `rolling`, and is empty otherwise.",
        "operationId": "get__api_orgs__slug__leaderboard",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "season",
            "in": "query",
            "required": false,
            "description": "Season UUID, or `rolling` for the league's rolling window. Omit for the all-time board.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Leaderboard.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "roster_player_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "nickname": {
                        "type": "string"
                      },
                      "games_played": {
                        "type": "integer"
                      },
                      "wins": {
                        "type": "integer"
                      },
                      "podiums": {
                        "type": "integer",
                        "description": "Finishes in the top three."
                      },
                      "total_points": {
                        "type": "integer"
                      },
                      "best_finish": {
                        "type": "integer"
                      },
                      "avg_finish": {
                        "type": "number"
                      },
                      "total_earnings": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "roster_player_id",
                      "nickname",
                      "games_played",
                      "wins",
                      "podiums",
                      "total_points",
                      "best_finish",
                      "avg_finish",
                      "total_earnings"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/seasons": {
      "get": {
        "tags": [
          "Seasons"
        ],
        "summary": "List seasons",
        "description": "All seasons for this org, newest year first. Returns a bare array.",
        "operationId": "get__api_orgs__slug__seasons",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Seasons.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Season"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Seasons"
        ],
        "summary": "Create a season",
        "description": "Group sessions into a season for standings. `scoring_config.bestNOfM` sets a drop-worst rule; leave it null to count every event.",
        "operationId": "post__api_orgs__slug__seasons",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "year": {
                    "type": "integer",
                    "minimum": 2020,
                    "maximum": 2100
                  },
                  "start_date": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "end_date": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "scoring_config": {
                    "type": "object",
                    "properties": {
                      "bestNOfM": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "best": {
                                "type": "integer",
                                "minimum": 1
                              },
                              "of": {
                                "type": "integer",
                                "minimum": 1
                              }
                            },
                            "required": [
                              "best",
                              "of"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                },
                "required": [
                  "name",
                  "year"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Season created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Season"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/seasons/{seasonId}": {
      "get": {
        "tags": [
          "Seasons"
        ],
        "summary": "Get a season",
        "description": "Season detail plus the sessions linked to it.",
        "operationId": "get__api_orgs__slug__seasons__seasonId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "seasonId",
            "in": "path",
            "required": true,
            "description": "Season UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Season and its sessions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "season": {
                      "$ref": "#/components/schemas/Season"
                    },
                    "sessions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Session"
                      }
                    }
                  },
                  "required": [
                    "season",
                    "sessions"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Seasons"
        ],
        "summary": "Update a season",
        "description": "Partial update. `link_session_id` and `unlink_session_id` attach or detach one session instead of editing the season, and each answers with its own acknowledgement rather than the season row, or 404 when no session of this league matches (for unlink, none linked to this season).",
        "operationId": "patch__api_orgs__slug__seasons__seasonId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "seasonId",
            "in": "path",
            "required": true,
            "description": "Season UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "start_date": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "end_date": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "scoring_config": {
                    "type": "object",
                    "properties": {
                      "bestNOfM": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "best": {
                                "type": "integer",
                                "minimum": 1
                              },
                              "of": {
                                "type": "integer",
                                "minimum": 1
                              }
                            },
                            "required": [
                              "best",
                              "of"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "link_session_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "unlink_session_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated season, or the link acknowledgement.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/Season"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "linked": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "linked"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "unlinked": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      },
                      "required": [
                        "unlinked"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Seasons"
        ],
        "summary": "Delete a season",
        "description": "Removes the season. Does not delete member sessions.",
        "operationId": "delete__api_orgs__slug__seasons__seasonId_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "seasonId",
            "in": "path",
            "required": true,
            "description": "Season UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/seasons/{seasonId}/standings": {
      "get": {
        "tags": [
          "Seasons"
        ],
        "summary": "Season standings",
        "description": "Points leaderboard for a season, ranked. Private sessions' results count here: `is_private` hides live surfaces and listings, never season maths. A session marked `is_championship` is the one exception — linked to its season but excluded from season points. Ties break on points, then wins, then best finish, then events played.",
        "operationId": "get__api_orgs__slug__seasons__seasonId__standings",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "seasonId",
            "in": "path",
            "required": true,
            "description": "Season UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Standings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "roster_player_id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "nickname": {
                        "type": "string"
                      },
                      "rank": {
                        "type": "integer"
                      },
                      "total_points": {
                        "type": "integer"
                      },
                      "events_played": {
                        "type": "integer"
                      },
                      "events_counted": {
                        "type": "integer",
                        "description": "How many of those events the season's best-N-of-M rule actually counted."
                      },
                      "wins": {
                        "type": "integer"
                      },
                      "seconds": {
                        "type": "integer"
                      },
                      "podiums": {
                        "type": "integer"
                      },
                      "best_finish": {
                        "type": "integer"
                      },
                      "avg_finish": {
                        "type": "number"
                      },
                      "total_earnings": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "roster_player_id",
                      "nickname",
                      "rank",
                      "total_points",
                      "events_played",
                      "events_counted",
                      "wins",
                      "seconds",
                      "podiums",
                      "best_finish",
                      "avg_finish",
                      "total_earnings"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/billing/checkout": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create Stripe Checkout session",
        "description": "Owner-only, and never available to an agent key. Creates a Stripe Checkout session for a league's first subscription and answers with the URL to send the browser to. A league that already has a subscription gets 409 `subscription_exists`: plan changes go through the portal, which updates that subscription instead of starting a second. Rate-limited to 5/min. Paid plans are off in production, so this currently answers 403 `billing_disabled`.",
        "operationId": "post__api_orgs__slug__billing_checkout",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tier": {
                    "type": "string",
                    "enum": [
                      "home",
                      "league"
                    ]
                  },
                  "interval": {
                    "default": "monthly",
                    "type": "string",
                    "enum": [
                      "monthly",
                      "annual"
                    ]
                  }
                },
                "required": [
                  "tier"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/billing/portal": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create Stripe Customer Portal session",
        "description": "Owner-only, and never available to an agent key. Creates a Stripe Customer Portal session for changing plan, updating the card, viewing invoices or cancelling. Takes no body. Answers 403 `billing_disabled` while paid plans are off.",
        "operationId": "post__api_orgs__slug__billing_portal",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Portal URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/api-keys": {
      "get": {
        "tags": [
          "API Keys"
        ],
        "summary": "List API keys",
        "description": "List active (non-revoked) agent API keys for this org. Admin/owner only. The response never includes the plaintext key — only the prefix for display. This is the one list endpoint that wraps its rows in `{ data, total }`.",
        "operationId": "get__api_orgs__slug__api_keys",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "API keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data",
                    "total"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "API Keys"
        ],
        "summary": "Create a new API key",
        "description": "Generates a fresh agent API key and returns the plaintext ONCE. Save it immediately — it cannot be recovered. Use in subsequent requests as `Authorization: Bearer <token>`. A key cannot grant a role higher than its creator's role. `scopes` is reserved: per-resource grants are not enforced yet, so the array must be empty and `role` is what narrows permissions.",
        "operationId": "post__api_orgs__slug__api_keys",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "role": {
                    "default": "manager",
                    "type": "string",
                    "enum": [
                      "owner",
                      "admin",
                      "manager",
                      "player"
                    ]
                  },
                  "scopes": {
                    "maxItems": 0,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "expires_in_days": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 3650
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created. The `token` field is shown ONCE.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/ApiKey"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "token": {
                          "type": "string",
                          "description": "The plaintext key, shown only on creation. Format: `ck_live_<43-char base64url>`. Save it now."
                        },
                        "_warning": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "token",
                        "_warning"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "API Keys"
        ],
        "summary": "Revoke an API key",
        "description": "Immediately revokes the key. Revoked keys cannot authenticate. Admin/owner only.",
        "operationId": "delete__api_orgs__slug__api_keys",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "keyId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "required": [
                  "keyId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revoked": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "revoked"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/quickstart": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Create a trial org, session, and API key in one request",
        "description": "One-call provisioning for agents. Creates a ghost-owned trial organization, a demo tournament with the default 15-level blind structure, a clock row, and an admin-role API key. The `api_key` value is returned in plaintext exactly once — agents must persist it before any follow-up call.\n\nTrial orgs auto-expire 7 days after creation; a daily Vercel Cron deletes them and their ghost owners. The API key expires 1 day after the org so cleanup produces 404s instead of 401s during the grace window.\n\n**Not idempotent** — retrying after a network timeout creates a second trial org. `hints.retry_safety` in the response re-states this so the caller does not blind-retry.\n\n**Rate limit**: 5 requests per hour per IP (advisory: the window is kept per serverless instance).\n\nAfter this call, agents typically proceed to `POST /api/orgs/{org_slug}/clock` with `{\"sessionId\":\"{session_id}\",\"action\":\"start\"}` using the returned `api_key`.",
        "operationId": "post__api_quickstart",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "org_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "session_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "timezone": {
                    "type": "string",
                    "enum": [
                      "America/New_York",
                      "America/Chicago",
                      "America/Denver",
                      "America/Phoenix",
                      "America/Los_Angeles",
                      "America/Anchorage",
                      "Pacific/Honolulu",
                      "Europe/London",
                      "Europe/Dublin",
                      "Europe/Lisbon",
                      "Europe/Paris",
                      "Europe/Berlin",
                      "Europe/Madrid",
                      "Europe/Rome",
                      "Europe/Amsterdam",
                      "Europe/Brussels",
                      "Europe/Vienna",
                      "Europe/Zurich",
                      "Europe/Warsaw",
                      "Europe/Stockholm",
                      "Europe/Copenhagen",
                      "Europe/Oslo",
                      "Europe/Helsinki",
                      "Europe/Athens",
                      "Atlantic/Canary"
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "USD",
                      "GBP",
                      "EUR"
                    ]
                  },
                  "locale": {
                    "type": "string",
                    "enum": [
                      "en",
                      "de",
                      "fr",
                      "es"
                    ]
                  }
                },
                "description": "Every field optional. `org_name` becomes the slug prefix with a random suffix appended; `session_name` defaults to \"Demo Tournament\"; `email` is advisory and not verified. `timezone` and `currency` are both allowlisted, and default to \"America/Denver\" and whatever the Accept-Language header suggests (else USD). `locale` picks the league's language (en, de, fr, es; default en) for every surface and the starter Library. A malformed body is a 400, not defaults."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Trial provisioned. Store `api_key` immediately — it will not be shown again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "org_slug",
                    "api_key",
                    "api_key_prefix",
                    "session_id",
                    "expires_at",
                    "next_actions"
                  ],
                  "properties": {
                    "org_slug": {
                      "type": "string",
                      "description": "Use in every follow-up URL: /api/orgs/{org_slug}/..."
                    },
                    "api_key": {
                      "type": "string",
                      "description": "Plaintext Bearer token — shown ONCE. Format: ck_live_<43-char-base64url>."
                    },
                    "api_key_prefix": {
                      "type": "string",
                      "description": "First 8 chars of the raw token (after the ck_live_ prefix). Safe to log."
                    },
                    "session_id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "UUID of the auto-created demo tournament."
                    },
                    "session_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "clock_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "openapi_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time",
                      "description": "ISO-8601. Trial org is deleted after this instant (1-day grace)."
                    },
                    "hints": {
                      "type": "object",
                      "properties": {
                        "start_clock": {
                          "type": "string"
                        },
                        "add_player": {
                          "type": "string"
                        },
                        "check_in": {
                          "type": "string"
                        },
                        "retry_safety": {
                          "type": "string"
                        }
                      }
                    },
                    "next_actions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "rel",
                          "href"
                        ],
                        "properties": {
                          "rel": {
                            "type": "string"
                          },
                          "href": {
                            "type": "string"
                          },
                          "method": {
                            "type": "string",
                            "enum": [
                              "GET",
                              "POST",
                              "PUT",
                              "PATCH",
                              "DELETE"
                            ]
                          }
                        }
                      }
                    },
                    "_warning": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (bad email, oversize org_name, etc.).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Hourly cap hit. Retry-After header present.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Slug generator exhausted after 5 retries. Retry or pass a different org_name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/orgs/{slug}/blind-schedules": {
      "get": {
        "tags": [
          "Library"
        ],
        "summary": "List blind schedules",
        "description": "Named blind structures. The chosen schedule's levels snapshot onto the tournament at creation, so a live game never changes underneath the host. Most recently used first, so a picker can default to the first entry. Capped at 100.",
        "operationId": "get__api_orgs__slug__blind_schedules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Blind schedule list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BlindSchedule"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Library"
        ],
        "summary": "Create a blind schedule",
        "description": "Saves a reusable blind schedule on the org. Requires manager role or above.",
        "operationId": "post__api_orgs__slug__blind_schedules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "blinds": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 200
                        },
                        "small_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "big_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "ante": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "duration_minutes": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 600
                        },
                        "is_break": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "level",
                        "small_blind",
                        "big_blind"
                      ]
                    }
                  },
                  "level_duration_minutes": {
                    "default": 15,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  }
                },
                "required": [
                  "name",
                  "blinds"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BlindSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/blind-schedules/{id}": {
      "patch": {
        "tags": [
          "Library"
        ],
        "summary": "Update a blind schedule",
        "description": "Partial update; at least one field is required. Tournaments already created keep their snapshot, so edits here only affect future use.",
        "operationId": "patch__api_orgs__slug__blind_schedules__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Blind schedule UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "blinds": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "level": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 200
                        },
                        "small_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "big_blind": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "ante": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "duration_minutes": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 600
                        },
                        "is_break": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "level",
                        "small_blind",
                        "big_blind"
                      ]
                    }
                  },
                  "level_duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BlindSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Library"
        ],
        "summary": "Delete a blind schedule",
        "description": "Removes the blind schedule. Setup templates referencing it keep working via their embedded snapshot.",
        "operationId": "delete__api_orgs__slug__blind_schedules__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Blind schedule UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/chip-sets": {
      "get": {
        "tags": [
          "Library"
        ],
        "summary": "List chip sets",
        "description": "Chip colors, denominations, and quantities. The in-play denominations drive color-up suggestions and the starting-stack chip check. Most recently used first, so a picker can default to the first entry. Capped at 100.",
        "operationId": "get__api_orgs__slug__chip_sets",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Chip set list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChipSet"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Library"
        ],
        "summary": "Create a chip set",
        "description": "Saves a reusable chip set on the org. Requires manager role or above.",
        "operationId": "post__api_orgs__slug__chip_sets",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chips": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "color": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "denomination": {
                          "type": "number"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000000
                        }
                      },
                      "required": [
                        "color",
                        "denomination",
                        "quantity"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "chips"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChipSet"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/chip-sets/{id}": {
      "patch": {
        "tags": [
          "Library"
        ],
        "summary": "Update a chip set",
        "description": "Partial update; at least one field is required. Tournaments already created keep their snapshot, so edits here only affect future use.",
        "operationId": "patch__api_orgs__slug__chip_sets__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Chip set UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "chips": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "color": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "denomination": {
                          "type": "number"
                        },
                        "quantity": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 1000000
                        }
                      },
                      "required": [
                        "color",
                        "denomination",
                        "quantity"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChipSet"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Library"
        ],
        "summary": "Delete a chip set",
        "description": "Removes the chip set. Setup templates referencing it keep working via their embedded snapshot.",
        "operationId": "delete__api_orgs__slug__chip_sets__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Chip set UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/payout-schedules": {
      "get": {
        "tags": [
          "Library"
        ],
        "summary": "List payout schedules",
        "description": "Payout tables keyed by player count. The matching tier resolves into the tournament's payout_structure; matching is exact-first, then the highest tier whose players count is <= the paid field. Most recently used first, so a picker can default to the first entry. Capped at 100.",
        "operationId": "get__api_orgs__slug__payout_schedules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payout schedule list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PayoutSchedule"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Library"
        ],
        "summary": "Create a payout schedule",
        "description": "Saves a reusable payout schedule on the org. Requires manager role or above.",
        "operationId": "post__api_orgs__slug__payout_schedules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rows": {
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "players": {
                          "type": "integer",
                          "minimum": 2,
                          "maximum": 500
                        },
                        "prize_pool": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 10000000
                        },
                        "positions": {
                          "maxItems": 50,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000
                              },
                              "amount": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 10000000
                              }
                            },
                            "required": [
                              "position",
                              "amount"
                            ]
                          }
                        }
                      },
                      "required": [
                        "players",
                        "prize_pool",
                        "positions"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/payout-schedules/{id}": {
      "patch": {
        "tags": [
          "Library"
        ],
        "summary": "Update a payout schedule",
        "description": "Partial update; at least one field is required. Tournaments already created keep their snapshot, so edits here only affect future use.",
        "operationId": "patch__api_orgs__slug__payout_schedules__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payout schedule UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rows": {
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "players": {
                          "type": "integer",
                          "minimum": 2,
                          "maximum": 500
                        },
                        "prize_pool": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 10000000
                        },
                        "positions": {
                          "maxItems": 50,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000
                              },
                              "amount": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 10000000
                              }
                            },
                            "required": [
                              "position",
                              "amount"
                            ]
                          }
                        }
                      },
                      "required": [
                        "players",
                        "prize_pool",
                        "positions"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutSchedule"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Library"
        ],
        "summary": "Delete a payout schedule",
        "description": "Removes the payout schedule. Setup templates referencing it keep working via their embedded snapshot.",
        "operationId": "delete__api_orgs__slug__payout_schedules__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payout schedule UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/point-charts": {
      "get": {
        "tags": [
          "Library"
        ],
        "summary": "List point charts",
        "description": "League points by finishing position, per player-count tier. Applied against the PAID entrant count when results are saved; falls back to the built-in scale when a tournament has no chart or the tier omits the position. Most recently used first, so a picker can default to the first entry. Capped at 100.",
        "operationId": "get__api_orgs__slug__point_charts",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Point chart list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PointChart"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Library"
        ],
        "summary": "Create a point chart",
        "description": "Saves a reusable point chart on the org. Requires manager role or above.",
        "operationId": "post__api_orgs__slug__point_charts",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rows": {
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "players": {
                          "type": "integer",
                          "minimum": 2,
                          "maximum": 500
                        },
                        "positions": {
                          "maxItems": 50,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000
                              },
                              "points": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 1000000
                              }
                            },
                            "required": [
                              "position",
                              "points"
                            ]
                          }
                        }
                      },
                      "required": [
                        "players",
                        "positions"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PointChart"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/point-charts/{id}": {
      "patch": {
        "tags": [
          "Library"
        ],
        "summary": "Update a point chart",
        "description": "Partial update; at least one field is required. Tournaments already created keep their snapshot, so edits here only affect future use.",
        "operationId": "patch__api_orgs__slug__point_charts__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Point chart UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 500
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rows": {
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "players": {
                          "type": "integer",
                          "minimum": 2,
                          "maximum": 500
                        },
                        "positions": {
                          "maxItems": 50,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "position": {
                                "type": "integer",
                                "minimum": 1,
                                "maximum": 1000
                              },
                              "points": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 1000000
                              }
                            },
                            "required": [
                              "position",
                              "points"
                            ]
                          }
                        }
                      },
                      "required": [
                        "players",
                        "positions"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PointChart"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Library"
        ],
        "summary": "Delete a point chart",
        "description": "Removes the point chart. Setup templates referencing it keep working via their embedded snapshot.",
        "operationId": "delete__api_orgs__slug__point_charts__id_",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Point chart UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/league-rules": {
      "post": {
        "tags": [
          "Library"
        ],
        "summary": "Upload the league-rules PDF",
        "description": "Multipart form upload with a `file` field. PDF only (magic bytes are verified, not just the declared MIME), 4 MB max, admin role required. Replaces any existing rules document. Players read it from the companion page.",
        "operationId": "post__api_orgs__slug__league_rules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Uploaded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "league_rules": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "file_name": {
                          "type": "string"
                        },
                        "uploaded_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "url",
                        "file_name",
                        "uploaded_at"
                      ]
                    }
                  },
                  "required": [
                    "league_rules"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Library"
        ],
        "summary": "Remove the league-rules PDF",
        "description": "Deletes the stored document and clears the org setting. Admin role required.",
        "operationId": "delete__api_orgs__slug__league_rules",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "removed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/timeline": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Read the tournament timeline",
        "description": "Ordered host-action audit trail for one tournament (level advances, pauses, seat moves, eliminations, failures).",
        "operationId": "get__api_orgs__slug__sessions__id__timeline",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Timeline entries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimelineEntry"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Append a timeline entry",
        "description": "Records a client-observed failure onto the tournament timeline: what the client was trying to do and what went wrong. Writes are best-effort by design, so a failure here never blocks the action it describes.",
        "operationId": "post__api_orgs__slug__sessions__id__timeline",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "error": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "auto": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "action",
                  "error"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "logged": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "logged"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/{id}/minigame-order": {
      "patch": {
        "tags": [
          "Sessions"
        ],
        "summary": "Reorder minigame results",
        "description": "Sets the displayed ranking for a minigame's recorded winners. Host-assigned order wins over chronological order on every leaderboard surface. `orderedIds` are player_request ids, in the order they should show.",
        "operationId": "patch__api_orgs__slug__sessions__id__minigame_order",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "minigame": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "orderedIds": {
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  }
                },
                "required": [
                  "minigame",
                  "orderedIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reordered.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reordered": {
                      "type": "integer",
                      "description": "How many rows were restamped."
                    }
                  },
                  "required": [
                    "reordered"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/setups/{setupId}/duplicate": {
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Duplicate a template",
        "description": "Copies an existing setup template, including its Library references and embedded snapshots. Takes no body.",
        "operationId": "post__api_orgs__slug__setups__setupId__duplicate",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "setupId",
            "in": "path",
            "required": true,
            "description": "Template UUID.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any random string (UUID recommended). Identical requests with the same key within 24 hours return the original response — safe to retry on network failure. A duplicate that arrives while the original is still running returns 409 `idempotency_key_in_flight`; retry it shortly.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Copy created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/sessions/live": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "The running tournament",
        "description": "The league's most recently started tournament that is active or paused, or null. Managers and above; a player gets 403.",
        "operationId": "get__api_orgs__slug__sessions_live",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The running tournament, or null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "paused"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "status"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "session"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/plan-status": {
      "get": {
        "tags": [
          "Organizations"
        ],
        "summary": "Plan and trial status",
        "description": "Current plan, roster headroom and the per-tournament field size the plan carries. `rosterLimit` is null on an unlimited plan, and both threshold flags are then false. A tournament may run past `checkInLimit`; once paid plans are open, the next session create is refused with `plan_field_exceeded` until the plan fits the field that ran.",
        "operationId": "get__api_orgs__slug__plan_status",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Plan status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tier": {
                      "type": "string",
                      "enum": [
                        "home",
                        "league",
                        "pro"
                      ]
                    },
                    "rosterCount": {
                      "type": "integer",
                      "description": "Active roster players."
                    },
                    "rosterLimit": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Null when the plan has no cap."
                    },
                    "approachingLimit": {
                      "type": "boolean",
                      "description": "At 80% of the cap or above."
                    },
                    "atLimit": {
                      "type": "boolean"
                    },
                    "checkInLimit": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "description": "Players per tournament. Null when the plan has no cap."
                    },
                    "lapsed": {
                      "type": "boolean",
                      "description": "No active plan (no paid subscription, comp or trial) while paid plans are open. Session create, clone and starting a scheduled session answer 403 `subscription_required` until one is chosen."
                    }
                  },
                  "required": [
                    "tier",
                    "rosterCount",
                    "rosterLimit",
                    "approachingLimit",
                    "atLimit",
                    "checkInLimit",
                    "lapsed"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/public-session-timeline": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public tournament timeline",
        "description": "Host-action timeline for one tournament, readable by anyone holding the session UUID. This is what lets a player knocked out early keep following along. Edge-cached for 15 seconds.",
        "operationId": "get__api_public_session_timeline",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Timeline.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TimelineEntry"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-active-season-standings": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Live season standings",
        "description": "Provisional season standings while the tournament is still running. Eliminated players hold their real finishing position; every player still alive is scored at the next position to be awarded, so values ratchet up on each bust. Never cache these as final: only a saved result writes real points. `season` is null and `standings` empty when the org has no active season.",
        "operationId": "get__api_public_active_season_standings",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provisional standings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "season": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "year": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "year"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "standings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "roster_player_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "nickname": {
                            "type": "string"
                          },
                          "games_played": {
                            "type": "integer"
                          },
                          "wins": {
                            "type": "integer"
                          },
                          "podiums": {
                            "type": "integer"
                          },
                          "total_points": {
                            "type": "integer"
                          },
                          "best_finish": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "roster_player_id",
                          "nickname",
                          "games_played",
                          "wins",
                          "podiums",
                          "total_points",
                          "best_finish"
                        ]
                      }
                    },
                    "live": {
                      "type": "boolean",
                      "description": "True while a tournament is in progress, which is what makes these numbers provisional."
                    },
                    "locale": {
                      "type": "string",
                      "enum": [
                        "en",
                        "de",
                        "fr",
                        "es"
                      ]
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "GBP",
                        "EUR"
                      ]
                    },
                    "timezone": {
                      "type": "string",
                      "description": "IANA zone, e.g. `America/Denver`."
                    }
                  },
                  "required": [
                    "season",
                    "standings",
                    "live",
                    "locale",
                    "currency",
                    "timezone"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-minigame-leaderboard": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public minigame leaderboard",
        "description": "Winners and per-player tallies for each minigame in the tournament, in the host-assigned display order. `activeMinigames` names the games this tournament is currently running, which may include ones with no winner yet.",
        "operationId": "get__api_public_minigame_leaderboard",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Minigame leaderboard.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "groups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "minigame": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "tally",
                              "ranked",
                              "judged"
                            ],
                            "description": "How the game is scored. `tally` counts wins per player; the others rank single entries."
                          },
                          "winners": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "nickname": {
                                  "type": "string"
                                },
                                "rosterPlayerId": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "hand": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "imageUrl": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "rank": {
                                  "type": "integer",
                                  "description": "1-based position in the displayed order: the host-set order when there is one, else chronological."
                                }
                              },
                              "required": [
                                "id",
                                "nickname",
                                "rosterPlayerId",
                                "hand",
                                "imageUrl",
                                "at",
                                "rank"
                              ]
                            }
                          },
                          "tally": {
                            "description": "Player-by-win-count leaderboard. Null for anything but a `tally` game.",
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "rosterPlayerId": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "nickname": {
                                      "type": "string"
                                    },
                                    "count": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "rosterPlayerId",
                                    "nickname",
                                    "count"
                                  ]
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "minigame",
                          "type",
                          "winners",
                          "tally"
                        ]
                      }
                    },
                    "activeMinigames": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "groups",
                    "activeMinigames"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-player-career": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public player career",
        "description": "One player's career history, earned achievements, and head-to-head record. `scope` selects all-time or the current season. Achievement labels and details are message keys with ICU arguments, not finished sentences: the companion renders them in the org's language.",
        "operationId": "get__api_public_player_career",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "rosterPlayerId",
            "in": "query",
            "required": false,
            "description": "Roster player UUID. Without it, `you` is empty and `standings` is the finishing order.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "`all` (default) or `season`.",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "season"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Career summary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "roster_player_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "nickname": {
                      "type": "string"
                    },
                    "season": {
                      "description": "Set only for `scope=season`: the resolved active season, or null if there is none.",
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "games_played": {
                          "type": "integer"
                        },
                        "wins": {
                          "type": "integer"
                        },
                        "podiums": {
                          "type": "integer"
                        },
                        "total_points": {
                          "type": "integer"
                        },
                        "best_finish": {
                          "type": "integer"
                        },
                        "avg_finish": {
                          "type": "number"
                        },
                        "total_earnings": {
                          "type": [
                            "number",
                            "null"
                          ],
                          "description": "Null unless the league's `player_money` setting shows it to players."
                        },
                        "total_spent": {
                          "type": [
                            "number",
                            "null"
                          ],
                          "description": "Buy-ins, rebuys and add-ons. Null unless the league's `player_money` setting shows it to players."
                        },
                        "net": {
                          "type": [
                            "number",
                            "null"
                          ],
                          "description": "Null unless the league's `player_money` setting shows it to players."
                        }
                      },
                      "required": [
                        "games_played",
                        "wins",
                        "podiums",
                        "total_points",
                        "best_finish",
                        "avg_finish",
                        "total_earnings",
                        "total_spent",
                        "net"
                      ]
                    },
                    "tournaments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "session_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "session_name": {
                            "type": "string"
                          },
                          "started_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "ended_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "finish_position": {
                            "type": "integer"
                          },
                          "players_in_tournament": {
                            "type": "integer"
                          },
                          "paid_positions": {
                            "type": "integer",
                            "description": "Positions that took money in that tournament."
                          },
                          "made_final_table": {
                            "type": "boolean"
                          },
                          "points": {
                            "type": "integer"
                          },
                          "payout_amount": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buy_in_amount": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "session_id",
                          "session_name",
                          "started_at",
                          "ended_at",
                          "finish_position",
                          "players_in_tournament",
                          "paid_positions",
                          "made_final_table",
                          "points",
                          "payout_amount",
                          "buy_in_amount"
                        ]
                      }
                    },
                    "achievements": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "icon": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string",
                            "description": "Message key, not a sentence."
                          },
                          "detail": {
                            "type": "string",
                            "description": "Message key for the detail line."
                          },
                          "tier": {
                            "type": "integer",
                            "description": "Index into the badge's tiers; 0 for a badge with one."
                          },
                          "args": {
                            "type": "object",
                            "description": "ICU arguments for the detail key. Money arrives already formatted.",
                            "additionalProperties": true
                          }
                        },
                        "required": [
                          "key",
                          "icon",
                          "label",
                          "detail",
                          "tier",
                          "args"
                        ]
                      }
                    },
                    "head_to_head": {
                      "type": "object",
                      "properties": {
                        "rival": {
                          "description": "The opponent this player has knocked out most often.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "nickname": {
                                  "type": "string"
                                },
                                "count": {
                                  "type": "integer"
                                }
                              },
                              "required": [
                                "nickname",
                                "count"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "nemesis": {
                          "description": "The opponent who has knocked this player out most often.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "nickname": {
                                  "type": "string"
                                },
                                "count": {
                                  "type": "integer"
                                }
                              },
                              "required": [
                                "nickname",
                                "count"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "rival",
                        "nemesis"
                      ]
                    },
                    "season_standing": {
                      "description": "`scope=season` only: this player's own position in season points (which exclude the championship), or null for career scope / not on the board.",
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "rank": {
                              "type": "integer"
                            },
                            "total_players": {
                              "type": "integer"
                            },
                            "total_points": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "rank",
                            "total_players",
                            "total_points"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "championship_standing": {
                      "description": "`scope=season` only: this player's finish in the season's championship, or null if none has been played. `finish` is null if the championship exists but this player did not play it.",
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "session_name": {
                              "type": "string"
                            },
                            "finish": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "total_entrants": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "session_name",
                            "finish",
                            "total_entrants"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "league_rules": {
                      "description": "The org's current league-rules PDF, or null if none is uploaded.",
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "file_name": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "url",
                            "file_name"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "locale": {
                      "type": "string",
                      "enum": [
                        "en",
                        "de",
                        "fr",
                        "es"
                      ]
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "GBP",
                        "EUR"
                      ]
                    },
                    "timezone": {
                      "type": "string",
                      "description": "IANA zone, e.g. `America/Denver`."
                    }
                  },
                  "required": [
                    "roster_player_id",
                    "nickname",
                    "season",
                    "stats",
                    "tournaments",
                    "achievements",
                    "head_to_head",
                    "season_standing",
                    "championship_standing",
                    "league_rules",
                    "locale",
                    "currency",
                    "timezone"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/public-player-tournament": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public player tournament detail",
        "description": "One player's detail for one past tournament. The live `sessionId` is the access token; `tournamentSessionId` names the past game.",
        "operationId": "get__api_public_player_tournament",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tournamentSessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the past tournament.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "rosterPlayerId",
            "in": "query",
            "required": false,
            "description": "Roster player UUID. Without it, `you` is empty and `standings` is the finishing order.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tournament detail.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "session_name": {
                      "type": "string"
                    },
                    "started_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "ended_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "buy_in_amount": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "players_in_tournament": {
                      "type": "integer"
                    },
                    "final_table_size": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "you": {
                      "type": "object",
                      "properties": {
                        "finish_position": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "made_final_table": {
                          "type": "boolean"
                        },
                        "points": {
                          "type": "integer"
                        },
                        "points_override_reason": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Why the host adjusted this player's points, shown to the player."
                        },
                        "payout_amount": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "rebuy_count": {
                          "type": "integer"
                        },
                        "addon_count": {
                          "type": "integer"
                        },
                        "spent": {
                          "type": [
                            "number",
                            "null"
                          ],
                          "description": "Null unless the league's `player_money` setting shows it to players."
                        },
                        "net": {
                          "type": [
                            "number",
                            "null"
                          ],
                          "description": "Null unless the league's `player_money` setting shows it to players."
                        }
                      },
                      "required": [
                        "finish_position",
                        "made_final_table",
                        "points",
                        "points_override_reason",
                        "payout_amount",
                        "rebuy_count",
                        "addon_count",
                        "spent",
                        "net"
                      ]
                    },
                    "standings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "roster_player_id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "nickname": {
                            "type": "string"
                          },
                          "finish_position": {
                            "type": "integer"
                          },
                          "payout_amount": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "points": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "roster_player_id",
                          "nickname",
                          "finish_position",
                          "payout_amount",
                          "points"
                        ]
                      }
                    },
                    "minigames": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "minigame": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "tally",
                              "ranked",
                              "judged"
                            ],
                            "description": "How the game is scored. `tally` counts wins per player; the others rank single entries."
                          },
                          "winners": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "nickname": {
                                  "type": "string"
                                },
                                "rosterPlayerId": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "hand": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "imageUrl": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "rank": {
                                  "type": "integer",
                                  "description": "1-based position in the displayed order: the host-set order when there is one, else chronological."
                                }
                              },
                              "required": [
                                "id",
                                "nickname",
                                "rosterPlayerId",
                                "hand",
                                "imageUrl",
                                "at",
                                "rank"
                              ]
                            }
                          },
                          "tally": {
                            "description": "Player-by-win-count leaderboard. Null for anything but a `tally` game.",
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "rosterPlayerId": {
                                      "type": "string",
                                      "format": "uuid"
                                    },
                                    "nickname": {
                                      "type": "string"
                                    },
                                    "count": {
                                      "type": "integer"
                                    }
                                  },
                                  "required": [
                                    "rosterPlayerId",
                                    "nickname",
                                    "count"
                                  ]
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "minigame",
                          "type",
                          "winners",
                          "tally"
                        ]
                      }
                    },
                    "locale": {
                      "type": "string",
                      "enum": [
                        "en",
                        "de",
                        "fr",
                        "es"
                      ]
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "GBP",
                        "EUR"
                      ]
                    },
                    "timezone": {
                      "type": "string",
                      "description": "IANA zone, e.g. `America/Denver`."
                    }
                  },
                  "required": [
                    "session_id",
                    "session_name",
                    "started_at",
                    "ended_at",
                    "buy_in_amount",
                    "players_in_tournament",
                    "final_table_size",
                    "you",
                    "standings",
                    "minigames",
                    "locale",
                    "currency",
                    "timezone"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/api/orgs/{slug}/me": {
      "get": {
        "tags": [
          "Me"
        ],
        "summary": "Your own member home",
        "description": "Any org member, logged in interactively — 403 for an API key, since a key acts as its creator's identity and this reads (and the sibling routes below write) that person's own contact fields and PIN, not the key's own scope. Own roster fields (full contact fields, since it is the caller's own row; never the pin), the soonest scheduled public game with the caller's own RSVP response if any, and the live/paused public game if one exists. Answers 200 with `linked: false` and `member: null` rather than 404 when the caller has no linked roster row, since this is the page that has to render that state gracefully.",
        "operationId": "get__api_orgs__slug__me",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's member home.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "linked": {
                      "type": "boolean"
                    },
                    "member": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "nickname": {
                              "type": "string"
                            },
                            "first_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "last_name": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "email": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "phone": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "archived"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "nickname",
                            "first_name",
                            "last_name",
                            "email",
                            "phone",
                            "status"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_game": {
                      "description": "The soonest scheduled public game, kept visible for 12 hours past its scheduled time so tonight's game does not vanish before the host starts it.",
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "scheduled_for": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "response": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "yes",
                                "no",
                                "maybe",
                                null
                              ],
                              "description": "The caller's own RSVP, or null."
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "scheduled_for",
                            "response"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "live_game": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "paused"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "status"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "linked",
                    "member",
                    "next_game",
                    "live_game"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/me/rsvp": {
      "post": {
        "tags": [
          "Me"
        ],
        "summary": "RSVP to a scheduled or live game",
        "description": "Any org member with a linked roster row, logged in interactively — 403 for an API key, same reasoning as GET /me. Upserts the caller's own RSVP for a game in this org that is not private and is scheduled, active, or paused. Keyed on the caller's roster row, not their account email, so it can never double-count against a public RSVP-form submission under the same address. 404 `not_claimed` if the caller has no linked roster row.",
        "operationId": "post__api_orgs__slug__me_rsvp",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "game_session_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "response": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no",
                      "maybe"
                    ]
                  }
                },
                "required": [
                  "game_session_id",
                  "response"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "RSVP recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rsvp"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not linked: the caller's account has no active roster row in this org. See `code: \"not_claimed\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "A different roster row in this org already holds an RSVP under the caller's email for this game.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/me/profile": {
      "patch": {
        "tags": [
          "Me"
        ],
        "summary": "Update your own profile",
        "description": "Any org member with a linked roster row, logged in interactively — 403 for an API key, same reasoning as GET /me. Partial update of the caller's own nickname/first_name/last_name/email/phone. A nickname collision with another active player in this org answers 409 `nickname_taken`, not a 500. 404 `not_claimed` if the caller has no linked roster row.",
        "operationId": "patch__api_orgs__slug__me_profile",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nickname": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "first_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "last_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 20
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RosterPlayer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not linked: the caller's account has no active roster row in this org. See `code: \"not_claimed\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Nickname already taken by another active player in this org.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/me/pin": {
      "post": {
        "tags": [
          "Me"
        ],
        "summary": "Set or reset your own PIN",
        "description": "Any org member with a linked roster row, logged in interactively — 403 for an API key, same reasoning as GET /me. Sets the caller's own 4-digit PIN unconditionally (no prior PIN required, since it is their own) and clears any pin-verify rate-limit lockout on this roster row. 404 `not_claimed` if the caller has no linked roster row.",
        "operationId": "post__api_orgs__slug__me_pin",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pin": {
                    "type": "string",
                    "pattern": "^\\d{4}$"
                  }
                },
                "required": [
                  "pin"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PIN set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not linked: the caller's account has no active roster row in this org. See `code: \"not_claimed\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/me": {
      "delete": {
        "tags": [
          "Me"
        ],
        "summary": "Delete your account",
        "description": "Deletes the caller's account outright. There is no window and no restore, unlike deleting a league: an account is one person asking to be gone. The body must carry `confirm` set to the caller's own email address. Blocked with `code: \"owns_organizations\"` while the caller still owns a league that is not already deleted; the hint names them, and they must be deleted or transferred first. A league the caller had ALREADY deleted is purged immediately rather than waiting out its 15-day window. Roster rows in leagues the caller merely played in are NOT deleted: those belong to the host, who is their controller, and the account link is severed instead. Session auth only, like every /api/me route; an API key cannot reach it.",
        "operationId": "delete__api_me",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "purged_organizations": {
                      "type": "integer",
                      "description": "Already-deleted leagues purged as part of this."
                    }
                  },
                  "required": [
                    "deleted",
                    "purged_organizations"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Confirmation did not match the caller's email address.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found (may also indicate no access).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "The caller still owns a league (`owns_organizations`; the hint names which), or an already-deleted league could not be purged because its subscription can still bill (`org_subscription_active`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/me/session-identity": {
      "get": {
        "tags": [
          "Me"
        ],
        "summary": "Resolve your own player identity for a live session",
        "description": "Session-UUID-keyed like every /api/public-* endpoint — no org key, `sessionId` alone — but authenticated: resolves the caller's own linked roster row, checked into THIS session, in that session's org. This is what lets the at-table companion skip the PIN picker for a claimed member. Always answers 200, even logged out, a private/missing session, or no checked-in linked row — the companion falls back to the PIN picker silently either way, so there is nothing to error on. Deliberately never accepts an org slug or id.",
        "operationId": "get__api_me_session_identity",
        "parameters": [
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The caller's identity for this session, or `linked: false` for every non-match.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "linked": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        }
                      },
                      "required": [
                        "linked"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "linked": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "org_slug": {
                          "type": "string"
                        },
                        "roster_player_id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "nickname": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "linked",
                        "org_slug",
                        "roster_player_id",
                        "nickname"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/me/cohost-invite": {
      "get": {
        "tags": [
          "Me"
        ],
        "summary": "Fetch the co-host handoff link aimed at your own roster row",
        "description": "Account-authenticated twin of `POST /api/public-cohost-invite`: same lookup, but the player is the caller's own claimed roster row in this org instead of a PIN. Rejects API keys.",
        "operationId": "get__api_orgs__slug__me_cohost_invite",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "required": true,
            "description": "UUID of the game session (tournament).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The open invite for the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "expiresAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Called with an API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not linked: the caller's account has no active roster row in this org. See `code: \"not_claimed\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/orgs/{slug}/me/requests": {
      "post": {
        "tags": [
          "Me"
        ],
        "summary": "File a self-service player request as your claimed roster row",
        "description": "Any org member with a linked roster row, logged in interactively — 403 for an API key, same reasoning as GET /me. Account-authenticated twin of POST /api/public-player-requests: identical effect (check-in guard, dedup insert, host broadcast, shared in lib/player-requests.ts), but the submitter is resolved from the caller's own claimed roster row instead of a PIN. 404 `not_claimed` if the caller has no linked roster row. A duplicate pending request for the same target answers 200 with `duplicate: true` rather than erroring. `image_data_url` is only meaningful when `request_type` is `minigame`.",
        "operationId": "post__api_orgs__slug__me_requests",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Organization slug (URL-friendly identifier).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "game_session_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "request_type": {
                    "type": "string",
                    "enum": [
                      "knockout",
                      "rebuy",
                      "minigame"
                    ]
                  },
                  "target_player_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "eliminated_by_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payload": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "image_data_url": {
                    "type": "string",
                    "maxLength": 220000,
                    "pattern": "^data:image\\/(jpeg|webp|png);base64,"
                  }
                },
                "required": [
                  "game_session_id",
                  "request_type",
                  "target_player_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A pending request for the same target already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "duplicate": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "duplicate",
                    "message"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Request created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlayerRequest"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input. Response `hint` may describe which field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated but lacks permission for this org or action.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not linked: the caller's account has no active roster row in this org. See `code: \"not_claimed\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Check `Retry-After` header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. Safe to retry with Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Legacy: the same text as `message`, kept for older readers that take `body.error` as a string. Branch on `code` instead."
          },
          "code": {
            "type": "string",
            "enum": [
              "invalid_input",
              "missing_field",
              "unauthorized",
              "forbidden",
              "not_found",
              "rate_limited",
              "internal_error",
              "service_unavailable",
              "billing_disabled",
              "no_billing_account",
              "subscription_exists",
              "plan_limit_reached",
              "plan_field_exceeded",
              "subscription_required",
              "not_claimed",
              "slug_taken",
              "cannot_change_own_role",
              "cannot_remove_self",
              "cannot_demote_self",
              "confirmation_mismatch",
              "org_already_deleted",
              "org_not_deleted",
              "tier_managed_by_stripe",
              "comp_active",
              "org_subscription_active",
              "owns_organizations",
              "too_many_invites",
              "invite_already_accepted",
              "invite_expired",
              "not_accepted",
              "not_pending",
              "nickname_taken",
              "nickname_mismatch",
              "nothing_to_update",
              "no_active_players",
              "no_recipients",
              "roster_already_linked",
              "roster_merge_link_conflict",
              "player_erased",
              "roster_not_active",
              "roster_not_linkable",
              "roster_not_linked",
              "survivor_archived",
              "user_already_linked_elsewhere",
              "no_unique_claimable_player",
              "pin_already_set",
              "pin_not_set",
              "pin_incorrect",
              "session_not_active",
              "session_ended",
              "not_checked_in",
              "already_eliminated",
              "seat_occupied",
              "empty_table",
              "table_break_no_room",
              "clock_cooldown",
              "recap_already_sent",
              "date_range_invalid",
              "rsvp_conflict",
              "session_private",
              "rebuys_disabled",
              "past_rebuy_cutoff",
              "max_rebuys_reached",
              "no_rebuys_to_remove",
              "addons_disabled",
              "past_addon_cutoff",
              "no_addons_to_remove",
              "upload_failed",
              "idempotency_key_in_flight",
              "idempotency_key_reused"
            ],
            "description": "Machine-readable error code. Always present; branch on this rather than on `message`."
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message, in English. For agents; the UI translates by `code`."
          },
          "hint": {
            "description": "Guidance for how to recover — often points to the right next call",
            "type": "string"
          },
          "doc_url": {
            "description": "Link to documentation for this error",
            "type": "string",
            "format": "uri"
          },
          "next_actions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rel": {
                  "type": "string",
                  "description": "Relation name, e.g. `retry`, `resume`, `verify-pin`"
                },
                "href": {
                  "type": "string",
                  "description": "URL or path to call next"
                },
                "method": {
                  "type": "string",
                  "enum": [
                    "GET",
                    "POST",
                    "PATCH",
                    "PUT",
                    "DELETE"
                  ]
                }
              },
              "required": [
                "rel",
                "href"
              ],
              "additionalProperties": false
            }
          },
          "retry_after_seconds": {
            "description": "On 429 and 503: seconds to wait before retrying. The `Retry-After` header carries the same number.",
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "error",
          "code",
          "message"
        ],
        "additionalProperties": false,
        "description": "Standard error shape returned by all endpoints on non-2xx responses."
      },
      "ClockState": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "hand_for_hand": {
            "type": "boolean",
            "description": "Freezes the level timer for lockstep play near the bubble. Every client tick short-circuits on it, so the clock reads as paused while it is set."
          },
          "current_level": {
            "type": "integer",
            "minimum": 1
          },
          "time_remaining_seconds": {
            "type": "integer",
            "minimum": 0
          },
          "is_running": {
            "type": "boolean"
          },
          "is_paused": {
            "type": "boolean"
          },
          "pause_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_updated_at": {
            "type": "string",
            "description": "ISO 8601 timestamp used for drift-corrected client-side timing"
          },
          "effective_remaining": {
            "type": "integer",
            "minimum": 0,
            "description": "Server-computed remaining seconds, drift-corrected from last_updated_at"
          }
        },
        "required": [
          "id",
          "game_session_id",
          "org_id",
          "hand_for_hand",
          "current_level",
          "time_remaining_seconds",
          "is_running",
          "is_paused",
          "pause_message",
          "last_updated_at",
          "effective_remaining"
        ],
        "additionalProperties": false
      },
      "PublicClock": {
        "type": "object",
        "properties": {
          "locale": {
            "type": "string",
            "description": "The league's locale (BCP 47), resolved through the session."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency the league plays for."
          },
          "timezone": {
            "type": "string",
            "description": "IANA zone the league's times are in."
          },
          "sessionName": {
            "type": "string"
          },
          "leagueSlug": {
            "description": "The league's public page is /league/{leagueSlug}; null when the league has turned that page off.",
            "type": [
              "string",
              "null"
            ]
          },
          "sessionStatus": {
            "type": "string",
            "enum": [
              "scheduled",
              "active",
              "paused",
              "completed",
              "cancelled"
            ]
          },
          "currentLevel": {
            "type": "integer"
          },
          "timeRemaining": {
            "type": "integer",
            "description": "Drift-corrected remaining seconds. Count down from lastUpdatedAt, never from a raw stored value."
          },
          "isRunning": {
            "type": "boolean"
          },
          "isPaused": {
            "type": "boolean"
          },
          "handForHand": {
            "type": "boolean",
            "description": "Freezes the level timer for lockstep play near the bubble."
          },
          "pauseMessage": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastUpdatedAt": {
            "type": "string"
          },
          "currentBlind": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "small_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "big_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "ante": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "is_break": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "level",
                  "small_blind",
                  "big_blind"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "nextBlind": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "small_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "big_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "ante": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "is_break": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "level",
                  "small_blind",
                  "big_blind"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "tableNames": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "clockBackgroundUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "checkedIn": {
            "type": "integer"
          },
          "remaining": {
            "type": "integer"
          },
          "startingStack": {
            "type": "integer"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "prizePool": {
            "type": "number"
          },
          "payouts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "position": {
                  "type": "integer"
                },
                "amount": {
                  "type": "number"
                }
              },
              "required": [
                "position",
                "amount"
              ],
              "additionalProperties": false
            }
          },
          "buyInAmount": {
            "type": [
              "number",
              "null"
            ]
          },
          "blinds": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "small_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "big_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "ante": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "duration_minutes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "is_break": {
                  "type": "boolean"
                }
              },
              "required": [
                "level",
                "small_blind",
                "big_blind"
              ],
              "additionalProperties": false
            }
          },
          "recentEliminations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "nickname": {
                  "type": "string"
                },
                "eliminated_by_nickname": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "eliminated_at": {
                  "type": "string"
                }
              },
              "required": [
                "nickname",
                "eliminated_by_nickname",
                "eliminated_at"
              ],
              "additionalProperties": false
            },
            "description": "The five most recent busts, newest first."
          },
          "tableCount": {
            "type": "integer",
            "description": "Tables with at least one seated, un-eliminated player."
          },
          "tableStats": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "table_number": {
                  "type": "integer"
                },
                "player_count": {
                  "type": "integer",
                  "description": "Seated players not yet eliminated."
                }
              },
              "required": [
                "table_number",
                "player_count"
              ],
              "additionalProperties": false
            }
          },
          "maxPlayersPerTable": {
            "type": "integer"
          },
          "chipDenominations": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "plannedTableCount": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "multiTable": {
                "type": "boolean"
              },
              "dealMaking": {
                "type": "boolean"
              },
              "delegation": {
                "type": "boolean"
              },
              "payoutAutomation": {
                "type": "boolean"
              }
            },
            "required": [
              "multiTable",
              "dealMaking",
              "delegation",
              "payoutAutomation"
            ],
            "additionalProperties": false,
            "description": "Adaptive UI flags for this session (lib/capabilities.ts)."
          },
          "payoutPositionCount": {
            "type": "integer"
          },
          "payoutStructure": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "positions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "position": {
                          "type": "integer"
                        },
                        "percentage": {
                          "type": "number"
                        },
                        "amount": {
                          "description": "A fixed amount; overrides the percentage when set.",
                          "type": "number"
                        }
                      },
                      "required": [
                        "position",
                        "percentage"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "positions"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ],
            "description": "The payout positions in force for the current paid field, or null when none apply."
          },
          "rebuyAllowed": {
            "type": "boolean"
          },
          "addonAllowed": {
            "type": "boolean"
          },
          "minigames": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Names of the active minigames."
          }
        },
        "required": [
          "locale",
          "currency",
          "timezone",
          "sessionName",
          "leagueSlug",
          "sessionStatus",
          "currentLevel",
          "timeRemaining",
          "isRunning",
          "isPaused",
          "handForHand",
          "pauseMessage",
          "lastUpdatedAt",
          "currentBlind",
          "nextBlind",
          "tableNames",
          "clockBackgroundUrl",
          "checkedIn",
          "remaining",
          "startingStack",
          "startedAt",
          "prizePool",
          "payouts",
          "buyInAmount",
          "blinds",
          "recentEliminations",
          "tableCount",
          "tableStats",
          "maxPlayersPerTable",
          "chipDenominations",
          "plannedTableCount",
          "capabilities",
          "payoutPositionCount",
          "payoutStructure",
          "rebuyAllowed",
          "addonAllowed",
          "minigames"
        ],
        "additionalProperties": false,
        "description": "What the TV clock and the player companion poll: the clock, the blinds, the field and the prize pool."
      },
      "ClockAction": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "action": {
            "type": "string",
            "enum": [
              "start",
              "pause",
              "resume",
              "next-level",
              "prev-level",
              "set-level",
              "adjust-time",
              "toggle-hand-for-hand"
            ]
          },
          "pauseMessage": {
            "type": "string",
            "maxLength": 200
          },
          "level": {
            "type": "integer",
            "minimum": 1
          },
          "adjustSeconds": {
            "type": "integer"
          },
          "force": {
            "type": "boolean"
          },
          "auto": {
            "type": "boolean"
          }
        },
        "required": [
          "sessionId",
          "action"
        ],
        "additionalProperties": false,
        "description": "A clock command. `set-level` requires `level`; `adjust-time` requires `adjustSeconds` (positive or negative, clamped to non-negative remaining time). `toggle-hand-for-hand` flips hand-for-hand mode, which freezes the level timer for lockstep play near the bubble. `force: true` bypasses the 2-second cooldown that stops two devices racing; `auto` marks the advance as the timer expiring rather than a host skipping a level."
      },
      "SessionStatus": {
        "type": "string",
        "enum": [
          "scheduled",
          "active",
          "paused",
          "completed",
          "cancelled"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "scheduled",
              "active",
              "paused",
              "completed",
              "cancelled"
            ]
          },
          "buy_in_amount": {
            "type": [
              "number",
              "null"
            ]
          },
          "starting_stack": {
            "type": "integer"
          },
          "level_duration_minutes": {
            "type": "integer"
          },
          "is_private": {
            "type": "boolean"
          },
          "is_championship": {
            "type": "boolean"
          },
          "seating_mode": {
            "type": "string",
            "enum": [
              "on_pay",
              "all_at_once",
              "manual"
            ]
          },
          "blinds_config": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "small_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "big_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "ante": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "duration_minutes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "is_break": {
                  "type": "boolean"
                }
              },
              "required": [
                "level",
                "small_blind",
                "big_blind"
              ],
              "additionalProperties": false
            }
          },
          "payout_structure": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "positions": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "position": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000
                        },
                        "percentage": {
                          "default": 0,
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "amount": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "position",
                        "percentage"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "schedule": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "rows": {
                        "maxItems": 500,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "players": {
                              "type": "integer",
                              "minimum": 2,
                              "maximum": 500
                            },
                            "prize_pool": {
                              "type": "number",
                              "minimum": 0
                            },
                            "positions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "position": {
                                    "type": "integer",
                                    "minimum": 1
                                  },
                                  "amount": {
                                    "type": "number",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "position",
                                  "amount"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "players",
                            "prize_pool",
                            "positions"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "name",
                      "rows"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "positions"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "rebuy_allowed": {
            "type": "boolean"
          },
          "rebuy_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "addon_allowed": {
            "type": "boolean"
          },
          "addon_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheduled_for": {
            "description": "ISO 8601 timestamp for a `scheduled` session's planned start. Null for every other status.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "status",
          "buy_in_amount",
          "starting_stack",
          "level_duration_minutes",
          "is_private",
          "is_championship",
          "seating_mode",
          "blinds_config",
          "payout_structure",
          "rebuy_allowed",
          "rebuy_price",
          "addon_allowed",
          "addon_price",
          "started_at",
          "scheduled_for",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      },
      "LiveTournament": {
        "type": "object",
        "properties": {
          "locale": {
            "type": "string",
            "description": "The league's locale (BCP 47), resolved through the session."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency the league plays for."
          },
          "timezone": {
            "type": "string",
            "description": "IANA zone the league's times are in."
          },
          "sessionStatus": {
            "type": "string",
            "enum": [
              "scheduled",
              "active",
              "paused",
              "completed",
              "cancelled"
            ]
          },
          "checkedIn": {
            "type": "integer"
          },
          "paidCount": {
            "type": "integer"
          },
          "remaining": {
            "type": "integer"
          },
          "eliminated": {
            "type": "integer"
          },
          "clockState": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "currentLevel": {
                    "type": "integer"
                  },
                  "timeRemaining": {
                    "type": "integer",
                    "description": "Drift-corrected remaining seconds."
                  },
                  "isRunning": {
                    "type": "boolean"
                  },
                  "isPaused": {
                    "type": "boolean"
                  },
                  "handForHand": {
                    "type": "boolean"
                  },
                  "pauseMessage": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lastUpdatedAt": {
                    "type": "string"
                  }
                },
                "required": [
                  "currentLevel",
                  "timeRemaining",
                  "isRunning",
                  "isPaused",
                  "handForHand",
                  "pauseMessage",
                  "lastUpdatedAt"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "blinds": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "small_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "big_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "ante": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "duration_minutes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "is_break": {
                  "type": "boolean"
                }
              },
              "required": [
                "level",
                "small_blind",
                "big_blind"
              ],
              "additionalProperties": false
            }
          },
          "chipDenominations": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "chipSet": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "color": {
                      "type": "string"
                    },
                    "denomination": {
                      "type": "number"
                    },
                    "quantity": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "color",
                    "denomination",
                    "quantity"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "chipDistribution": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "denomination": {
                      "type": "number"
                    },
                    "color": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "denomination",
                    "color",
                    "count"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "Chips each player starts with: the host's override if set, else the suggestion. Null with no chip set."
          },
          "currentBlind": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "small_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "big_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "ante": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "is_break": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "level",
                  "small_blind",
                  "big_blind"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "nextBlind": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "small_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "big_blind": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "ante": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000
                  },
                  "duration_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 600
                  },
                  "is_break": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "level",
                  "small_blind",
                  "big_blind"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "rebuyCutoffLevel": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "tableStats": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "table_number": {
                  "type": "integer"
                },
                "player_count": {
                  "type": "integer",
                  "description": "Seated players not yet eliminated."
                }
              },
              "required": [
                "table_number",
                "player_count"
              ],
              "additionalProperties": false
            }
          },
          "maxPlayersPerTable": {
            "type": "integer"
          },
          "recentEliminations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "org_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "game_session_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "roster_player_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "eliminated_by_id": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "bounty_won": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "table_number": {
                  "anyOf": [
                    {
                      "type": "integer"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "notes": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "eliminated_at": {
                  "type": "string"
                },
                "nickname": {
                  "type": "string"
                },
                "eliminated_by_nickname": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "org_id",
                "game_session_id",
                "roster_player_id",
                "eliminated_by_id",
                "bounty_won",
                "table_number",
                "notes",
                "eliminated_at",
                "nickname",
                "eliminated_by_nickname"
              ],
              "additionalProperties": false
            },
            "description": "The five most recent busts, newest first."
          },
          "prizePool": {
            "type": "number",
            "minimum": 0
          },
          "totalRebuys": {
            "type": "integer"
          },
          "totalAddons": {
            "type": "integer"
          },
          "rebuyPrice": {
            "description": "What one rebuy costs; null when rebuys are not priced.",
            "type": [
              "number",
              "null"
            ]
          },
          "addonPrice": {
            "description": "What one add-on costs; null when add-ons are not priced.",
            "type": [
              "number",
              "null"
            ]
          },
          "tableNames": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "dealerDraws": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "buyInAmount": {
            "type": [
              "number",
              "null"
            ]
          },
          "startingStack": {
            "type": "integer"
          },
          "startedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "addonCutoffLevel": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "payoutStructure": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "positions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "position": {
                          "type": "integer"
                        },
                        "percentage": {
                          "type": "number"
                        },
                        "amount": {
                          "description": "A fixed amount; overrides the percentage when set.",
                          "type": "number"
                        }
                      },
                      "required": [
                        "position",
                        "percentage"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "positions"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ],
            "description": "The payout positions in force for the current paid field, or null when none apply."
          },
          "seatingMode": {
            "type": "string",
            "enum": [
              "on_pay",
              "all_at_once",
              "manual"
            ]
          },
          "isPrivate": {
            "type": "boolean"
          },
          "plannedTableCount": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "expectedPlayerCount": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "minigames": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "active": {
                  "type": "boolean"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "tally",
                    "ranked",
                    "judged"
                  ]
                }
              },
              "required": [
                "name",
                "active"
              ],
              "additionalProperties": false
            }
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "multiTable": {
                "type": "boolean"
              },
              "dealMaking": {
                "type": "boolean"
              },
              "delegation": {
                "type": "boolean"
              },
              "payoutAutomation": {
                "type": "boolean"
              }
            },
            "required": [
              "multiTable",
              "dealMaking",
              "delegation",
              "payoutAutomation"
            ],
            "additionalProperties": false,
            "description": "Adaptive UI flags for this session (lib/capabilities.ts)."
          }
        },
        "required": [
          "locale",
          "currency",
          "timezone",
          "sessionStatus",
          "checkedIn",
          "paidCount",
          "remaining",
          "eliminated",
          "clockState",
          "blinds",
          "chipDenominations",
          "chipSet",
          "chipDistribution",
          "currentBlind",
          "nextBlind",
          "rebuyCutoffLevel",
          "tableStats",
          "maxPlayersPerTable",
          "recentEliminations",
          "prizePool",
          "totalRebuys",
          "totalAddons",
          "rebuyPrice",
          "addonPrice",
          "tableNames",
          "dealerDraws",
          "buyInAmount",
          "startingStack",
          "startedAt",
          "addonCutoffLevel",
          "payoutStructure",
          "seatingMode",
          "isPrivate",
          "plannedTableCount",
          "expectedPlayerCount",
          "minigames",
          "capabilities"
        ],
        "additionalProperties": false,
        "description": "Complete snapshot of a live tournament: clock, players, blinds, tables, prize pool."
      },
      "RosterPlayer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "description": "Managers only.",
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "nickname": {
            "type": "string"
          },
          "first_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_name": {
            "description": "Managers only.",
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "description": "Managers only.",
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "description": "Managers only.",
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "description": "Managers only. The host's private notes on the player.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "pin": {
            "description": "Managers only. The 4-digit at-table PIN, plaintext by design.",
            "type": [
              "string",
              "null"
            ]
          },
          "pin_failed_attempts": {
            "description": "Managers only. Consecutive wrong PINs since the last correct one or the last set/reset.",
            "type": "integer",
            "minimum": 0
          },
          "pin_locked_until": {
            "description": "Managers only. Set while the PIN is locked after too many wrong attempts. A PIN reset clears it.",
            "type": [
              "string",
              "null"
            ]
          },
          "user_id": {
            "description": "Managers only. The claimed account, or null for an unclaimed row.",
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_by": {
            "description": "Managers only.",
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "erased_at": {
            "description": "Managers only. Set when the row was erased (a tombstone). An erased row cannot be edited.",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "description": "Managers only.",
            "type": "string"
          },
          "updated_at": {
            "description": "Managers only.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "nickname",
          "first_name",
          "status"
        ],
        "additionalProperties": false
      },
      "CreatePlayer": {
        "type": "object",
        "properties": {
          "nickname": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 20
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "pin": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\d{4}$"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "nickname"
        ],
        "additionalProperties": false,
        "description": "One new roster player. `pin` is the 4-digit at-table PIN; omit it and the host sets one later."
      },
      "Elimination": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "eliminated_by_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "bounty_won": {
            "type": [
              "number",
              "null"
            ]
          },
          "table_number": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "eliminated_at": {
            "type": "string"
          },
          "nickname": {
            "description": "Joined from the roster row on the list endpoint.",
            "type": "string"
          },
          "eliminated_by_nickname": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "eliminated_by_id",
          "bounty_won",
          "table_number",
          "notes",
          "eliminated_at"
        ],
        "additionalProperties": false,
        "description": "A bust. Finishing position is not stored here: it is derived from elimination order and written to the results rows when the tournament is finalized."
      },
      "RecordElimination": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "rosterPlayerId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "eliminatedById": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "tableNumber": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "sessionId",
          "rosterPlayerId"
        ],
        "additionalProperties": false,
        "description": "A bust. Omit `eliminatedById` for a walk-away. Finishing position is not sent: it falls out of elimination order when the tournament is finalized."
      },
      "CheckIn": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "payment_status": {
            "type": "string",
            "enum": [
              "paid",
              "unpaid"
            ]
          },
          "rebuy_count": {
            "type": "integer"
          },
          "addon_count": {
            "type": "integer"
          },
          "checked_in_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "payment_status",
          "rebuy_count",
          "addon_count",
          "checked_in_at"
        ],
        "additionalProperties": false
      },
      "BlindLevel": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "small_blind": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000
          },
          "big_blind": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000
          },
          "ante": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000
          },
          "duration_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 600
          },
          "is_break": {
            "type": "boolean"
          }
        },
        "required": [
          "level",
          "small_blind",
          "big_blind"
        ],
        "additionalProperties": false
      },
      "BlindsConfig": {
        "maxItems": 200,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "level": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "small_blind": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000000
            },
            "big_blind": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000000
            },
            "ante": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000000
            },
            "duration_minutes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 600
            },
            "is_break": {
              "type": "boolean"
            }
          },
          "required": [
            "level",
            "small_blind",
            "big_blind"
          ],
          "additionalProperties": false
        }
      },
      "PayoutStructure": {
        "type": "object",
        "properties": {
          "positions": {
            "maxItems": 1000,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "position": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 1000
                },
                "percentage": {
                  "default": 0,
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                "amount": {
                  "type": "number",
                  "minimum": 0
                }
              },
              "required": [
                "position",
                "percentage"
              ],
              "additionalProperties": false
            }
          },
          "schedule": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 100
              },
              "rows": {
                "maxItems": 500,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "players": {
                      "type": "integer",
                      "minimum": 2,
                      "maximum": 500
                    },
                    "prize_pool": {
                      "type": "number",
                      "minimum": 0
                    },
                    "positions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "position": {
                            "type": "integer",
                            "minimum": 1
                          },
                          "amount": {
                            "type": "number",
                            "minimum": 0
                          }
                        },
                        "required": [
                          "position",
                          "amount"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "players",
                    "prize_pool",
                    "positions"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "name",
              "rows"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "positions"
        ],
        "additionalProperties": false
      },
      "SessionParticipant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "created_at": {
            "type": "string"
          },
          "nickname": {
            "type": "string",
            "description": "Joined from the roster row."
          },
          "checked_in": {
            "type": "boolean"
          },
          "payment_status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "paid",
                  "unpaid"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Null when the player is on the participant list but not checked in."
          },
          "rebuy_count": {
            "type": "integer"
          },
          "addon_count": {
            "type": "integer"
          },
          "is_eliminated": {
            "type": "boolean"
          },
          "elimination_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "finish_place": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "description": "Finishing place so far, 1 = winner. Null while the player is still in."
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "created_at",
          "nickname",
          "checked_in",
          "payment_status",
          "rebuy_count",
          "addon_count",
          "is_eliminated",
          "elimination_id",
          "finish_place"
        ],
        "additionalProperties": false
      },
      "SessionManager": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "user_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "nickname": {
            "type": "string"
          },
          "delegated_at": {
            "type": "string"
          },
          "email": {
            "description": "Null for callers below the manager role, which never see member emails.",
            "type": [
              "string",
              "null"
            ]
          },
          "can_control_clock": {
            "type": "boolean"
          },
          "can_check_in_players": {
            "type": "boolean"
          },
          "can_assign_tables": {
            "type": "boolean"
          },
          "can_record_eliminations": {
            "type": "boolean"
          },
          "can_enter_results": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "user_id",
          "nickname",
          "delegated_at",
          "email",
          "can_control_clock",
          "can_check_in_players",
          "can_assign_tables",
          "can_record_eliminations",
          "can_enter_results"
        ],
        "additionalProperties": false
      },
      "Rsvp": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for a walk-up RSVP from the public code page that matched no roster row."
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "response": {
            "type": "string",
            "enum": [
              "yes",
              "no",
              "maybe"
            ]
          },
          "responded_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "name",
          "email",
          "response",
          "responded_at"
        ],
        "additionalProperties": false
      },
      "Result": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "nickname": {
            "type": "string"
          },
          "finish_position": {
            "type": "integer"
          },
          "points": {
            "type": "integer"
          },
          "points_override": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "description": "A host's manual correction. Every standings surface reads this over `points`."
          },
          "points_override_reason": {
            "description": "Shown to the player. Required whenever `points_override` is set.",
            "type": [
              "string",
              "null"
            ]
          },
          "payout_amount": {
            "type": [
              "number",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "nickname",
          "finish_position",
          "points",
          "points_override",
          "points_override_reason",
          "payout_amount",
          "created_at"
        ],
        "additionalProperties": false
      },
      "PlayerRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "request_type": {
            "type": "string",
            "enum": [
              "knockout",
              "rebuy",
              "minigame"
            ]
          },
          "target_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "eliminated_by_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "payload": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "declined",
              "auto_resolved"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "resolved_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "request_type",
          "target_player_id",
          "eliminated_by_id",
          "payload",
          "status",
          "created_at",
          "resolved_at"
        ],
        "additionalProperties": false
      },
      "TableAssignment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "game_session_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "roster_player_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "table_number": {
            "type": "integer",
            "minimum": 1
          },
          "seat_number": {
            "type": "integer",
            "minimum": 1
          },
          "created_at": {
            "type": "string"
          },
          "nickname": {
            "type": "string"
          },
          "is_eliminated": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "org_id",
          "game_session_id",
          "roster_player_id",
          "table_number",
          "seat_number",
          "created_at"
        ],
        "additionalProperties": false,
        "description": "A seat. There is no parking seat: table and seat are both >= 1 by CHECK constraint."
      },
      "Season": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "year": {
            "type": "integer"
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "scoring_config": {
            "type": "object",
            "properties": {
              "bestNOfM": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "best": {
                        "type": "integer"
                      },
                      "of": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "best",
                      "of"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": false
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "year",
          "start_date",
          "end_date",
          "is_active",
          "scoring_config",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      },
      "SetupTemplate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "owner_user_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "source_org_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "share_code": {
            "type": "string",
            "description": "Import this template into another org with POST /setups { shareCode }."
          },
          "is_public": {
            "type": "boolean"
          },
          "buy_in_amount": {
            "type": [
              "number",
              "null"
            ]
          },
          "starting_stack": {
            "type": "integer"
          },
          "level_duration_minutes": {
            "type": "integer"
          },
          "blinds_config": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "small_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "big_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "ante": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "duration_minutes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "is_break": {
                  "type": "boolean"
                }
              },
              "required": [
                "level",
                "small_blind",
                "big_blind"
              ],
              "additionalProperties": false
            }
          },
          "rebuy_allowed": {
            "type": "boolean"
          },
          "rebuy_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "rebuy_chips": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "max_rebuys": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "rebuy_cutoff_level": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "addon_allowed": {
            "type": "boolean"
          },
          "addon_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "addon_chips": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "addon_cutoff_level": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "table_names": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "payout_structure": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "positions": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "position": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000
                        },
                        "percentage": {
                          "default": 0,
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "amount": {
                          "type": "number",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "position",
                        "percentage"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "schedule": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "rows": {
                        "maxItems": 500,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "players": {
                              "type": "integer",
                              "minimum": 2,
                              "maximum": 500
                            },
                            "prize_pool": {
                              "type": "number",
                              "minimum": 0
                            },
                            "positions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "position": {
                                    "type": "integer",
                                    "minimum": 1
                                  },
                                  "amount": {
                                    "type": "number",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "position",
                                  "amount"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "players",
                            "prize_pool",
                            "positions"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "name",
                      "rows"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "positions"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "prize_pool_deduction": {
            "type": [
              "number",
              "null"
            ]
          },
          "max_players_per_table": {
            "type": "integer"
          },
          "seating_mode": {
            "type": "string",
            "enum": [
              "on_pay",
              "all_at_once",
              "manual"
            ]
          },
          "bounty_amount": {
            "type": [
              "number",
              "null"
            ]
          },
          "bounty_type": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "standard",
                  "progressive"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "minigames": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "record_to_career": {
            "type": "boolean"
          },
          "complexity": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "casual",
                  "pro"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "planned_table_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "expected_player_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "blind_schedule_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "chip_set_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "payout_schedule_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "point_chart_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "chip_set_json": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "color": {
                      "type": "string"
                    },
                    "denomination": {
                      "type": "number"
                    },
                    "quantity": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "color",
                    "denomination"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "chip_distribution_json": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "denomination": {
                      "type": "number"
                    },
                    "quantity": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "denomination",
                    "quantity"
                  ],
                  "additionalProperties": false
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "use_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "owner_user_id",
          "source_org_id",
          "name",
          "description",
          "share_code",
          "is_public",
          "buy_in_amount",
          "starting_stack",
          "level_duration_minutes",
          "blinds_config",
          "rebuy_allowed",
          "rebuy_price",
          "rebuy_chips",
          "max_rebuys",
          "rebuy_cutoff_level",
          "addon_allowed",
          "addon_price",
          "addon_chips",
          "addon_cutoff_level",
          "table_names",
          "payout_structure",
          "prize_pool_deduction",
          "max_players_per_table",
          "seating_mode",
          "bounty_amount",
          "bounty_type",
          "minigames",
          "record_to_career",
          "complexity",
          "planned_table_count",
          "expected_player_count",
          "blind_schedule_id",
          "chip_set_id",
          "payout_schedule_id",
          "point_chart_id",
          "chip_set_json",
          "chip_distribution_json",
          "use_count",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false,
        "description": "A reusable tournament configuration. A `*_id` reference wins over the matching embedded snapshot, so send the id fields explicitly on PUT or the route infers a detach from a snapshot that differs from the stored one."
      },
      "BlindSchedule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "description": "Drives the most-recently-used ordering every Library list returns.",
            "type": [
              "string",
              "null"
            ]
          },
          "use_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "blinds_json": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 200
                },
                "small_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "big_blind": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "ante": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 100000000
                },
                "duration_minutes": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 600
                },
                "is_break": {
                  "type": "boolean"
                }
              },
              "required": [
                "level",
                "small_blind",
                "big_blind"
              ],
              "additionalProperties": false
            }
          },
          "level_duration_minutes": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "description",
          "last_used_at",
          "use_count",
          "created_at",
          "updated_at",
          "blinds_json",
          "level_duration_minutes"
        ],
        "additionalProperties": false
      },
      "ChipSet": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "description": "Drives the most-recently-used ordering every Library list returns.",
            "type": [
              "string",
              "null"
            ]
          },
          "use_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "chips_json": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "color": {
                  "type": "string"
                },
                "denomination": {
                  "type": "number"
                },
                "quantity": {
                  "type": "integer"
                }
              },
              "required": [
                "color",
                "denomination"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "description",
          "last_used_at",
          "use_count",
          "created_at",
          "updated_at",
          "chips_json"
        ],
        "additionalProperties": false
      },
      "PayoutSchedule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "description": "Drives the most-recently-used ordering every Library list returns.",
            "type": [
              "string",
              "null"
            ]
          },
          "use_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "rows_json": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "players": {
                  "type": "integer"
                },
                "prize_pool": {
                  "type": "number"
                },
                "positions": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "position": {
                        "type": "integer"
                      },
                      "amount": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "position",
                      "amount"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "players",
                "prize_pool",
                "positions"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "description",
          "last_used_at",
          "use_count",
          "created_at",
          "updated_at",
          "rows_json"
        ],
        "additionalProperties": false
      },
      "PointChart": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_used_at": {
            "description": "Drives the most-recently-used ordering every Library list returns.",
            "type": [
              "string",
              "null"
            ]
          },
          "use_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "rows_json": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "players": {
                  "type": "integer"
                },
                "positions": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "position": {
                        "type": "integer"
                      },
                      "points": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "position",
                      "points"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "players",
                "positions"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "org_id",
          "name",
          "description",
          "last_used_at",
          "use_count",
          "created_at",
          "updated_at",
          "rows_json"
        ],
        "additionalProperties": false
      },
      "TimelineEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "type": {
            "type": "string",
            "description": "Event type, e.g. `level_advance`, `pause`, `elimination`, `table_reseat`."
          },
          "created_at": {
            "type": "string"
          },
          "actor_user_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "actor_nickname": {
            "type": [
              "string",
              "null"
            ]
          },
          "actor_label": {
            "description": "Who acted when the actor was not an account: a companion player, or the clock itself.",
            "type": [
              "string",
              "null"
            ]
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {},
            "description": "Event-specific payload. Its keys depend on `type`."
          },
          "player_nickname": {
            "type": [
              "string",
              "null"
            ]
          },
          "eliminated_by_nickname": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "created_at",
          "actor_user_id",
          "actor_nickname",
          "actor_label",
          "data",
          "player_nickname",
          "eliminated_by_nickname"
        ],
        "additionalProperties": false
      },
      "OrgInvite": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "org_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "email": {
            "description": "A delivery label only. Invites are not emailed and the address is never matched against the roster.",
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "manager",
              "player"
            ]
          },
          "token": {
            "type": "string"
          },
          "invited_by": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "expires_at": {
            "type": "string"
          },
          "accepted_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "game_session_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "roster_player_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "org_id",
          "email",
          "role",
          "token",
          "invited_by",
          "expires_at",
          "accepted_at",
          "created_at",
          "game_session_id",
          "roster_player_id"
        ],
        "additionalProperties": false
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "manager",
              "player"
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "display": {
            "type": "string",
            "description": "Masked form for display, e.g. `ck_live_abc1...`."
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "role",
          "scopes",
          "last_used_at",
          "expires_at",
          "created_at",
          "display"
        ],
        "additionalProperties": false,
        "description": "An issued key with the secret removed. The plaintext is returned once, at create."
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ck_live_*",
        "description": "Agent API key. Issue from `/orgs/{slug}/settings/api-keys`. Include as `Authorization: Bearer ck_live_<token>`. Scoped per organization with granular permissions."
      },
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "sb-access-token",
        "description": "Supabase session cookie. Set by the web UI login flow. Not suitable for agents."
      }
    }
  },
  "tags": [
    {
      "name": "System",
      "description": "Health and meta endpoints. Use `/api/health` for uptime monitoring — it does not check DB connectivity."
    },
    {
      "name": "Public",
      "description": "No-auth endpoints. Most are gated by session UUID — private sessions return 404. Start here with `POST /api/quickstart` for agent bootstrap."
    },
    {
      "name": "Clock",
      "description": "Tournament clock control. Use `next-level` with `force: true` behind a confirm dialog on UIs — that bypasses the 2-second cooldown that protects against two devices racing."
    },
    {
      "name": "Sessions",
      "description": "Tournament CRUD + lifecycle. Creating a session always creates a matching `clock_state` row — never write to `clock_state` directly."
    },
    {
      "name": "Players",
      "description": "Org roster management. Roster is per-org, not per-session. A `check_in` row joins a roster player to a specific tournament."
    },
    {
      "name": "Eliminations",
      "description": "Busting players from a tournament. `eliminated_by_id` is optional — omit it for walk-away busts. Always includes a `session_events` audit entry."
    },
    {
      "name": "Tables",
      "description": "Seating and table balancing. Set the session's `seating_mode` to `on_pay` to have the server auto-seat players at check-in."
    },
    {
      "name": "Organizations",
      "description": "Tenant administration. Most org-level settings are behind admin role. API keys cannot manage other keys — rotate via the web UI."
    },
    {
      "name": "Library",
      "description": "Org-owned reusable blocks: blind schedules, chip sets, payout schedules, point charts, league rules. A tournament snapshots a block's content at creation, so editing a block never rewrites a game in progress."
    },
    {
      "name": "Templates",
      "description": "Reusable tournament configurations. Share via short code; import by code creates a local copy so edits don't propagate."
    },
    {
      "name": "Stats",
      "description": "Leaderboards and analytics. Season standings and per-player stats are read-only — the writes happen implicitly when eliminations + results are recorded."
    },
    {
      "name": "Seasons",
      "description": "Grouping tournaments across time. A session belongs to at most one season (via `season_id`). Best-of-N scoring configured per-season."
    },
    {
      "name": "Billing",
      "description": "Stripe Checkout and Customer Portal. Agent keys cannot initiate checkout — billing is a web-UI action."
    },
    {
      "name": "API Keys",
      "description": "Agent API key management — create, list, revoke. Cannot be invoked via a Bearer key (prevents key-rotation loops); use the web UI."
    }
  ]
}