# PokerLeagueOS > The operating system for poker leagues: seasons, schedules, standings, seating, blinds and payouts for the organizer, plus a live companion for every player. An agent acting on behalf of a human can create an organization, issue an API key, and start a live tournament in a single HTTP call. Human companion UI lives at https://pokerleagueos.com. ## Try it in one request ``` curl -X POST https://pokerleagueos.com/api/quickstart \ -H "content-type: application/json" \ -d '{"org_name":"Demo League"}' ``` The response contains: - `api_key` — `ck_live_…` Bearer token. Shown exactly once. Store it. - `org_slug` — use in every follow-up URL: `/api/orgs/{org_slug}/…`. - `session_id` — pre-provisioned demo tournament with DEFAULT_BLINDS. - `next_actions[]` — the first endpoints an agent will typically call. - `expires_at`: trial orgs auto-delete 7 days after creation. **Not idempotent.** A blind retry after network timeout creates a second trial org — see `hints.retry_safety` in the response. Rate limit: 5 trial orgs per hour per IP (advisory — best-effort on serverless). ### Immediately after quickstart ``` # Start the clock (use api_key as Bearer, session_id from the response) curl -X POST https://pokerleagueos.com/api/orgs/{org_slug}/clock \ -H "Authorization: Bearer {api_key}" \ -H "content-type: application/json" \ -d '{"sessionId":"{session_id}","action":"start"}' # Add a player curl -X POST https://pokerleagueos.com/api/orgs/{org_slug}/players \ -H "Authorization: Bearer {api_key}" \ -H "content-type: application/json" \ -d '{"nickname":"Alice"}' ``` ## API Reference - [OpenAPI 3.1 spec](https://pokerleagueos.com/openapi.json) — machine-readable. Feed this to Vercel AI SDK, OpenAI Agents SDK, or any OpenAPI-aware tool-discovery framework. - [llms-full.txt](https://pokerleagueos.com/llms-full.txt) — expanded reference with example requests, response shapes, and common agent workflows. ## Core Concepts - **Organization** — Tenant unit. Every row is scoped by `org_id`. URL-addressable by slug: `/api/orgs/{slug}/...`. Roles: `owner > admin > manager > player`. - **Session**: a single tournament event. Status: `scheduled` | `active` | `paused` | `completed` | `cancelled`. Has `blinds_config`, `buy_in_amount`, `payout_structure`, `starting_stack`. - **Clock** — Real-time tournament timer. Advances through blind levels, auto-advances when time hits zero. Drift-corrected via `last_updated_at`. - **Roster Player** — Named player in an org. Carries a 4-digit `pin` for self-service. - **Check-in** — Links a roster player to a session with payment status and rebuy/addon counts. - **Elimination** — Records when a player busts, who eliminated them, and the resulting position. - **Payout structure** — Percentage-based prize distribution. Presets: `top3`, `top5`. - **Table assignment** — Maps players to tables and seats. Supports seat-on-pay. - **Trial org** — Org created via `POST /api/quickstart`. `created_via = "quickstart"`, `trial_ends_at = +7 days`. Auto-deleted by daily cleanup cron unless converted (v1.1). ## Authentication Three modes. Agents should use API keys. - **API key (agents)** — `Authorization: Bearer ck_live_`. Org-scoped. Issued by `POST /api/quickstart` (new orgs) or `POST /api/orgs/{slug}/api-keys` (existing orgs). Revoke via the same route's DELETE. - **Supabase session cookie (humans)** — Set by the web UI login flow. Not suitable for agents. - **Session UUID (public, read-only)** — Public endpoints accept a session UUID as a read-only access token. Private, not-yet-started and deleted-league sessions return 404. - **Player PIN** — 4-digit PIN on `roster_players.pin` gates self-service player actions (rebuy requests, re-seat requests). - **Claiming**: attaches a roster row to an account for cross-session access. The PIN stays the at-table credential; claiming is a separate, optional layer on top of it. ## Agent-Friendly Conventions - **Errors** — Every non-2xx response returns a flat envelope: `{ error, code, message, hint, doc_url, next_actions }`. `error` is the legacy string for frontend compat. `code` is always present and comes from the closed enum on the `ErrorEnvelope` schema in `/openapi.json`. Agents should read `code`, `hint`, and `next_actions[]` to choose the next tool call. - **Idempotency**: some mutating endpoints accept an `Idempotency-Key: ` header; the same key within 24h returns the cached response, so a timeout is safe to retry. Concurrent duplicates are safe too: the key is reserved before the handler runs, and the second request gets 409 `idempotency_key_in_flight` rather than executing a second time. `/openapi.json` marks which ones (look for the `Idempotency-Key` parameter): the clock, eliminations POST and DELETE, session create/clone, check-in, rebuys, results, notify, recap, api-keys, players, setups create/duplicate, player-requests and the four Library collections. Everywhere else the header is ignored. - Exception: `POST /api/quickstart` is deliberately **not** idempotent — each call creates a fresh trial org. - **Rate limits**: 429 responses include `Retry-After` header (seconds). Per-IP limits: 5/hour quickstart, 5/min org create, 30/min host clock actions, 60/min public reads, 10/min public writes, 3/min mail sends; PIN checks allow 5 attempts per 15 minutes per player and IP, and 5 consecutive wrong PINs lock that player for 15 minutes across every IP; API-key writes are capped at 120/min per org. llms-full.txt has the full table. - **Response shapes** — 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: it wraps its rows in `{ data, total }`. `/openapi.json` carries the full schema for every request body and every response. - **Multi-tenancy** — Every data row belongs to exactly one org. API keys cannot cross org boundaries. ## Public Endpoints (no auth, session UUID only) - [/api/quickstart](https://pokerleagueos.com/api/quickstart) — POST only. Creates a trial org, session, clock, and API key in one request. See top of this file. - [/api/health](https://pokerleagueos.com/api/health) — Liveness probe. Returns `{ ok: true, ts }`. - [/api/live-tournament?sessionId={uuid}](https://pokerleagueos.com/api/live-tournament) — Single-request snapshot of all live tournament state — clock, blinds, players, eliminations, prize pool, table stats. - [/api/clock?sessionId={uuid}](https://pokerleagueos.com/api/clock) — Clock state only (current level, time remaining, running/paused). - [/api/public-table-assignments?sessionId={uuid}](https://pokerleagueos.com/api/public-table-assignments) — Who's sitting at which table and seat. - [/api/public-player-requests](https://pokerleagueos.com/api/public-player-requests) — Submit a rebuy/re-seat/knockout request (POST, requires the player's PIN). Hosts read the pending queue through `GET /api/orgs/{slug}/sessions/{id}/player-requests`. - [/api/public-player-pin](https://pokerleagueos.com/api/public-player-pin) — Set or verify a player's 4-digit PIN. Set requires nickname match to prevent PIN-spraying. - [/api/public-cohost-invite](https://pokerleagueos.com/api/public-cohost-invite) — Fetch the co-host handoff link aimed at this player (POST, requires the player's PIN). The host creates it with `POST /api/orgs/{slug}/sessions/{id}/managers/handoff`; the companion is nudged over Broadcast and fetches the link here. Claimed members use `GET /api/orgs/{slug}/me/cohost-invite?sessionId=` instead. - [/api/public-feed?sessionId={uuid}](https://pokerleagueos.com/api/public-feed) — Chronological feed of tournament events. - [/api/public-session-timeline?sessionId={uuid}](https://pokerleagueos.com/api/public-session-timeline): host-action timeline for this tournament. - [/api/public-season-standings?sessionId={uuid}](https://pokerleagueos.com/api/public-season-standings): standings for the season this tournament belongs to. - [/api/public-active-season-standings?sessionId={uuid}](https://pokerleagueos.com/api/public-active-season-standings): live/provisional season standings while the tournament is still running. Eliminated players hold their real finish position; every player still alive is scored at the next position to be awarded, so values move on each bust. - [/api/public-minigame-leaderboard?sessionId={uuid}](https://pokerleagueos.com/api/public-minigame-leaderboard): minigame winners and per-player tallies. - [/api/public-player-career?sessionId={uuid}&rosterPlayerId={uuid}](https://pokerleagueos.com/api/public-player-career): one player's career history, achievements, and head-to-head record. `scope` selects all-time vs season. - [/api/public-player-tournament?sessionId={uuid}&tournamentSessionId={uuid}&rosterPlayerId={uuid}](https://pokerleagueos.com/api/public-player-tournament): one player's detail for one completed tournament; without `rosterPlayerId`, its finishing order. - [/api/public-claim-otp](https://pokerleagueos.com/api/public-claim-otp): POST, `{ sessionId, email }`. Emails a code to claim the roster row on file for that address. The response is the same constant message whether or not the address matched, so this cannot be used to enumerate a roster. - [/api/rsvp/{code}](https://pokerleagueos.com/api/rsvp/{code}): `GET` reads the session and its RSVP names and responses; `POST` `{ name, email?, response: yes|no|maybe, rsvp_id? }` records one and returns its `id`; the same email, or an email-less answer's `rsvp_id`, replaces the earlier answer. Keyed by the 8-character `rsvpCode` from `POST /api/orgs/{slug}/sessions/{id}/rsvp`, not a session UUID; private sessions 404. Rate-limited per IP and code. - [/api/public-claim-complete](https://pokerleagueos.com/api/public-claim-complete): POST, `{ sessionId }`. Call after verifying the emailed code client-side (Supabase `verifyOtp`); links the now-authenticated caller's account to the `sessionId` roster row matching their email. Every public endpoint above except quickstart, health and the RSVP pair is keyed by the **live** `sessionId`. That UUID is the access token and the only tenant key a public caller supplies. A session that does not exist, is private, has not started yet (status `scheduled`), or belongs to a league pending deletion answers 404; only the claim endpoints accept a scheduled session. Two human-facing pages, not API endpoints, follow the same no-auth rule: - [/league/{slug}](https://pokerleagueos.com/league/{slug}): a league's public home page, standings, the next scheduled game, recent results. On by default; an org can turn it off in settings. - [/claim/{sessionId}](https://pokerleagueos.com/claim/{sessionId}): claim a roster seat and turn it into an account, keyed by session UUID like the endpoints above. ## Authenticated Endpoints (org-scoped) All under `/api/orgs/{slug}/...`. Require a Supabase session cookie or an API key. ### Sessions (tournaments) - `GET|POST /api/orgs/{slug}/sessions`: List or create tournaments. Set `scheduled_for` (ISO datetime) on create to make it `scheduled` instead of `active`; `PATCH` status to `active` is what starts it for real. Create answers 403 `subscription_required` when the league has no active plan and `plan_field_exceeded` while its last tournament had more check-ins than its plan carries; check-ins themselves are never refused for size. Starting a scheduled session passes the same two checks. - `GET|PATCH|DELETE /api/orgs/{slug}/sessions/{id}` — Single tournament. PATCH takes `is_private` to hide or unhide every public surface for it. - `POST /api/orgs/{slug}/sessions/{id}/clone` — Clone for re-run. Carries the full config, including bounties, minigames, cutoff levels and privacy. Passes the same plan checks as create (`subscription_required`, `plan_field_exceeded`). - `GET|POST|DELETE /api/orgs/{slug}/sessions/{id}/participants` — Add or drop a player for one tournament. POST takes `{ rosterPlayerId, checkIn? }`; DELETE takes no body and names the player as `?rosterPlayerId={uuid}`. - `POST /api/orgs/{slug}/sessions/{id}/managers/handoff` — Mint a single-use co-host link (default 30 minutes). - `POST|DELETE /api/orgs/{slug}/sessions/{id}/check-in` — Check a player in with `{ rosterPlayerId }`, or set payment with `{ rosterPlayerId, paymentStatus: paid|unpaid }`, which also seats or unseats them when the session's `seating_mode` is `on_pay`. DELETE takes no body and names the player as `?rosterPlayerId={uuid}`. - `POST /api/orgs/{slug}/sessions/{id}/rebuys` — Record or remove a rebuy/add-on (`{ rosterPlayerId, type, action }`). Counts come back on the check-in and live-tournament reads. - `GET|POST /api/orgs/{slug}/sessions/{id}/results` — Final standings. Rows take `rosterPlayerId` + `finishPosition`; `points` and `payoutAmount` are resolved from the session's point chart and payout structure when omitted. `pointsOverride` (org admin only) replaces a player's season points and requires `pointsOverrideReason`, which the player is shown; send `null` to clear one. - `GET /api/orgs/{slug}/sessions/{id}/participants` — Who's in this session. - `GET|POST|DELETE /api/orgs/{slug}/sessions/{id}/managers` — Session-level manager delegation. DELETE takes no body and names the row as `?managerId={uuid}`. - `POST /api/orgs/{slug}/sessions/{id}/notify` — Send email reminders. Requires `audience`: `rsvp_yes`, `checked_in`, `roster`, or `custom` with `playerIds`. - `POST /api/orgs/{slug}/sessions/{id}/recap` — Email the results recap to checked-in players now. Session must be completed with results saved; one send per session (409 `recap_already_sent` after). - `GET /api/orgs/{slug}/sessions/{id}/player-requests` — Pending player self-service requests (host side). - `PATCH /api/orgs/{slug}/sessions/{id}/player-requests` — Resolve one: `{ requestId, action: accept|decline|revoke }`. - `POST /api/orgs/{slug}/sessions/{id}/player-requests` — Record a minigame result: `{ targetPlayerId, minigame, hand? }`. - `GET|POST /api/orgs/{slug}/sessions/{id}/rsvp` — GET lists the responses. POST takes no body: it returns the session's RSVP code, minting one on the first call, which is what `/api/rsvp/{code}` is keyed on. - `GET|POST /api/orgs/{slug}/sessions/{id}/timeline`: host-action timeline for a tournament (read, or append an entry). - `PATCH /api/orgs/{slug}/sessions/{id}/minigame-order`: reorder minigame results (sets the displayed ranking). ### Clock - `GET /api/orgs/{slug}/clock?sessionId={uuid}` — Authenticated clock state. - `POST /api/orgs/{slug}/clock` — Actions: `start`, `pause`, `resume`, `next-level`, `prev-level`, `set-level`, `adjust-time`, `toggle-hand-for-hand`. ### Roster & players - `GET|POST /api/orgs/{slug}/players` — Roster list/create. - `GET|PATCH /api/orgs/{slug}/players/{playerId}` — Single player. - `PUT|DELETE /api/orgs/{slug}/players/{playerId}/link`: admin links or unlinks a roster row to a member account. - `POST /api/orgs/{slug}/players/{playerId}/claim-link`: manager mints a claim link for the row's email. - `POST /api/orgs/{slug}/players/{playerId}/merge`: admin merges a duplicate roster row into this one. - `POST /api/orgs/{slug}/players/{playerId}/erase`: admin erases a roster row, irreversibly. Nulls contact details, PIN, notes and the account link, archives the row and stamps `erased_at`; PATCH on it is refused from then on. The row itself survives because every result the player recorded points at it. `tier` picks how much of the name stays: `removed` (default) keeps a first name and last initial so standings stay legible, `erased` keeps only a tombstone. - `POST /api/invites/{token}/claim`: authenticated, claims the roster row a claim link points at; the caller's own email must match. - `GET|POST|DELETE /api/orgs/{slug}/eliminations` — List, record, or undo an elimination. - `GET|POST /api/orgs/{slug}/table-assignments` — Seat management. ### Member self-service (/me) Acts as the signed-in member making the call, not a target id in the path. Not available to API keys: these are personal, interactive-session actions, so a Bearer key request is rejected. - `GET /api/orgs/{slug}/me`: the member home. Your linked roster player (if any), the next scheduled or public game, and any tournament live right now. - `PATCH /api/orgs/{slug}/me/profile`: update your own nickname, name, email or phone. - `POST /api/orgs/{slug}/me/pin`: set or reset your own PIN. - `POST /api/orgs/{slug}/me/rsvp`: RSVP yourself to a tournament: `{ game_session_id, response }`. - `DELETE /api/me`: delete your own account, outright. Body must carry `confirm` set to your own email address. Refused with `owns_organizations` while you still own a league that is not already deleted; the hint names them. Roster rows in leagues you merely played in are not touched: those belong to the host, and only the account link is severed. - `GET /api/me/session-identity`: resolve your own linked roster player for a live session, keyed by session UUID only (no org key), so a claimed member can skip the PIN picker at the table. Always 200; `{ linked: false }` when there's no match. - `POST /api/orgs/{slug}/me/requests`: file a knockout, rebuy or minigame request as your own claimed roster row, no PIN needed. Account-authenticated twin of the public PIN-based request endpoint. ### Org admin - `POST /api/orgs`: create a league owned by the signed-in account (`{ name, slug, timezone? }`). Session cookie only: an API key belongs to one org. 409 `slug_taken` when the slug is held, including by a league pending deletion. - `GET|PATCH|DELETE /api/orgs/{slug}/members` — Org membership. PATCH changes a member's role. - `DELETE /api/orgs/{slug}` — Owner-only, and not available to API keys. Deletes the league. Body must carry `confirm` set to the org's own slug. Marks it deleted rather than removing it: every surface stops serving it at once and its API keys are destroyed, then the row and everything under it goes 15 days later. Restoring inside that window is a support request. - `GET /api/orgs/{slug}/export` — Admin-only. The whole league as a JSON attachment: members, invites, roster, seasons, tournaments and their children, plus the Library. Excludes API keys, idempotency keys and telemetry. This is the data-access and portability answer, and the thing to call before the DELETE above. - `GET|PATCH /api/orgs/{slug}/settings` — Org settings, including `timezone` (IANA zone, curated allowlist of US and European zones), `currency` (`USD` / `GBP` / `EUR`, display only, nothing is converted) and `locale` (`en` / `de` / `fr` / `es`, the language the league's UI, companion and mail render in). The API, this file and the OpenAPI document are English in every locale. - `GET|POST /api/orgs/{slug}/invites` — Invite tokens. `DELETE /api/orgs/{slug}/invites/{inviteId}` revokes one that has not been accepted. - `GET|POST|DELETE /api/orgs/{slug}/api-keys` — API key management. Cannot be invoked via a Bearer key — a key cannot manage other keys. Use the web UI. - `GET|POST /api/orgs/{slug}/setups`: tournament templates ("Setup Templates" in the UI Library). A template holds everything a tournament is created with — blinds, chips, payouts, rebuy/add-on rules and cutoff levels, bounties, minigames, points, seating, persona, expected size. It does not hold `is_private`; that stays a per-event choice. - `GET|PUT|DELETE /api/orgs/{slug}/setups/{setupId}` — Single template. PUT is partial; omitted fields keep their value. `blind_schedule_id` / `payout_schedule_id` / `chip_set_id` link the template to 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 link drops only if you send a snapshot that differs from the stored one. A block owned by another org is stored as null. The embedded snapshots are named `chip_set` and `chip_distribution` on both create and update. - `POST /api/orgs/{slug}/setups/{setupId}/duplicate`: copy a template. - `GET /api/orgs/{slug}/sessions/live`: the running (active or paused) tournament as `{ session: { id, name, status } | null }`. Managers only. - `GET /api/orgs/{slug}/plan-status`: current tier, roster usage against the plan's roster limit, and `checkInLimit`, the players per tournament the plan carries. - `GET /api/orgs/{slug}/leaderboard` — Org leaderboard. `?season=` for a season, `?season=rolling` for a rolling league's window of recent tournaments. - `GET|POST /api/orgs/{slug}/seasons` — Season CRUD. - `GET|PATCH|DELETE /api/orgs/{slug}/seasons/{seasonId}` — Single season. - `GET /api/orgs/{slug}/seasons/{seasonId}/standings` — Season standings. ### Library (reusable building blocks) Org-owned blocks a tournament or a setup template can reference. All four follow the same shape: `GET|POST` on the collection, `PATCH|DELETE` on `/{id}`. A tournament snapshots the block's content at creation, so editing a block never rewrites a game already in progress. - `GET|POST /api/orgs/{slug}/blind-schedules` · `PATCH|DELETE /api/orgs/{slug}/blind-schedules/{id}`: named blind structures. - `GET|POST /api/orgs/{slug}/chip-sets` · `PATCH|DELETE /api/orgs/{slug}/chip-sets/{id}`: chip colors, denominations, quantities. Drives color-up accuracy. - `GET|POST /api/orgs/{slug}/payout-schedules` · `PATCH|DELETE /api/orgs/{slug}/payout-schedules/{id}`: payout tables by player count. - `GET|POST /api/orgs/{slug}/point-charts` · `PATCH|DELETE /api/orgs/{slug}/point-charts/{id}`: league points by finishing position and player count. Applied against the paid-entrant count when results are saved; falls back to the built-in scale when a tournament has no chart. - `POST|DELETE /api/orgs/{slug}/league-rules`: upload or remove the org's league-rules PDF (multipart `file`, admin only, 4 MB max). Players read it from the companion. ### Billing - `POST /api/orgs/{slug}/billing/checkout` — Create Stripe Checkout session. - `POST /api/orgs/{slug}/billing/portal` — Create Stripe Customer Portal session. ## Common Agent Workflows ### "Start a tournament from scratch" 1. `POST /api/quickstart` with `{ "org_name": "..." }` — returns `api_key`, `org_slug`, `session_id`. 2. `POST /api/orgs/{slug}/players` with `{ "nickname": "Alice" }` — add players as needed. 3. `POST /api/orgs/{slug}/clock` with `{ sessionId, action: "start" }` — start the clock. 4. `GET /api/live-tournament?sessionId={uuid}` — confirm running state. ### "Who's still in?" 1. `GET /api/live-tournament?sessionId={uuid}` — `remaining` field + `recentEliminations[]`. ### "Set up payouts and league points once, reuse every week" 1. `POST /api/orgs/{slug}/payout-schedules` with `{ name, rows }`, one row per player-count tier. 2. `POST /api/orgs/{slug}/point-charts` with `{ name, rows }`, points by finishing position per tier. 3. `POST /api/orgs/{slug}/sessions` referencing them. The tournament snapshots the payout structure and resolves points from the chart when results are saved. ### "Knock out player X" 1. `GET /api/orgs/{slug}/players` — find player ID by nickname. 2. `POST /api/orgs/{slug}/eliminations` with `{ sessionId, rosterPlayerId, eliminatedById? }`. ## Comparisons - [/vs/the-tournament-director](https://pokerleagueos.com/vs/the-tournament-director) - [/vs/blindvalet](https://pokerleagueos.com/vs/blindvalet) ## Resources - [Main site](https://pokerleagueos.com) - [Agents overview](https://pokerleagueos.com/agents) - [Tournament clock](https://pokerleagueos.com/tournament-clock) - [Pricing](https://pokerleagueos.com/pricing) - [Terms](https://pokerleagueos.com/terms) - [Privacy](https://pokerleagueos.com/privacy) ## Versioning & Stability Current API version: **v1** (stable). Breaking changes announced ≥30 days in advance. Deprecated fields remain functional for 90 days after announcement. Check `/openapi.json` `info.version` for exact build.