{
  "openapi": "3.0.0",
  "info": {
    "title": "Lean API",
    "version": "0.1.0",
    "description": "Programmatic access to Lean: canonical sports markets, quotes, orders, positions and balances."
  },
  "servers": [
    {
      "url": "{baseUrl}/v1",
      "description": "Lean API",
      "variables": {
        "baseUrl": {
          "default": "https://api.lean.xyz",
          "description": "The Lean API base URL, without /v1. Same value as LEAN_API_URL in the guides."
        }
      }
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A Lean API key, sent as `Authorization: Bearer <key>`. A test key (`lean_sk_test_...`) simulates orders and fills with no money; a live key (`lean_sk_live_...`) trades for real within the key's limits. Every successful response says which mode answered in `data.livemode`."
      },
      "sessionToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "The session token of a Lean user who is signed in, sent as `Authorization: Bearer <token>`. Only the API key endpoints accept it, and an API key cannot create or revoke keys."
      }
    },
    "schemas": {
      "ApiError": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "VALIDATION_ERROR",
                  "NOT_FOUND",
                  "UNAUTHORIZED",
                  "FORBIDDEN",
                  "CONFLICT",
                  "UPSTREAM_ERROR",
                  "RATE_LIMITED",
                  "INTERNAL_ERROR",
                  "FEATURE_DISABLED",
                  "CONDITIONAL_SELL_REJECTED",
                  "CONDITIONAL_SELL_ACTIVE"
                ]
              },
              "message": {
                "type": "string",
                "minLength": 1
              },
              "details": {
                "nullable": true
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "meta": {
            "type": "object",
            "properties": {
              "timestampMs": {
                "type": "integer",
                "minimum": 0
              },
              "requestId": {
                "type": "string",
                "minLength": 1
              },
              "traceId": {
                "type": "string",
                "minLength": 1
              },
              "cachedAtMs": {
                "type": "integer",
                "minimum": 0
              },
              "source": {
                "type": "string",
                "enum": [
                  "cache",
                  "database",
                  "clickhouse",
                  "upstream",
                  "fallback",
                  "internal"
                ]
              }
            },
            "required": [
              "timestampMs",
              "requestId"
            ]
          }
        },
        "required": [
          "success",
          "error",
          "meta"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/markets": {
      "get": {
        "operationId": "listMarkets",
        "summary": "List markets",
        "description": "Canonical sports markets, each with the Kalshi, Polymarket, Polymarket US and Hyperliquid legs that trade the same outcome. Filter by league, sport, status, start time or text, or look up the markets of one venue symbol. Pass `next_cursor` back as `cursor` for the next page.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Look up the markets one venue symbol trades: a leg `ticker` (`pm:…`, `hl:…`, `pmus:…`, `lt:…` or a Kalshi market ticker), a Polymarket condition id or token id, or a Hyperliquid book coin (`#…`). The start window, cursor and other filters except `venue` do not apply."
            },
            "required": false,
            "description": "Look up the markets one venue symbol trades: a leg `ticker` (`pm:…`, `hl:…`, `pmus:…`, `lt:…` or a Kalshi market ticker), a Polymarket condition id or token id, or a Hyperliquid book coin (`#…`). The start window, cursor and other filters except `venue` do not apply.",
            "name": "symbol",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Words matched the way the Lean app search matches them: every word against Kalshi, Polymarket, Polymarket US and Hyperliquid market and event titles in any letter case, the last word as a prefix, with common team nicknames and small typos tried when few markets match. Only markets with a leg that matches are listed, in the usual start order, and the other filters and `cursor` apply as without it. A search covers the venue markets of the fixtures in the start window, at most 10,000 matching ones, open ones first and then by start, so narrow broad words with `league`, `sport` or the start window. To list a whole league, use `league`. With `kind=event`, every word must match a whole word of the open venue market title, its event title or its outcome names, in any letter case, the last word as a prefix, so `rain` finds `Rain` and `Rainfall` but not `Ukraine`; no nicknames or near spellings are tried."
            },
            "required": false,
            "description": "Words matched the way the Lean app search matches them: every word against Kalshi, Polymarket, Polymarket US and Hyperliquid market and event titles in any letter case, the last word as a prefix, with common team nicknames and small typos tried when few markets match. Only markets with a leg that matches are listed, in the usual start order, and the other filters and `cursor` apply as without it. A search covers the venue markets of the fixtures in the start window, at most 10,000 matching ones, open ones first and then by start, so narrow broad words with `league`, `sport` or the start window. To list a whole league, use `league`. With `kind=event`, every word must match a whole word of the open venue market title, its event title or its outcome names, in any letter case, the last word as a prefix, so `rain` finds `Rain` and `Rainfall` but not `Ukraine`; no nicknames or near spellings are tried.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "sports",
                "time_window",
                "event"
              ],
              "description": "`sports`: one outcome of a fixture proposition, with a leg on each venue that lists it. `time_window`: one outcome of a crypto price window. `event`: one side of a single Polymarket, Polymarket US, Hyperliquid or Kalshi market that no fixture lists and that is no Kalshi parlay, such as an election or a company result. Defaults to `time_window` with `category=crypto` or `venue=lighter`, to `event` with any category but `sports` and `crypto`, else to `sports`."
            },
            "required": false,
            "description": "`sports`: one outcome of a fixture proposition, with a leg on each venue that lists it. `time_window`: one outcome of a crypto price window. `event`: one side of a single Polymarket, Polymarket US, Hyperliquid or Kalshi market that no fixture lists and that is no Kalshi parlay, such as an election or a company result. Defaults to `time_window` with `category=crypto` or `venue=lighter`, to `event` with any category but `sports` and `crypto`, else to `sports`.",
            "name": "kind",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "sports",
                "crypto",
                "politics",
                "economy",
                "business",
                "entertainment",
                "science",
                "society",
                "climate",
                "commodities",
                "transportation",
                "gaming",
                "health",
                "law",
                "uncategorized"
              ],
              "description": "The topic listed. `sports` lists fixture markets. `crypto` without `kind` lists only Lighter crypto price windows, so with another `venue` it lists an empty page unless `kind=event` is passed. Every other category lists event markets. An event market lists as `crypto` when it is a coin-price market (Polymarket tagged `crypto-prices`, or `crypto` and `hit-price`; a Hyperliquid outcome tagged `asset:<coin>` for a Hyperliquid coin), whatever its taxonomy; otherwise as the first root of its Lean taxonomy, else the category Kalshi files it under, else `uncategorized`. Defaults to `sports`, or to `crypto` with `venue=lighter`. A `crypto` window listing takes the start window, `status`, `venue`, `limit` and `cursor`; an event listing takes `search`, `venue`, `status`, the end window, `limit` and `cursor`; filters that do not apply are refused."
            },
            "required": false,
            "description": "The topic listed. `sports` lists fixture markets. `crypto` without `kind` lists only Lighter crypto price windows, so with another `venue` it lists an empty page unless `kind=event` is passed. Every other category lists event markets. An event market lists as `crypto` when it is a coin-price market (Polymarket tagged `crypto-prices`, or `crypto` and `hit-price`; a Hyperliquid outcome tagged `asset:<coin>` for a Hyperliquid coin), whatever its taxonomy; otherwise as the first root of its Lean taxonomy, else the category Kalshi files it under, else `uncategorized`. Defaults to `sports`, or to `crypto` with `venue=lighter`. A `crypto` window listing takes the start window, `status`, `venue`, `limit` and `cursor`; an event listing takes `search`, `venue`, `status`, the end window, `limit` and `cursor`; filters that do not apply are refused.",
            "name": "category",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32,
              "description": "Only fixtures of this sport, such as `football`."
            },
            "required": false,
            "description": "Only fixtures of this sport, such as `football`.",
            "name": "sport",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32,
              "description": "Only fixtures of this league. Coverage includes international basketball (euroleague, eurocup), hockey (khl, shl, del, ahl, liiga), soccer and other sports.",
              "example": "nfl"
            },
            "required": false,
            "description": "Only fixtures of this league. Coverage includes international basketball (euroleague, eurocup), hockey (khl, shl, del, ahl, liiga), soccer and other sports.",
            "name": "league",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "moneyline",
                "spread",
                "total",
                "team_total",
                "prop"
              ],
              "description": "Sports listings only: only propositions of this `group.kind`, such as `moneyline`, `spread`, `total`, `team_total` or `prop` (which includes `sports.player_prop` markets)."
            },
            "required": false,
            "description": "Sports listings only: only propositions of this `group.kind`, such as `moneyline`, `spread`, `total`, `team_total` or `prop` (which includes `sports.player_prop` markets).",
            "name": "group_kind",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Only markets of this fixture, by its exact `fixture.key`. The start window still applies, so a fixture that starts outside it lists nothing."
            },
            "required": false,
            "description": "Only markets of this fixture, by its exact `fixture.key`. The start window still applies, so a fixture that starts outside it lists nothing.",
            "name": "fixture",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Only markets of propositions with this exact `group.key`, such as `moneyline:game`. With `fixture`, lists one proposition of one fixture; without it, that proposition in every fixture the other filters keep."
            },
            "required": false,
            "description": "Only markets of propositions with this exact `group.key`, such as `moneyline:game`. With `fixture`, lists one proposition of one fixture; without it, that proposition in every fixture the other filters keep.",
            "name": "group",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only markets with a leg on this venue."
            },
            "required": false,
            "description": "Only markets with a leg on this venue.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Event markets only: list all markets/strikes belonging to this exact event ticker."
            },
            "required": false,
            "description": "Event markets only: list all markets/strikes belonging to this exact event ticker.",
            "name": "event",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Event markets only: list markets belonging to this exact series ticker (e.g. KXFAOFPI)."
            },
            "required": false,
            "description": "Event markets only: list markets belonging to this exact series ticker (e.g. KXFAOFPI).",
            "name": "series",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "ending_soon",
                "newest",
                "overdue"
              ],
              "description": "Event markets only. `ending_soon` (default): soonest scheduled close first. `newest`: most recently listed markets first. `overdue`: open markets past their scheduled end_date, oldest overdue first."
            },
            "required": false,
            "description": "Event markets only. `ending_soon` (default): soonest scheduled close first. `newest`: most recently listed markets first. `overdue`: open markets past their scheduled end_date, oldest overdue first.",
            "name": "sort",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "Event markets only: when `\"true\"`, include Kalshi multivariate combo markets (KXMVE*) in listings. Defaults to `\"false\"`. Any combo ticker still resolves directly by id or symbol."
            },
            "required": false,
            "description": "Event markets only: when `\"true\"`, include Kalshi multivariate combo markets (KXMVE*) in listings. Defaults to `\"false\"`. Any combo ticker still resolves directly by id or symbol.",
            "name": "include_combos",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "Event listings only. With true and no status, include every venue status and untradable markets; with status=closed, include only untradable markets. Requires an end window of at most 30 days, starting no more than 30 days ago. Omitted ends_after defaults to 48 hours ago; omitted ends_before defaults to 30 days after ends_after. The default window is retained by the cursor. Does not apply to symbol lookups."
            },
            "required": false,
            "description": "Event listings only. With true and no status, include every venue status and untradable markets; with status=closed, include only untradable markets. Requires an end window of at most 30 days, starting no more than 30 days ago. Omitted ends_after defaults to 48 hours ago; omitted ends_before defaults to 30 days after ends_after. The default window is retained by the cursor. Does not apply to symbol lookups.",
            "name": "include_closed",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "closed",
                "resolved",
                "all"
              ],
              "description": "`open`: tradable open markets. `closed`: closed, resolving or unopened markets. `resolved`: settled event markets (useful for backtesting/history). `all`: every status (event markets only)."
            },
            "required": false,
            "description": "`open`: tradable open markets. `closed`: closed, resolving or unopened markets. `resolved`: settled event markets (useful for backtesting/history). `all`: every status (event markets only).",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only fixtures, or crypto windows, starting at or after this time. Defaults to 12 hours ago."
            },
            "required": false,
            "description": "Only fixtures, or crypto windows, starting at or after this time. Defaults to 12 hours ago.",
            "name": "starts_after",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only fixtures, or crypto windows, starting before this time. Defaults to 30 days ahead, so season futures such as a championship final are listed only when this is set past their start. Their market ids resolve at any time."
            },
            "required": false,
            "description": "Only fixtures, or crypto windows, starting before this time. Defaults to 30 days ahead, so season futures such as a championship final are listed only when this is set past their start. Their market ids resolve at any time.",
            "name": "starts_before",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Event markets only: only venue markets scheduled to close at or after this time. Defaults to 48 hours ago, so a market still trading after its scheduled close stays listed."
            },
            "required": false,
            "description": "Event markets only: only venue markets scheduled to close at or after this time. Defaults to 48 hours ago, so a market still trading after its scheduled close stays listed.",
            "name": "ends_after",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Event markets only: only venue markets scheduled to close before this time. With include_closed=true, defaults to 30 days after ends_after and the window must be at most 30 days."
            },
            "required": false,
            "description": "Event markets only: only venue markets scheduled to close before this time. With include_closed=true, defaults to 30 days after ends_after and the window must be at most 30 days.",
            "name": "ends_before",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query",
            "example": 2
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "The `next_cursor` of the previous page. An event listing refuses a cursor issued for another `category`, `venue`, `search`, `ends_after`, `ends_before`, `include_closed` or closed-status filter."
            },
            "required": false,
            "description": "The `next_cursor` of the previous page. An event listing refuses a cursor issued for another `category`, `venue`, `search`, `ends_after`, `ends_before`, `include_closed` or closed-status filter.",
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Canonical markets with their venue legs",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "markets": {
                              "type": "array",
                              "items": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "sports"
                                        ]
                                      },
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "line": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                      },
                                      "fixture": {
                                        "type": "object",
                                        "properties": {
                                          "key": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "sport": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "league": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "starts_at": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "scheduled_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                          },
                                          "participants": {
                                            "type": "array",
                                            "items": {
                                              "type": "string",
                                              "minLength": 1
                                            }
                                          },
                                          "teams": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "key": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "name": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "role": {
                                                  "type": "string",
                                                  "enum": [
                                                    "home",
                                                    "away",
                                                    "competitor"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "key",
                                                "name",
                                                "role"
                                              ]
                                            }
                                          }
                                        },
                                        "required": [
                                          "key",
                                          "sport",
                                          "league",
                                          "title",
                                          "starts_at",
                                          "scheduled_date",
                                          "participants",
                                          "teams"
                                        ]
                                      },
                                      "group": {
                                        "type": "object",
                                        "properties": {
                                          "key": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "kind": {
                                            "type": "string",
                                            "enum": [
                                              "moneyline",
                                              "spread",
                                              "total",
                                              "team_total",
                                              "prop"
                                            ]
                                          },
                                          "template": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Canonical sports contract template, such as `sports.winner`, `sports.handicap`, `sports.total`, `sports.team_total` or `sports.player_prop`."
                                          },
                                          "label": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "period": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "subject": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "stat": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "line": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          }
                                        },
                                        "required": [
                                          "key",
                                          "kind",
                                          "template",
                                          "label",
                                          "period",
                                          "subject",
                                          "stat",
                                          "line"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "nullable": true,
                                              "enum": [
                                                "unopened",
                                                "open",
                                                "closed",
                                                "resolving",
                                                "resolved"
                                              ],
                                              "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                            },
                                            "tradable": {
                                              "type": "boolean",
                                              "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                            },
                                            "yes_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "no_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "lean_url": {
                                              "type": "string",
                                              "format": "uri",
                                              "description": "Direct Lean web terminal link for this market leg and side."
                                            },
                                            "venue_url": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "uri",
                                              "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                            },
                                            "resolution": {
                                              "type": "object",
                                              "properties": {
                                                "source": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                },
                                                "rules": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                },
                                                "end_date": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "date-time",
                                                  "description": "When the venue market is scheduled to close, if the venue gives one."
                                                },
                                                "url": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "uri",
                                                  "description": "The venue's public page for this market, when it can be built from stored data."
                                                },
                                                "result": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "enum": [
                                                    "won",
                                                    "lost",
                                                    "void"
                                                  ],
                                                  "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                                }
                                              },
                                              "required": [
                                                "source",
                                                "rules",
                                                "end_date",
                                                "url",
                                                "result"
                                              ],
                                              "description": "How this venue resolves its market."
                                            },
                                            "fees": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "formula": {
                                                  "type": "string",
                                                  "enum": [
                                                    "price_curve",
                                                    "flat",
                                                    "notional_on_exit"
                                                  ],
                                                  "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                },
                                                "taker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "maker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "exponent": {
                                                  "type": "integer",
                                                  "nullable": true,
                                                  "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                }
                                              },
                                              "required": [
                                                "formula",
                                                "taker_rate",
                                                "maker_rate",
                                                "exponent"
                                              ],
                                              "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "status",
                                            "tradable",
                                            "yes_token",
                                            "no_token",
                                            "lean_url",
                                            "venue_url",
                                            "resolution",
                                            "fees"
                                          ]
                                        }
                                      },
                                      "equivalence": {
                                        "type": "string",
                                        "enum": [
                                          "single_venue",
                                          "verified",
                                          "unreviewed"
                                        ],
                                        "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "id",
                                      "title",
                                      "outcome",
                                      "line",
                                      "fixture",
                                      "group",
                                      "legs",
                                      "equivalence"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "time_window"
                                        ]
                                      },
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "enum": [
                                          "up",
                                          "down"
                                        ]
                                      },
                                      "line": {
                                        "nullable": true
                                      },
                                      "window": {
                                        "type": "object",
                                        "properties": {
                                          "key": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "The window: underlying, length and UTC start, such as `btc:15m:20261117-0100`. Every venue market on the same window shares it."
                                          },
                                          "category": {
                                            "type": "string",
                                            "enum": [
                                              "crypto"
                                            ]
                                          },
                                          "underlying": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "The asset whose price the window follows, such as `BTC`."
                                          },
                                          "duration_minutes": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "exclusiveMinimum": true
                                          },
                                          "proposition": {
                                            "type": "string",
                                            "enum": [
                                              "up_down"
                                            ],
                                            "description": "`up_down`: `up` pays when the price at the window end is at or above the price at its start, as the venue resolution rules define them; `down` pays when it is below."
                                          },
                                          "starts_at": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "ends_at": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "key",
                                          "category",
                                          "underlying",
                                          "duration_minutes",
                                          "proposition",
                                          "starts_at",
                                          "ends_at",
                                          "title"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "nullable": true,
                                              "enum": [
                                                "unopened",
                                                "open",
                                                "closed",
                                                "resolving",
                                                "resolved"
                                              ],
                                              "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                            },
                                            "tradable": {
                                              "type": "boolean",
                                              "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                            },
                                            "yes_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "no_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "lean_url": {
                                              "type": "string",
                                              "format": "uri",
                                              "description": "Direct Lean web terminal link for this market leg and side."
                                            },
                                            "venue_url": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "uri",
                                              "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                            },
                                            "resolution": {
                                              "type": "object",
                                              "properties": {
                                                "source": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                },
                                                "rules": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                },
                                                "end_date": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "date-time",
                                                  "description": "When the venue market is scheduled to close, if the venue gives one."
                                                },
                                                "url": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "uri",
                                                  "description": "The venue's public page for this market, when it can be built from stored data."
                                                },
                                                "result": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "enum": [
                                                    "won",
                                                    "lost",
                                                    "void"
                                                  ],
                                                  "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                                }
                                              },
                                              "required": [
                                                "source",
                                                "rules",
                                                "end_date",
                                                "url",
                                                "result"
                                              ],
                                              "description": "How this venue resolves its market."
                                            },
                                            "fees": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "formula": {
                                                  "type": "string",
                                                  "enum": [
                                                    "price_curve",
                                                    "flat",
                                                    "notional_on_exit"
                                                  ],
                                                  "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                },
                                                "taker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "maker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "exponent": {
                                                  "type": "integer",
                                                  "nullable": true,
                                                  "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                }
                                              },
                                              "required": [
                                                "formula",
                                                "taker_rate",
                                                "maker_rate",
                                                "exponent"
                                              ],
                                              "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "status",
                                            "tradable",
                                            "yes_token",
                                            "no_token",
                                            "lean_url",
                                            "venue_url",
                                            "resolution",
                                            "fees"
                                          ]
                                        }
                                      },
                                      "equivalence": {
                                        "type": "string",
                                        "enum": [
                                          "single_venue",
                                          "verified",
                                          "unreviewed"
                                        ],
                                        "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "id",
                                      "title",
                                      "outcome",
                                      "line",
                                      "window",
                                      "legs",
                                      "equivalence"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "event"
                                        ]
                                      },
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "line": {
                                        "nullable": true
                                      },
                                      "event": {
                                        "type": "object",
                                        "properties": {
                                          "key": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "The venue event the market belongs to, such as a Polymarket event's ticker."
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "category": {
                                            "type": "string",
                                            "enum": [
                                              "sports",
                                              "crypto",
                                              "politics",
                                              "economy",
                                              "business",
                                              "entertainment",
                                              "science",
                                              "society",
                                              "climate",
                                              "commodities",
                                              "transportation",
                                              "gaming",
                                              "health",
                                              "law",
                                              "uncategorized"
                                            ],
                                            "description": "`crypto` for a coin-price market (Polymarket tagged `crypto-prices`, or `crypto` and `hit-price`; a Hyperliquid outcome tagged `asset:<coin>` for a Hyperliquid coin), whatever its taxonomy; otherwise the first root of the venue event's Lean taxonomy, else the category Kalshi files it under, else `uncategorized`."
                                          },
                                          "ends_at": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time",
                                            "description": "When the venue market is scheduled to close; null when the venue gives no date."
                                          },
                                          "created_at": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time",
                                            "description": "When the market was first listed on the venue or indexed by Lean."
                                          },
                                          "series_ticker": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "Recurring series identifier when the event belongs to a series; null otherwise."
                                          },
                                          "is_recurring": {
                                            "type": "boolean",
                                            "description": "True when the event belongs to a recurring series with prior or repeated iterations."
                                          },
                                          "recurrence": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "Recurrence cadence reported by the venue (e.g. daily, weekly, monthly), if known."
                                          }
                                        },
                                        "required": [
                                          "key",
                                          "title",
                                          "category",
                                          "ends_at",
                                          "created_at",
                                          "series_ticker",
                                          "is_recurring",
                                          "recurrence"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "nullable": true,
                                              "enum": [
                                                "unopened",
                                                "open",
                                                "closed",
                                                "resolving",
                                                "resolved"
                                              ],
                                              "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                            },
                                            "tradable": {
                                              "type": "boolean",
                                              "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                            },
                                            "yes_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "no_token": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                            },
                                            "lean_url": {
                                              "type": "string",
                                              "format": "uri",
                                              "description": "Direct Lean web terminal link for this market leg and side."
                                            },
                                            "venue_url": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "uri",
                                              "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                            },
                                            "resolution": {
                                              "type": "object",
                                              "properties": {
                                                "source": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                },
                                                "rules": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                },
                                                "end_date": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "date-time",
                                                  "description": "When the venue market is scheduled to close, if the venue gives one."
                                                },
                                                "url": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "uri",
                                                  "description": "The venue's public page for this market, when it can be built from stored data."
                                                },
                                                "result": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "enum": [
                                                    "won",
                                                    "lost",
                                                    "void"
                                                  ],
                                                  "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                                }
                                              },
                                              "required": [
                                                "source",
                                                "rules",
                                                "end_date",
                                                "url",
                                                "result"
                                              ],
                                              "description": "How this venue resolves its market."
                                            },
                                            "fees": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "formula": {
                                                  "type": "string",
                                                  "enum": [
                                                    "price_curve",
                                                    "flat",
                                                    "notional_on_exit"
                                                  ],
                                                  "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                },
                                                "taker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "maker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "exponent": {
                                                  "type": "integer",
                                                  "nullable": true,
                                                  "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                }
                                              },
                                              "required": [
                                                "formula",
                                                "taker_rate",
                                                "maker_rate",
                                                "exponent"
                                              ],
                                              "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "status",
                                            "tradable",
                                            "yes_token",
                                            "no_token",
                                            "lean_url",
                                            "venue_url",
                                            "resolution",
                                            "fees"
                                          ]
                                        }
                                      },
                                      "equivalence": {
                                        "type": "string",
                                        "enum": [
                                          "single_venue",
                                          "verified",
                                          "unreviewed"
                                        ],
                                        "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "id",
                                      "title",
                                      "outcome",
                                      "line",
                                      "event",
                                      "legs",
                                      "equivalence"
                                    ]
                                  }
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "markets",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Spread markets": {
                    "summary": "Both sides of DEN -3.5",
                    "value": {
                      "success": true,
                      "data": {
                        "markets": [
                          {
                            "id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                            "outcome": "DEN",
                            "line": "-3.5",
                            "fixture": {
                              "key": "nfl:2026-10-11:DEN-LAC",
                              "sport": "football",
                              "league": "nfl",
                              "title": "Denver Broncos at Los Angeles Chargers",
                              "starts_at": "2026-10-11T20:25:00.000Z",
                              "scheduled_date": "2026-10-11",
                              "participants": [
                                "Denver Broncos",
                                "Los Angeles Chargers"
                              ],
                              "teams": [
                                {
                                  "key": "DEN",
                                  "name": "Denver Broncos",
                                  "role": "away"
                                },
                                {
                                  "key": "LAC",
                                  "name": "Los Angeles Chargers",
                                  "role": "home"
                                }
                              ]
                            },
                            "group": {
                              "key": "spread:game:DEN:-3.5",
                              "kind": "spread",
                              "label": "DEN -3.5",
                              "period": "game",
                              "subject": "DEN",
                              "stat": null,
                              "line": "-3.5"
                            },
                            "legs": [
                              {
                                "venue": "hyperliquid",
                                "ticker": "<venue ticker>",
                                "side": "yes",
                                "status": "open",
                                "tradable": true,
                                "resolution": {
                                  "source": null,
                                  "rules": "Resolves YES if the Denver Broncos win by more than 3.5 points, overtime included.",
                                  "end_date": "2026-10-12T04:00:00.000Z",
                                  "url": null
                                }
                              },
                              {
                                "venue": "polymarket",
                                "ticker": "<venue ticker>",
                                "side": "yes",
                                "status": "open",
                                "tradable": true,
                                "resolution": {
                                  "source": null,
                                  "rules": "Resolves to Denver Broncos if they win by more than 3.5 points, overtime included.",
                                  "end_date": "2026-10-12T04:00:00.000Z",
                                  "url": null
                                }
                              }
                            ],
                            "equivalence": "verified"
                          },
                          {
                            "id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpMQUM",
                            "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Los Angeles Chargers +3.5",
                            "outcome": "LAC",
                            "line": "3.5",
                            "fixture": {
                              "key": "nfl:2026-10-11:DEN-LAC",
                              "sport": "football",
                              "league": "nfl",
                              "title": "Denver Broncos at Los Angeles Chargers",
                              "starts_at": "2026-10-11T20:25:00.000Z",
                              "scheduled_date": "2026-10-11",
                              "participants": [
                                "Denver Broncos",
                                "Los Angeles Chargers"
                              ],
                              "teams": [
                                {
                                  "key": "DEN",
                                  "name": "Denver Broncos",
                                  "role": "away"
                                },
                                {
                                  "key": "LAC",
                                  "name": "Los Angeles Chargers",
                                  "role": "home"
                                }
                              ]
                            },
                            "group": {
                              "key": "spread:game:DEN:-3.5",
                              "kind": "spread",
                              "label": "DEN -3.5",
                              "period": "game",
                              "subject": "DEN",
                              "stat": null,
                              "line": "-3.5"
                            },
                            "legs": [
                              {
                                "venue": "hyperliquid",
                                "ticker": "<venue ticker>",
                                "side": "no",
                                "status": "open",
                                "tradable": true,
                                "resolution": {
                                  "source": null,
                                  "rules": "Resolves YES if the Denver Broncos win by more than 3.5 points, overtime included.",
                                  "end_date": "2026-10-12T04:00:00.000Z",
                                  "url": null
                                }
                              },
                              {
                                "venue": "polymarket",
                                "ticker": "<venue ticker>",
                                "side": "no",
                                "status": "open",
                                "tradable": true,
                                "resolution": {
                                  "source": null,
                                  "rules": "Resolves to Denver Broncos if they win by more than 3.5 points, overtime included.",
                                  "end_date": "2026-10-12T04:00:00.000Z",
                                  "url": null
                                }
                              }
                            ],
                            "equivalence": "verified"
                          }
                        ],
                        "next_cursor": null,
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Invalid request": {
                    "summary": "A field failed validation",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "limit",
                            "message": "Number must be less than or equal to 200"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "5b0d7f3e-2c61-4e8a-b947-1d3a6e0f8c25"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "UPSTREAM_ERROR when `search` is set and search is unavailable; retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}": {
      "get": {
        "operationId": "getMarket",
        "summary": "Get a market",
        "description": "One market by its id, with each venue leg (including `lean_url`, resolution rules, and fees) plus automatic `series_context` (whether the market is recurring, Brier score & sharpness calibration of prior settled markets in the series, sibling strikes in the same event, cross-venue equivalents, and active liquidity rewards).",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "One canonical market with its venue legs and series context",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "sports"
                                  ]
                                },
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "title": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "outcome": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "line": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                },
                                "fixture": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "sport": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "league": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "title": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "starts_at": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "scheduled_date": {
                                      "type": "string",
                                      "nullable": true,
                                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                                    },
                                    "participants": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "teams": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "key": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "name": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "role": {
                                            "type": "string",
                                            "enum": [
                                              "home",
                                              "away",
                                              "competitor"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "key",
                                          "name",
                                          "role"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "sport",
                                    "league",
                                    "title",
                                    "starts_at",
                                    "scheduled_date",
                                    "participants",
                                    "teams"
                                  ]
                                },
                                "group": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "moneyline",
                                        "spread",
                                        "total",
                                        "team_total",
                                        "prop"
                                      ]
                                    },
                                    "template": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "Canonical sports contract template, such as `sports.winner`, `sports.handicap`, `sports.total`, `sports.team_total` or `sports.player_prop`."
                                    },
                                    "label": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "period": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "stat": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "line": {
                                      "type": "string",
                                      "nullable": true,
                                      "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "kind",
                                    "template",
                                    "label",
                                    "period",
                                    "subject",
                                    "stat",
                                    "line"
                                  ]
                                },
                                "legs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "unopened",
                                          "open",
                                          "closed",
                                          "resolving",
                                          "resolved"
                                        ],
                                        "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                      },
                                      "tradable": {
                                        "type": "boolean",
                                        "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                      },
                                      "yes_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "no_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "lean_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "Direct Lean web terminal link for this market leg and side."
                                      },
                                      "venue_url": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uri",
                                        "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                      },
                                      "resolution": {
                                        "type": "object",
                                        "properties": {
                                          "source": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                          },
                                          "rules": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time",
                                            "description": "When the venue market is scheduled to close, if the venue gives one."
                                          },
                                          "url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri",
                                            "description": "The venue's public page for this market, when it can be built from stored data."
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true,
                                            "enum": [
                                              "won",
                                              "lost",
                                              "void"
                                            ],
                                            "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                          }
                                        },
                                        "required": [
                                          "source",
                                          "rules",
                                          "end_date",
                                          "url",
                                          "result"
                                        ],
                                        "description": "How this venue resolves its market."
                                      },
                                      "fees": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "formula": {
                                            "type": "string",
                                            "enum": [
                                              "price_curve",
                                              "flat",
                                              "notional_on_exit"
                                            ],
                                            "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                          },
                                          "taker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "maker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "exponent": {
                                            "type": "integer",
                                            "nullable": true,
                                            "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                          }
                                        },
                                        "required": [
                                          "formula",
                                          "taker_rate",
                                          "maker_rate",
                                          "exponent"
                                        ],
                                        "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "status",
                                      "tradable",
                                      "yes_token",
                                      "no_token",
                                      "lean_url",
                                      "venue_url",
                                      "resolution",
                                      "fees"
                                    ]
                                  }
                                },
                                "equivalence": {
                                  "type": "string",
                                  "enum": [
                                    "single_venue",
                                    "verified",
                                    "unreviewed"
                                  ],
                                  "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                },
                                "series_context": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "is_recurring": {
                                      "type": "boolean"
                                    },
                                    "series_ticker": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "recurrence": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "prior_settled_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "prior_settled_markets": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "upcoming_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "calibration": {
                                      "type": "object",
                                      "nullable": true,
                                      "properties": {
                                        "sample_size": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "yes_rate": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Fraction of sampled prior markets that resolved YES."
                                        },
                                        "brier_24h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean squared error (Brier score) of YES prices 24 hours before close vs realized outcome. Lower is sharper."
                                        },
                                        "brier_6h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 6 hours before close vs realized outcome."
                                        },
                                        "brier_1h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 1 hour before close vs realized outcome."
                                        },
                                        "brier_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of final pre-close YES prices vs realized outcome."
                                        },
                                        "log_loss_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean binary log loss of final pre-close YES prices vs realized outcome."
                                        },
                                        "sharpness": {
                                          "type": "string",
                                          "enum": [
                                            "very_sharp",
                                            "well_calibrated",
                                            "noisy",
                                            "insufficient_history"
                                          ],
                                          "description": "Automatic sharpness classification of prior markets in this series: very_sharp (<0.05 Brier), well_calibrated (<0.12), noisy (>=0.12), or insufficient_history (<3 samples)."
                                        },
                                        "recent_settlements": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "market_id": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "event_ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time"
                                              },
                                              "result": {
                                                "type": "string",
                                                "enum": [
                                                  "yes",
                                                  "no"
                                                ]
                                              },
                                              "expiration_value": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_24h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_6h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_1h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "final_price": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "lean_url": {
                                                "type": "string",
                                                "format": "uri"
                                              },
                                              "venue_url": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "market_id",
                                              "ticker",
                                              "event_ticker",
                                              "title",
                                              "end_date",
                                              "result",
                                              "expiration_value",
                                              "price_24h_before",
                                              "price_6h_before",
                                              "price_1h_before",
                                              "final_price",
                                              "lean_url",
                                              "venue_url"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "sample_size",
                                        "yes_rate",
                                        "brier_24h",
                                        "brier_6h",
                                        "brier_1h",
                                        "brier_close",
                                        "log_loss_close",
                                        "sharpness",
                                        "recent_settlements"
                                      ]
                                    },
                                    "siblings": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "unopened",
                                              "open",
                                              "closed",
                                              "resolving",
                                              "resolved"
                                            ]
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "ticker",
                                          "title",
                                          "status",
                                          "result",
                                          "lean_url",
                                          "venue_url"
                                        ]
                                      }
                                    },
                                    "related_markets": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the aligned outcome on the peer venue."
                                          },
                                          "no_market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the opposite outcome on the peer venue."
                                          },
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          },
                                          "compatibility": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "resolution": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "source": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                              },
                                              "rules": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time",
                                                "description": "When the venue market is scheduled to close, if the venue gives one."
                                              }
                                            },
                                            "required": [
                                              "source",
                                              "rules",
                                              "end_date"
                                            ]
                                          },
                                          "fees": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "formula": {
                                                "type": "string",
                                                "enum": [
                                                  "price_curve",
                                                  "flat",
                                                  "notional_on_exit"
                                                ],
                                                "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                              },
                                              "taker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "maker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "exponent": {
                                                "type": "integer",
                                                "nullable": true,
                                                "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                              }
                                            },
                                            "required": [
                                              "formula",
                                              "taker_rate",
                                              "maker_rate",
                                              "exponent"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "no_market_id",
                                          "venue",
                                          "ticker",
                                          "title",
                                          "lean_url",
                                          "venue_url",
                                          "compatibility",
                                          "resolution",
                                          "fees"
                                        ]
                                      }
                                    },
                                    "rewards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "daily_rate_usd": {
                                            "type": "string",
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "max_spread": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "min_size": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time"
                                          }
                                        },
                                        "required": [
                                          "venue",
                                          "ticker",
                                          "daily_rate_usd",
                                          "max_spread",
                                          "min_size",
                                          "end_date"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "is_recurring",
                                    "series_ticker",
                                    "recurrence",
                                    "prior_settled_events",
                                    "prior_settled_markets",
                                    "upcoming_events",
                                    "calibration",
                                    "siblings",
                                    "related_markets",
                                    "rewards"
                                  ]
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "kind",
                                "id",
                                "title",
                                "outcome",
                                "line",
                                "fixture",
                                "group",
                                "legs",
                                "equivalence",
                                "series_context",
                                "livemode"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "time_window"
                                  ]
                                },
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "title": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "up",
                                    "down"
                                  ]
                                },
                                "line": {
                                  "nullable": true
                                },
                                "window": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The window: underlying, length and UTC start, such as `btc:15m:20261117-0100`. Every venue market on the same window shares it."
                                    },
                                    "category": {
                                      "type": "string",
                                      "enum": [
                                        "crypto"
                                      ]
                                    },
                                    "underlying": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The asset whose price the window follows, such as `BTC`."
                                    },
                                    "duration_minutes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "exclusiveMinimum": true
                                    },
                                    "proposition": {
                                      "type": "string",
                                      "enum": [
                                        "up_down"
                                      ],
                                      "description": "`up_down`: `up` pays when the price at the window end is at or above the price at its start, as the venue resolution rules define them; `down` pays when it is below."
                                    },
                                    "starts_at": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "ends_at": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "title": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "category",
                                    "underlying",
                                    "duration_minutes",
                                    "proposition",
                                    "starts_at",
                                    "ends_at",
                                    "title"
                                  ]
                                },
                                "legs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "unopened",
                                          "open",
                                          "closed",
                                          "resolving",
                                          "resolved"
                                        ],
                                        "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                      },
                                      "tradable": {
                                        "type": "boolean",
                                        "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                      },
                                      "yes_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "no_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "lean_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "Direct Lean web terminal link for this market leg and side."
                                      },
                                      "venue_url": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uri",
                                        "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                      },
                                      "resolution": {
                                        "type": "object",
                                        "properties": {
                                          "source": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                          },
                                          "rules": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time",
                                            "description": "When the venue market is scheduled to close, if the venue gives one."
                                          },
                                          "url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri",
                                            "description": "The venue's public page for this market, when it can be built from stored data."
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true,
                                            "enum": [
                                              "won",
                                              "lost",
                                              "void"
                                            ],
                                            "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                          }
                                        },
                                        "required": [
                                          "source",
                                          "rules",
                                          "end_date",
                                          "url",
                                          "result"
                                        ],
                                        "description": "How this venue resolves its market."
                                      },
                                      "fees": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "formula": {
                                            "type": "string",
                                            "enum": [
                                              "price_curve",
                                              "flat",
                                              "notional_on_exit"
                                            ],
                                            "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                          },
                                          "taker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "maker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "exponent": {
                                            "type": "integer",
                                            "nullable": true,
                                            "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                          }
                                        },
                                        "required": [
                                          "formula",
                                          "taker_rate",
                                          "maker_rate",
                                          "exponent"
                                        ],
                                        "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "status",
                                      "tradable",
                                      "yes_token",
                                      "no_token",
                                      "lean_url",
                                      "venue_url",
                                      "resolution",
                                      "fees"
                                    ]
                                  }
                                },
                                "equivalence": {
                                  "type": "string",
                                  "enum": [
                                    "single_venue",
                                    "verified",
                                    "unreviewed"
                                  ],
                                  "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                },
                                "series_context": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "is_recurring": {
                                      "type": "boolean"
                                    },
                                    "series_ticker": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "recurrence": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "prior_settled_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "prior_settled_markets": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "upcoming_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "calibration": {
                                      "type": "object",
                                      "nullable": true,
                                      "properties": {
                                        "sample_size": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "yes_rate": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Fraction of sampled prior markets that resolved YES."
                                        },
                                        "brier_24h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean squared error (Brier score) of YES prices 24 hours before close vs realized outcome. Lower is sharper."
                                        },
                                        "brier_6h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 6 hours before close vs realized outcome."
                                        },
                                        "brier_1h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 1 hour before close vs realized outcome."
                                        },
                                        "brier_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of final pre-close YES prices vs realized outcome."
                                        },
                                        "log_loss_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean binary log loss of final pre-close YES prices vs realized outcome."
                                        },
                                        "sharpness": {
                                          "type": "string",
                                          "enum": [
                                            "very_sharp",
                                            "well_calibrated",
                                            "noisy",
                                            "insufficient_history"
                                          ],
                                          "description": "Automatic sharpness classification of prior markets in this series: very_sharp (<0.05 Brier), well_calibrated (<0.12), noisy (>=0.12), or insufficient_history (<3 samples)."
                                        },
                                        "recent_settlements": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "market_id": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "event_ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time"
                                              },
                                              "result": {
                                                "type": "string",
                                                "enum": [
                                                  "yes",
                                                  "no"
                                                ]
                                              },
                                              "expiration_value": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_24h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_6h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_1h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "final_price": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "lean_url": {
                                                "type": "string",
                                                "format": "uri"
                                              },
                                              "venue_url": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "market_id",
                                              "ticker",
                                              "event_ticker",
                                              "title",
                                              "end_date",
                                              "result",
                                              "expiration_value",
                                              "price_24h_before",
                                              "price_6h_before",
                                              "price_1h_before",
                                              "final_price",
                                              "lean_url",
                                              "venue_url"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "sample_size",
                                        "yes_rate",
                                        "brier_24h",
                                        "brier_6h",
                                        "brier_1h",
                                        "brier_close",
                                        "log_loss_close",
                                        "sharpness",
                                        "recent_settlements"
                                      ]
                                    },
                                    "siblings": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "unopened",
                                              "open",
                                              "closed",
                                              "resolving",
                                              "resolved"
                                            ]
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "ticker",
                                          "title",
                                          "status",
                                          "result",
                                          "lean_url",
                                          "venue_url"
                                        ]
                                      }
                                    },
                                    "related_markets": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the aligned outcome on the peer venue."
                                          },
                                          "no_market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the opposite outcome on the peer venue."
                                          },
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          },
                                          "compatibility": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "resolution": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "source": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                              },
                                              "rules": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time",
                                                "description": "When the venue market is scheduled to close, if the venue gives one."
                                              }
                                            },
                                            "required": [
                                              "source",
                                              "rules",
                                              "end_date"
                                            ]
                                          },
                                          "fees": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "formula": {
                                                "type": "string",
                                                "enum": [
                                                  "price_curve",
                                                  "flat",
                                                  "notional_on_exit"
                                                ],
                                                "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                              },
                                              "taker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "maker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "exponent": {
                                                "type": "integer",
                                                "nullable": true,
                                                "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                              }
                                            },
                                            "required": [
                                              "formula",
                                              "taker_rate",
                                              "maker_rate",
                                              "exponent"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "no_market_id",
                                          "venue",
                                          "ticker",
                                          "title",
                                          "lean_url",
                                          "venue_url",
                                          "compatibility",
                                          "resolution",
                                          "fees"
                                        ]
                                      }
                                    },
                                    "rewards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "daily_rate_usd": {
                                            "type": "string",
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "max_spread": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "min_size": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time"
                                          }
                                        },
                                        "required": [
                                          "venue",
                                          "ticker",
                                          "daily_rate_usd",
                                          "max_spread",
                                          "min_size",
                                          "end_date"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "is_recurring",
                                    "series_ticker",
                                    "recurrence",
                                    "prior_settled_events",
                                    "prior_settled_markets",
                                    "upcoming_events",
                                    "calibration",
                                    "siblings",
                                    "related_markets",
                                    "rewards"
                                  ]
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "kind",
                                "id",
                                "title",
                                "outcome",
                                "line",
                                "window",
                                "legs",
                                "equivalence",
                                "series_context",
                                "livemode"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "event"
                                  ]
                                },
                                "id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "title": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "outcome": {
                                  "type": "string",
                                  "enum": [
                                    "yes",
                                    "no"
                                  ]
                                },
                                "line": {
                                  "nullable": true
                                },
                                "event": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The venue event the market belongs to, such as a Polymarket event's ticker."
                                    },
                                    "title": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "category": {
                                      "type": "string",
                                      "enum": [
                                        "sports",
                                        "crypto",
                                        "politics",
                                        "economy",
                                        "business",
                                        "entertainment",
                                        "science",
                                        "society",
                                        "climate",
                                        "commodities",
                                        "transportation",
                                        "gaming",
                                        "health",
                                        "law",
                                        "uncategorized"
                                      ],
                                      "description": "`crypto` for a coin-price market (Polymarket tagged `crypto-prices`, or `crypto` and `hit-price`; a Hyperliquid outcome tagged `asset:<coin>` for a Hyperliquid coin), whatever its taxonomy; otherwise the first root of the venue event's Lean taxonomy, else the category Kalshi files it under, else `uncategorized`."
                                    },
                                    "ends_at": {
                                      "type": "string",
                                      "nullable": true,
                                      "format": "date-time",
                                      "description": "When the venue market is scheduled to close; null when the venue gives no date."
                                    },
                                    "created_at": {
                                      "type": "string",
                                      "nullable": true,
                                      "format": "date-time",
                                      "description": "When the market was first listed on the venue or indexed by Lean."
                                    },
                                    "series_ticker": {
                                      "type": "string",
                                      "nullable": true,
                                      "description": "Recurring series identifier when the event belongs to a series; null otherwise."
                                    },
                                    "is_recurring": {
                                      "type": "boolean",
                                      "description": "True when the event belongs to a recurring series with prior or repeated iterations."
                                    },
                                    "recurrence": {
                                      "type": "string",
                                      "nullable": true,
                                      "description": "Recurrence cadence reported by the venue (e.g. daily, weekly, monthly), if known."
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "title",
                                    "category",
                                    "ends_at",
                                    "created_at",
                                    "series_ticker",
                                    "is_recurring",
                                    "recurrence"
                                  ]
                                },
                                "legs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "unopened",
                                          "open",
                                          "closed",
                                          "resolving",
                                          "resolved"
                                        ],
                                        "description": "The venue market status: `unopened`, `open`, `closed`, `resolving` or `resolved`; null until Lean has recorded the venue market. The platform shows a live book for every status but `closed` and `resolved`."
                                      },
                                      "tradable": {
                                        "type": "boolean",
                                        "description": "Whether the venue takes orders on this leg now: `status` is `open`, the venue has not marked the market untradable, and the API trades on its venue. An `unopened` or `resolving` leg is live but not tradable."
                                      },
                                      "yes_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 YES outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "no_token": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "On-chain Polymarket ERC1155 NO outcome token id; null on venues that do not use ERC1155 tokens or when not recorded."
                                      },
                                      "lean_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "Direct Lean web terminal link for this market leg and side."
                                      },
                                      "venue_url": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uri",
                                        "description": "External venue page URL (Kalshi, Polymarket, Polymarket US, Hyperliquid), when known."
                                      },
                                      "resolution": {
                                        "type": "object",
                                        "properties": {
                                          "source": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                          },
                                          "rules": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time",
                                            "description": "When the venue market is scheduled to close, if the venue gives one."
                                          },
                                          "url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri",
                                            "description": "The venue's public page for this market, when it can be built from stored data."
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true,
                                            "enum": [
                                              "won",
                                              "lost",
                                              "void"
                                            ],
                                            "description": "How the venue settled this leg's side once `status` is `resolved`: `won` pays $1 a share, `lost` pays nothing, `void` pays the venue's void payout. Null until then."
                                          }
                                        },
                                        "required": [
                                          "source",
                                          "rules",
                                          "end_date",
                                          "url",
                                          "result"
                                        ],
                                        "description": "How this venue resolves its market."
                                      },
                                      "fees": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "formula": {
                                            "type": "string",
                                            "enum": [
                                              "price_curve",
                                              "flat",
                                              "notional_on_exit"
                                            ],
                                            "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                          },
                                          "taker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "maker_rate": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                          },
                                          "exponent": {
                                            "type": "integer",
                                            "nullable": true,
                                            "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                          }
                                        },
                                        "required": [
                                          "formula",
                                          "taker_rate",
                                          "maker_rate",
                                          "exponent"
                                        ],
                                        "description": "What this venue charges a fill, as `POST /v1/orders/preview` prices it; null when the venue's fee terms for the market are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "status",
                                      "tradable",
                                      "yes_token",
                                      "no_token",
                                      "lean_url",
                                      "venue_url",
                                      "resolution",
                                      "fees"
                                    ]
                                  }
                                },
                                "equivalence": {
                                  "type": "string",
                                  "enum": [
                                    "single_venue",
                                    "verified",
                                    "unreviewed"
                                  ],
                                  "description": "`single_venue`: one leg. `verified`: a reviewer confirmed each venue market is the same proposition; rules text can still differ, so read each leg `resolution.rules`. `unreviewed`: at least one leg is not reviewed yet."
                                },
                                "series_context": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "is_recurring": {
                                      "type": "boolean"
                                    },
                                    "series_ticker": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "recurrence": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "prior_settled_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "prior_settled_markets": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "upcoming_events": {
                                      "type": "integer",
                                      "minimum": 0
                                    },
                                    "calibration": {
                                      "type": "object",
                                      "nullable": true,
                                      "properties": {
                                        "sample_size": {
                                          "type": "integer",
                                          "minimum": 0
                                        },
                                        "yes_rate": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Fraction of sampled prior markets that resolved YES."
                                        },
                                        "brier_24h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean squared error (Brier score) of YES prices 24 hours before close vs realized outcome. Lower is sharper."
                                        },
                                        "brier_6h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 6 hours before close vs realized outcome."
                                        },
                                        "brier_1h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of YES prices 1 hour before close vs realized outcome."
                                        },
                                        "brier_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Brier score of final pre-close YES prices vs realized outcome."
                                        },
                                        "log_loss_close": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                          "description": "Mean binary log loss of final pre-close YES prices vs realized outcome."
                                        },
                                        "sharpness": {
                                          "type": "string",
                                          "enum": [
                                            "very_sharp",
                                            "well_calibrated",
                                            "noisy",
                                            "insufficient_history"
                                          ],
                                          "description": "Automatic sharpness classification of prior markets in this series: very_sharp (<0.05 Brier), well_calibrated (<0.12), noisy (>=0.12), or insufficient_history (<3 samples)."
                                        },
                                        "recent_settlements": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "market_id": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "event_ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time"
                                              },
                                              "result": {
                                                "type": "string",
                                                "enum": [
                                                  "yes",
                                                  "no"
                                                ]
                                              },
                                              "expiration_value": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_24h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_6h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_1h_before": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "final_price": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "lean_url": {
                                                "type": "string",
                                                "format": "uri"
                                              },
                                              "venue_url": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "market_id",
                                              "ticker",
                                              "event_ticker",
                                              "title",
                                              "end_date",
                                              "result",
                                              "expiration_value",
                                              "price_24h_before",
                                              "price_6h_before",
                                              "price_1h_before",
                                              "final_price",
                                              "lean_url",
                                              "venue_url"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "sample_size",
                                        "yes_rate",
                                        "brier_24h",
                                        "brier_6h",
                                        "brier_1h",
                                        "brier_close",
                                        "log_loss_close",
                                        "sharpness",
                                        "recent_settlements"
                                      ]
                                    },
                                    "siblings": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "unopened",
                                              "open",
                                              "closed",
                                              "resolving",
                                              "resolved"
                                            ]
                                          },
                                          "result": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "ticker",
                                          "title",
                                          "status",
                                          "result",
                                          "lean_url",
                                          "venue_url"
                                        ]
                                      }
                                    },
                                    "related_markets": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the aligned outcome on the peer venue."
                                          },
                                          "no_market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Orderable Lean market_id for the opposite outcome on the peer venue."
                                          },
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "title": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "lean_url": {
                                            "type": "string",
                                            "format": "uri"
                                          },
                                          "venue_url": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "uri"
                                          },
                                          "compatibility": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "resolution": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "source": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                              },
                                              "rules": {
                                                "type": "string",
                                                "nullable": true,
                                                "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                              },
                                              "end_date": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time",
                                                "description": "When the venue market is scheduled to close, if the venue gives one."
                                              }
                                            },
                                            "required": [
                                              "source",
                                              "rules",
                                              "end_date"
                                            ]
                                          },
                                          "fees": {
                                            "type": "object",
                                            "nullable": true,
                                            "properties": {
                                              "formula": {
                                                "type": "string",
                                                "enum": [
                                                  "price_curve",
                                                  "flat",
                                                  "notional_on_exit"
                                                ],
                                                "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                              },
                                              "taker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "maker_rate": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                              },
                                              "exponent": {
                                                "type": "integer",
                                                "nullable": true,
                                                "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                              }
                                            },
                                            "required": [
                                              "formula",
                                              "taker_rate",
                                              "maker_rate",
                                              "exponent"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "no_market_id",
                                          "venue",
                                          "ticker",
                                          "title",
                                          "lean_url",
                                          "venue_url",
                                          "compatibility",
                                          "resolution",
                                          "fees"
                                        ]
                                      }
                                    },
                                    "rewards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "venue": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "daily_rate_usd": {
                                            "type": "string",
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "max_spread": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "min_size": {
                                            "type": "string",
                                            "nullable": true,
                                            "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                          },
                                          "end_date": {
                                            "type": "string",
                                            "nullable": true,
                                            "format": "date-time"
                                          }
                                        },
                                        "required": [
                                          "venue",
                                          "ticker",
                                          "daily_rate_usd",
                                          "max_spread",
                                          "min_size",
                                          "end_date"
                                        ]
                                      }
                                    }
                                  },
                                  "required": [
                                    "is_recurring",
                                    "series_ticker",
                                    "recurrence",
                                    "prior_settled_events",
                                    "prior_settled_markets",
                                    "upcoming_events",
                                    "calibration",
                                    "siblings",
                                    "related_markets",
                                    "rewards"
                                  ]
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "kind",
                                "id",
                                "title",
                                "outcome",
                                "line",
                                "event",
                                "legs",
                                "equivalence",
                                "series_context",
                                "livemode"
                              ]
                            }
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "kind": "sports",
                    "id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                    "outcome": "DEN",
                    "line": "-3.5",
                    "fixture": {
                      "key": "nfl:2026-10-11:DEN-LAC",
                      "sport": "football",
                      "league": "nfl",
                      "title": "Denver Broncos at Los Angeles Chargers",
                      "starts_at": "2026-10-11T20:25:00.000Z",
                      "scheduled_date": "2026-10-11",
                      "participants": [
                        "Denver Broncos",
                        "Los Angeles Chargers"
                      ],
                      "teams": [
                        {
                          "key": "DEN",
                          "name": "Denver Broncos",
                          "role": "away"
                        },
                        {
                          "key": "LAC",
                          "name": "Los Angeles Chargers",
                          "role": "home"
                        }
                      ]
                    },
                    "group": {
                      "key": "spread:game:DEN:-3.5",
                      "kind": "spread",
                      "template": "sports.handicap",
                      "label": "DEN -3.5",
                      "period": "game",
                      "subject": "DEN",
                      "stat": null,
                      "line": "-3.5"
                    },
                    "legs": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "status": "open",
                        "tradable": true,
                        "yes_token": null,
                        "no_token": null,
                        "lean_url": "https://lean.xyz/trade?ticker=hl%3A9999",
                        "venue_url": "https://app.hyperliquid.xyz/trade",
                        "resolution": {
                          "source": null,
                          "rules": "Resolves YES if the Denver Broncos win by more than 3.5 points, overtime included.",
                          "end_date": "2026-10-12T04:00:00.000Z",
                          "url": null,
                          "result": null
                        },
                        "fees": {
                          "formula": "notional_on_exit",
                          "taker_rate": "0.0007",
                          "maker_rate": "0.0004",
                          "exponent": null
                        }
                      },
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "status": "open",
                        "tradable": true,
                        "yes_token": null,
                        "no_token": null,
                        "lean_url": "https://lean.xyz/trade?ticker=pm%3A0x2222222222222222222222222222222222222222222222222222222222222222",
                        "venue_url": null,
                        "resolution": {
                          "source": null,
                          "rules": "Resolves to Denver Broncos if they win by more than 3.5 points, overtime included.",
                          "end_date": "2026-10-12T04:00:00.000Z",
                          "url": null,
                          "result": null
                        },
                        "fees": {
                          "formula": "price_curve",
                          "taker_rate": "0.03",
                          "maker_rate": "0",
                          "exponent": 1
                        }
                      }
                    ],
                    "equivalence": "verified",
                    "series_context": null,
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not a market id, or a venue symbol that names more than one market",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Not a market id, or a venue symbol that names more than one market"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market with this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market with this id"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}/calibration": {
      "get": {
        "operationId": "getMarketCalibration",
        "summary": "Get series recurrence and Brier calibration",
        "description": "Deep series calibration and recurrence analysis for a market: prior settled iterations (up to 100), Brier scores at 24h / 6h / 1h / close, log loss, empirical YES base rate, sharpness classification, sibling strikes, cross-venue equivalents, and active liquidity rewards.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Maximum prior settled markets in the same series to score (up to 100)."
            },
            "required": false,
            "description": "Maximum prior settled markets in the same series to score (up to 100).",
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Series recurrence, prior Brier score calibration, siblings, and rewards",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "is_recurring": {
                              "type": "boolean"
                            },
                            "series_ticker": {
                              "type": "string",
                              "nullable": true
                            },
                            "recurrence": {
                              "type": "string",
                              "nullable": true
                            },
                            "prior_settled_events": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "prior_settled_markets": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "upcoming_events": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "calibration": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "sample_size": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "yes_rate": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Fraction of sampled prior markets that resolved YES."
                                },
                                "brier_24h": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Mean squared error (Brier score) of YES prices 24 hours before close vs realized outcome. Lower is sharper."
                                },
                                "brier_6h": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Brier score of YES prices 6 hours before close vs realized outcome."
                                },
                                "brier_1h": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Brier score of YES prices 1 hour before close vs realized outcome."
                                },
                                "brier_close": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Brier score of final pre-close YES prices vs realized outcome."
                                },
                                "log_loss_close": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Mean binary log loss of final pre-close YES prices vs realized outcome."
                                },
                                "sharpness": {
                                  "type": "string",
                                  "enum": [
                                    "very_sharp",
                                    "well_calibrated",
                                    "noisy",
                                    "insufficient_history"
                                  ],
                                  "description": "Automatic sharpness classification of prior markets in this series: very_sharp (<0.05 Brier), well_calibrated (<0.12), noisy (>=0.12), or insufficient_history (<3 samples)."
                                },
                                "recent_settlements": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "event_ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "end_date": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "result": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "expiration_value": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "price_24h_before": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "price_6h_before": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "price_1h_before": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "final_price": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "lean_url": {
                                        "type": "string",
                                        "format": "uri"
                                      },
                                      "venue_url": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uri"
                                      }
                                    },
                                    "required": [
                                      "market_id",
                                      "ticker",
                                      "event_ticker",
                                      "title",
                                      "end_date",
                                      "result",
                                      "expiration_value",
                                      "price_24h_before",
                                      "price_6h_before",
                                      "price_1h_before",
                                      "final_price",
                                      "lean_url",
                                      "venue_url"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "sample_size",
                                "yes_rate",
                                "brier_24h",
                                "brier_6h",
                                "brier_1h",
                                "brier_close",
                                "log_loss_close",
                                "sharpness",
                                "recent_settlements"
                              ]
                            },
                            "siblings": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "unopened",
                                      "open",
                                      "closed",
                                      "resolving",
                                      "resolved"
                                    ]
                                  },
                                  "result": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "ticker",
                                  "title",
                                  "status",
                                  "result",
                                  "lean_url",
                                  "venue_url"
                                ]
                              }
                            },
                            "related_markets": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "Orderable Lean market_id for the aligned outcome on the peer venue."
                                  },
                                  "no_market_id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "Orderable Lean market_id for the opposite outcome on the peer venue."
                                  },
                                  "venue": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  },
                                  "compatibility": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "resolution": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "source": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                      },
                                      "rules": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                      },
                                      "end_date": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time",
                                        "description": "When the venue market is scheduled to close, if the venue gives one."
                                      }
                                    },
                                    "required": [
                                      "source",
                                      "rules",
                                      "end_date"
                                    ]
                                  },
                                  "fees": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "formula": {
                                        "type": "string",
                                        "enum": [
                                          "price_curve",
                                          "flat",
                                          "notional_on_exit"
                                        ],
                                        "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                      },
                                      "taker_rate": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                      },
                                      "maker_rate": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                      },
                                      "exponent": {
                                        "type": "integer",
                                        "nullable": true,
                                        "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                      }
                                    },
                                    "required": [
                                      "formula",
                                      "taker_rate",
                                      "maker_rate",
                                      "exponent"
                                    ]
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "no_market_id",
                                  "venue",
                                  "ticker",
                                  "title",
                                  "lean_url",
                                  "venue_url",
                                  "compatibility",
                                  "resolution",
                                  "fees"
                                ]
                              }
                            },
                            "rewards": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "daily_rate_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "max_spread": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "min_size": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "end_date": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "daily_rate_usd",
                                  "max_spread",
                                  "min_size",
                                  "end_date"
                                ]
                              }
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "is_recurring",
                            "series_ticker",
                            "recurrence",
                            "prior_settled_events",
                            "prior_settled_markets",
                            "upcoming_events",
                            "calibration",
                            "siblings",
                            "related_markets",
                            "rewards",
                            "market_id",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Not a market id, or a venue symbol that names more than one market",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Not a market id, or a venue symbol that names more than one market"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market with this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market with this id"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}/quote": {
      "get": {
        "operationId": "quoteMarket",
        "summary": "Quote a market",
        "description": "The best price to buy a quantity across venues right now, or to sell it from the shares the account holds, with the venue legs that would fill it. A venue symbol is quoted on the one listing it names, which is all an order naming it trades. Nothing is placed or reserved, and books can move before you order.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "buy",
                "sell"
              ],
              "default": "buy"
            },
            "required": false,
            "name": "action",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^\\d+(?:\\.\\d+)?$",
              "description": "Shares to buy or sell. Send exactly one of quantity or notional.",
              "example": "10"
            },
            "required": false,
            "description": "Shares to buy or sell. Send exactly one of quantity or notional.",
            "name": "quantity",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^\\d+(?:\\.\\d{1,2})?$",
              "description": "Amount to spend in USD on a buy, in place of quantity. The quote shows how many shares this buys at the current book.",
              "example": "25"
            },
            "required": false,
            "description": "Amount to spend in USD on a buy, in place of quantity, at most two decimals. The quote shows how many shares this buys at the current book.",
            "name": "notional",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Best executable route for buying a quantity, or for selling it from the shares held; places nothing",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "executable_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "average_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "average_price": {
                                    "type": "string"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "fee_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "executable": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "average_price",
                                  "limit_price",
                                  "fee_usd",
                                  "executable"
                                ]
                              }
                            },
                            "expected_total_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "max_total_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "network_cost_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "limited_by": {
                              "type": "string",
                              "nullable": true
                            },
                            "quoted_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "expires_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_id",
                            "action",
                            "quantity",
                            "executable_quantity",
                            "average_price",
                            "legs",
                            "expected_total_usd",
                            "max_total_usd",
                            "network_cost_usd",
                            "limited_by",
                            "quoted_at",
                            "expires_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Quote": {
                    "summary": "A buy of 5 shares",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "5",
                        "executable_quantity": "5",
                        "average_price": "0.47",
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "average_price": "0.47",
                            "limit_price": "0.50",
                            "fee_usd": "0",
                            "executable": true
                          }
                        ],
                        "expected_total_usd": "2.35",
                        "max_total_usd": "2.5",
                        "network_cost_usd": "0",
                        "limited_by": null,
                        "quoted_at": "2026-10-11T18:00:00.000Z",
                        "expires_at": "2026-10-11T18:00:15.000Z",
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Invalid quantity": {
                    "summary": "quantity is not a positive decimal",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "quantity",
                            "message": "Invalid"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "Market not found",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Market not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A venue has stopped trading the market, so there is nothing to quote or fill against; details.reason is MARKET_NOT_TRADABLE. Its book still reads with 200.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "market_not_tradable": {
                    "summary": "The venue stopped trading the market",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "Polymarket has stopped trading this market",
                        "details": {
                          "reason": "MARKET_NOT_TRADABLE"
                        }
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Send exactly one of quantity or notional, and notional only with a buy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Send exactly one of quantity or notional, and notional only with a buy"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "A venue failed or did not answer, or routing is paused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Venue error": {
                    "summary": "The venue failed or did not answer",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "A required service is temporarily unavailable."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  },
                  "Routing paused": {
                    "summary": "Routing is not available, so quotes cannot be served",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FEATURE_DISABLED",
                        "message": "Cross-venue routing is paused"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "c4e19a72-8d05-4f3b-a6e1-7b2d9c0f5e48"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/discover": {
      "post": {
        "operationId": "discoverMarkets",
        "summary": "Discover live markets with fine-grained bid/ask, taxonomy, and optional live books",
        "description": "Queries the same live in-memory Market Discovery index that powers Lean Discover across Kalshi, Polymarket, Polymarket US, Hyperliquid, and Lighter. Filter by fine-grained YES bid and YES ask bounds, spread, 24h move, volume, open interest, categories, tags, recurrence frequency, keywords, and time windows. Set `include_books: true` to attach live WS-backed L2 orderbooks and filter by live depth in one call. Every event and outcome includes both `lean_url` and external `venue_url`.",
        "tags": [
          "Markets"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "venues": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "kalshi",
                        "polymarket",
                        "polymarket_us",
                        "hyperliquid",
                        "lighter"
                      ]
                    },
                    "maxItems": 8,
                    "description": "Restrict discovery to these venues (kalshi, polymarket, polymarket_us, hyperliquid, lighter)."
                  },
                  "categories": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Display category keys or aliases (e.g. \"politics\", \"economics\", \"sports\", \"crypto\", or exact keys from GET /v1/discover/taxonomy)."
                  },
                  "exclude_categories": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Exclude events carrying any of these category keys or aliases (e.g. [\"sports\"] to find non-sports markets)."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Include events matching any of these tags (ORed with categories)."
                  },
                  "exclude_tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Exclude events carrying any of these tags (even when they match a selected category)."
                  },
                  "frequencies": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "fiveMin",
                        "fifteenMin",
                        "hourly",
                        "fourHour",
                        "daily",
                        "weekly",
                        "monthly",
                        "quarterly",
                        "annual"
                      ]
                    },
                    "maxItems": 16,
                    "description": "Only recurring series on these cadences (fiveMin, fifteenMin, hourly, fourHour, daily, weekly, monthly, quarterly, annual)."
                  },
                  "market_types": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "mentions",
                        "priceUpDown",
                        "dailyTemperature"
                      ]
                    },
                    "maxItems": 16,
                    "description": "Only events of these structured types (mentions, priceUpDown, dailyTemperature)."
                  },
                  "rewards": {
                    "type": "string",
                    "enum": [
                      "any",
                      "has",
                      "none"
                    ],
                    "description": "Filter by liquidity rewards: any (default), has, or none."
                  },
                  "search": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Ranked free-text search across titles, outcomes, and tags (all words must match)."
                  },
                  "include_keywords": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 20,
                    "description": "Match events containing any of these substrings."
                  },
                  "exclude_keywords": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 20,
                    "description": "Exclude events containing any of these substrings."
                  },
                  "keyword_scope": {
                    "type": "string",
                    "enum": [
                      "title",
                      "titleAndOutcomes"
                    ],
                    "description": "Where include/exclude keywords match: title or titleAndOutcomes (default)."
                  },
                  "min_bid": {
                    "type": "string",
                    "description": "Minimum live YES bid price in dollars (0 to 1, e.g. \"0.10\" for 10¢)."
                  },
                  "max_bid": {
                    "type": "string",
                    "description": "Maximum live YES bid price in dollars (0 to 1, e.g. \"0.45\" for 45¢)."
                  },
                  "min_ask": {
                    "type": "string",
                    "description": "Minimum live YES ask price in dollars (0 to 1, e.g. \"0.12\" for 12¢)."
                  },
                  "max_ask": {
                    "type": "string",
                    "description": "Maximum live YES ask price in dollars (0 to 1, e.g. \"0.50\" for 50¢)."
                  },
                  "min_spread": {
                    "type": "string",
                    "description": "Minimum live YES bid-ask spread in dollars (e.g. \"0.01\")."
                  },
                  "max_spread": {
                    "type": "string",
                    "description": "Maximum live YES bid-ask spread in dollars (e.g. \"0.03\" for 3¢)."
                  },
                  "min_change_24h": {
                    "type": "string",
                    "description": "Minimum absolute 24h price change in dollars (e.g. \"0.05\" for 5¢ move)."
                  },
                  "max_change_24h": {
                    "type": "string",
                    "description": "Maximum absolute 24h price change in dollars."
                  },
                  "move_direction": {
                    "type": "string",
                    "enum": [
                      "any",
                      "up",
                      "down"
                    ],
                    "description": "Direction of 24h price move: any, up, or down."
                  },
                  "match_any_outcome": {
                    "type": "boolean",
                    "description": "When true (default for /v1), bid/ask/spread/change filters match if ANY outcome in a multi-strike event passes, and matching strikes appear first."
                  },
                  "min_volume_24h": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Minimum 24h dollars traded, as `volume_24h_usd` reports it."
                  },
                  "max_volume_24h": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Maximum 24h dollars traded, as `volume_24h_usd` reports it."
                  },
                  "min_open_interest": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Minimum open interest in contracts."
                  },
                  "max_open_interest": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Maximum open interest in contracts."
                  },
                  "expires_after": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Only events closing at or after this ISO 8601 time."
                  },
                  "expires_before": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Only events closing before this ISO 8601 time."
                  },
                  "created_after": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Only events created at or after this ISO 8601 time."
                  },
                  "created_before": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Only events created before this ISO 8601 time."
                  },
                  "series_tickers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Restrict discovery to these exact series tickers (e.g. [\"KXFED\", \"KXHIGHNY\"])."
                  },
                  "event_tickers": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Restrict discovery to these exact event tickers."
                  },
                  "exclude_event_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 300
                    },
                    "maxItems": 200,
                    "description": "Exclude events with these exact event `id`s (from prior discover_markets results) to paginate across unseen markets without repeats. For a collapsed row, also pass every event_group.members[].id, since another member of the same real-world event can otherwise lead the row on a later page."
                  },
                  "collapse_event_groups": {
                    "type": "boolean",
                    "description": "When true (default), merge cross-venue listings of the same real-world event into one row with event_group.members."
                  },
                  "sort": {
                    "type": "string",
                    "enum": [
                      "volume",
                      "open_interest",
                      "bid",
                      "ask",
                      "spread",
                      "change",
                      "close",
                      "rewards",
                      "yes_taker",
                      "title"
                    ],
                    "description": "Sort order: volume (default), open_interest, bid, ask, spread, change, close, rewards, yes_taker, or title."
                  },
                  "descending": {
                    "type": "boolean",
                    "description": "Sort descending (default true; pass false for tightest spreads or soonest close)."
                  },
                  "outcome_limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Maximum outcomes returned per event (default 5, max 50), applied after book filters."
                  },
                  "start": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000,
                    "description": "Offset into the filtered result list (default 0)."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Maximum events returned (default 25, max 100)."
                  },
                  "include_books": {
                    "type": "boolean",
                    "description": "When true, fetches live WS-backed L2 orderbooks for the discovered outcomes in the same call (up to 100 outcomes) and attaches each outcome.book. With min_bid_notional_usd, min_ask_notional_usd, or only_liquid, every candidate outcome of each selected event is checked before outcome_limit applies, so a request needing more than 100 outcome books, or an event with more than 50 candidate outcomes, returns 400 instead of dropping unchecked outcomes."
                  },
                  "include_rules": {
                    "type": "boolean",
                    "description": "When true, fetches batched settlement rules (`resolution`) and venue `fees` for every discovered outcome in one call (zero N+1 get_market loops)."
                  },
                  "book_depth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Levels per side when include_books is true (default 10, max 100)."
                  },
                  "min_bid_notional_usd": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "When include_books is true, drop outcomes whose live total bid notional is below this USD amount."
                  },
                  "min_ask_notional_usd": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "When include_books is true, drop outcomes whose live total ask notional is below this USD amount."
                  },
                  "only_liquid": {
                    "type": "boolean",
                    "description": "When include_books is true, drop outcomes with an empty live book (no bids and no asks)."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Discovered markets with live quotes, URLs, and optional L2 books",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "categories": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "series_ticker": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "is_recurring": {
                                    "type": "boolean"
                                  },
                                  "recurrence": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "frequency": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "fiveMin",
                                      "fifteenMin",
                                      "hourly",
                                      "fourHour",
                                      "daily",
                                      "weekly",
                                      "monthly",
                                      "quarterly",
                                      "annual"
                                    ]
                                  },
                                  "close_time": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "created_time": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "volume_24h_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                  },
                                  "open_interest": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0
                                  },
                                  "rewards_daily_rate_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "market_count": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  },
                                  "event_group": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "volume_24h_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                      },
                                      "members": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "minLength": 1,
                                              "description": "Discovery event `id` of this venue event; pass it in exclude_event_ids with the row `id`."
                                            },
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "event_ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "title": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "volume_24h_usd": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                            },
                                            "market_count": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "exclusiveMinimum": true
                                            },
                                            "lean_url": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "uri"
                                            },
                                            "venue_url": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "uri"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "venue",
                                            "event_ticker",
                                            "title",
                                            "volume_24h_usd",
                                            "market_count",
                                            "lean_url",
                                            "venue_url"
                                          ]
                                        }
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "title",
                                      "volume_24h_usd",
                                      "members"
                                    ]
                                  },
                                  "outcomes": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "market_id": {
                                          "type": "string",
                                          "minLength": 1,
                                          "description": "Orderable Lean market_id for the YES (or UP) outcome."
                                        },
                                        "no_market_id": {
                                          "type": "string",
                                          "minLength": 1,
                                          "description": "Orderable Lean market_id for the NO (or DOWN) outcome, ready for preview/order calls without extra lookups."
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "label": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "yes_bid": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "yes_ask": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "no_bid": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "no_ask": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "spread": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "price_change_24h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                        },
                                        "volume_24h_usd": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$",
                                          "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                        },
                                        "open_interest": {
                                          "type": "integer",
                                          "nullable": true,
                                          "minimum": 0
                                        },
                                        "yes_taker_pct_24h": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                        },
                                        "close_time": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "date-time"
                                        },
                                        "rewards_daily_rate_usd": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "lean_url": {
                                          "type": "string",
                                          "format": "uri"
                                        },
                                        "venue_url": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "uri"
                                        },
                                        "book": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "market_id": {
                                              "type": "string",
                                              "minLength": 1,
                                              "description": "The market id from GET /markets, however the request named the market."
                                            },
                                            "venues": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "venue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "kalshi",
                                                      "polymarket",
                                                      "polymarket_us",
                                                      "hyperliquid",
                                                      "lighter"
                                                    ]
                                                  },
                                                  "ticker": {
                                                    "type": "string",
                                                    "minLength": 1
                                                  },
                                                  "side": {
                                                    "type": "string",
                                                    "enum": [
                                                      "yes",
                                                      "no"
                                                    ]
                                                  },
                                                  "bids": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "price": {
                                                          "type": "string"
                                                        },
                                                        "quantity": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        }
                                                      },
                                                      "required": [
                                                        "price",
                                                        "quantity"
                                                      ]
                                                    }
                                                  },
                                                  "asks": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "price": {
                                                          "type": "string"
                                                        },
                                                        "quantity": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        }
                                                      },
                                                      "required": [
                                                        "price",
                                                        "quantity"
                                                      ]
                                                    }
                                                  },
                                                  "bid_quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "ask_quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "bid_notional_usd": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "ask_notional_usd": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "lean_url": {
                                                    "type": "string",
                                                    "format": "uri"
                                                  },
                                                  "venue_url": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "format": "uri"
                                                  }
                                                },
                                                "required": [
                                                  "venue",
                                                  "ticker",
                                                  "side",
                                                  "bids",
                                                  "asks",
                                                  "bid_quantity",
                                                  "ask_quantity",
                                                  "bid_notional_usd",
                                                  "ask_notional_usd",
                                                  "lean_url",
                                                  "venue_url"
                                                ]
                                              }
                                            },
                                            "combined": {
                                              "type": "object",
                                              "properties": {
                                                "bids": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "price": {
                                                        "type": "string"
                                                      },
                                                      "quantity": {
                                                        "type": "string",
                                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                                      },
                                                      "venues": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "venue": {
                                                              "type": "string",
                                                              "enum": [
                                                                "kalshi",
                                                                "polymarket",
                                                                "polymarket_us",
                                                                "hyperliquid",
                                                                "lighter"
                                                              ]
                                                            },
                                                            "quantity": {
                                                              "type": "string",
                                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                                            }
                                                          },
                                                          "required": [
                                                            "venue",
                                                            "quantity"
                                                          ]
                                                        }
                                                      }
                                                    },
                                                    "required": [
                                                      "price",
                                                      "quantity",
                                                      "venues"
                                                    ]
                                                  }
                                                },
                                                "asks": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "price": {
                                                        "type": "string"
                                                      },
                                                      "quantity": {
                                                        "type": "string",
                                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                                      },
                                                      "venues": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "venue": {
                                                              "type": "string",
                                                              "enum": [
                                                                "kalshi",
                                                                "polymarket",
                                                                "polymarket_us",
                                                                "hyperliquid",
                                                                "lighter"
                                                              ]
                                                            },
                                                            "quantity": {
                                                              "type": "string",
                                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                                            }
                                                          },
                                                          "required": [
                                                            "venue",
                                                            "quantity"
                                                          ]
                                                        }
                                                      }
                                                    },
                                                    "required": [
                                                      "price",
                                                      "quantity",
                                                      "venues"
                                                    ]
                                                  }
                                                }
                                              },
                                              "required": [
                                                "bids",
                                                "asks"
                                              ]
                                            },
                                            "total_bid_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "total_ask_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "total_bid_notional_usd": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "total_ask_notional_usd": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "unavailable": {
                                              "type": "array",
                                              "items": {
                                                "type": "string",
                                                "enum": [
                                                  "kalshi",
                                                  "polymarket",
                                                  "polymarket_us",
                                                  "hyperliquid",
                                                  "lighter"
                                                ]
                                              }
                                            },
                                            "as_of": {
                                              "type": "string",
                                              "format": "date-time"
                                            },
                                            "no_market_id": {
                                              "type": "string",
                                              "nullable": true,
                                              "minLength": 1,
                                              "description": "Orderable Lean market_id for the opposite NO/DOWN outcome when this book is a YES/UP binary market, enabling direct NO-side previews and orders without extra lookups."
                                            },
                                            "title": {
                                              "type": "string",
                                              "nullable": true,
                                              "minLength": 1
                                            },
                                            "outcome": {
                                              "type": "string",
                                              "nullable": true,
                                              "minLength": 1
                                            },
                                            "best_bid": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "best_ask": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "mid": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "weighted_mid": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "Top-of-book depth-weighted midpoint (microprice) across venues; null when either side is empty."
                                            },
                                            "spread": {
                                              "type": "string",
                                              "nullable": true,
                                              "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                            },
                                            "book_source": {
                                              "type": "string",
                                              "enum": [
                                                "live",
                                                "rest",
                                                "mixed"
                                              ],
                                              "description": "`live`: served from live venue WebSocket feeds. `rest`: fetched via venue REST. `mixed`: combination across venues."
                                            },
                                            "resolution": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "source": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                },
                                                "rules": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                },
                                                "end_date": {
                                                  "type": "string",
                                                  "nullable": true,
                                                  "format": "date-time",
                                                  "description": "When the venue market is scheduled to close, if the venue gives one."
                                                }
                                              },
                                              "required": [
                                                "source",
                                                "rules",
                                                "end_date"
                                              ],
                                              "description": "Attached when `include_rules: true`: the listing's settlement rules, source, and scheduled end date; null when the book combines several venue listings (pass `venue` to read one listing's terms)."
                                            },
                                            "fees": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "formula": {
                                                  "type": "string",
                                                  "enum": [
                                                    "price_curve",
                                                    "flat",
                                                    "notional_on_exit"
                                                  ],
                                                  "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                },
                                                "taker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "maker_rate": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                                  "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                },
                                                "exponent": {
                                                  "type": "integer",
                                                  "nullable": true,
                                                  "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                }
                                              },
                                              "required": [
                                                "formula",
                                                "taker_rate",
                                                "maker_rate",
                                                "exponent"
                                              ],
                                              "description": "Attached when `include_rules: true`: the listing's venue fee formula and taker/maker rates; null when the book combines several venue listings (pass `venue` to read one listing's terms), or when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                            }
                                          },
                                          "required": [
                                            "market_id",
                                            "venues",
                                            "combined",
                                            "total_bid_quantity",
                                            "total_ask_quantity",
                                            "total_bid_notional_usd",
                                            "total_ask_notional_usd",
                                            "unavailable",
                                            "as_of",
                                            "title",
                                            "outcome",
                                            "best_bid",
                                            "best_ask",
                                            "mid",
                                            "weighted_mid",
                                            "spread",
                                            "book_source"
                                          ]
                                        },
                                        "resolution": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "source": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                            },
                                            "rules": {
                                              "type": "string",
                                              "nullable": true,
                                              "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                            },
                                            "end_date": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time",
                                              "description": "When the venue market is scheduled to close, if the venue gives one."
                                            }
                                          },
                                          "required": [
                                            "source",
                                            "rules",
                                            "end_date"
                                          ],
                                          "description": "Attached when `include_rules: true`: settlement rules, source, and scheduled end date."
                                        },
                                        "fees": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "formula": {
                                              "type": "string",
                                              "enum": [
                                                "price_curve",
                                                "flat",
                                                "notional_on_exit"
                                              ],
                                              "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                            },
                                            "taker_rate": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                            },
                                            "maker_rate": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                            },
                                            "exponent": {
                                              "type": "integer",
                                              "nullable": true,
                                              "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                            }
                                          },
                                          "required": [
                                            "formula",
                                            "taker_rate",
                                            "maker_rate",
                                            "exponent"
                                          ],
                                          "description": "Attached when `include_rules: true`: venue fee formula and taker/maker rates; null when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                        }
                                      },
                                      "required": [
                                        "market_id",
                                        "no_market_id",
                                        "ticker",
                                        "title",
                                        "label",
                                        "yes_bid",
                                        "yes_ask",
                                        "no_bid",
                                        "no_ask",
                                        "spread",
                                        "price_change_24h",
                                        "volume_24h_usd",
                                        "open_interest",
                                        "yes_taker_pct_24h",
                                        "close_time",
                                        "rewards_daily_rate_usd",
                                        "lean_url",
                                        "venue_url",
                                        "book"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "id",
                                  "venue",
                                  "event_ticker",
                                  "title",
                                  "categories",
                                  "tags",
                                  "series_ticker",
                                  "is_recurring",
                                  "recurrence",
                                  "frequency",
                                  "close_time",
                                  "created_time",
                                  "volume_24h_usd",
                                  "open_interest",
                                  "rewards_daily_rate_usd",
                                  "market_count",
                                  "lean_url",
                                  "venue_url",
                                  "event_group",
                                  "outcomes"
                                ]
                              }
                            },
                            "total_events": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "total_markets": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "universe_events": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "description": "Events in the whole discovery catalog; null when the database fallback answered."
                            },
                            "universe_markets": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "description": "Markets in the whole discovery catalog; null when the database fallback answered."
                            },
                            "related_tags": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "markets": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "key",
                                  "markets"
                                ]
                              }
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "discovery_index",
                                "database_fallback"
                              ]
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "events",
                            "total_events",
                            "total_markets",
                            "universe_events",
                            "universe_markets",
                            "related_tags",
                            "source",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/discover/batch": {
      "post": {
        "operationId": "discoverMarketsBatch",
        "summary": "Run up to 15 labeled market discovery queries concurrently in one call",
        "description": "Executes up to 15 independent Market Discovery queries concurrently against the live in-memory index in one HTTP call, deduplicating optional `include_books` (up to 100 unique markets across the batch) and `include_rules` lookups so multi-topic scans and repeating research loops avoid rate limits and round-trip overhead.",
        "tags": [
          "Markets"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "queries": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "venues": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "kalshi",
                              "polymarket",
                              "polymarket_us",
                              "hyperliquid",
                              "lighter"
                            ]
                          },
                          "maxItems": 8,
                          "description": "Restrict discovery to these venues (kalshi, polymarket, polymarket_us, hyperliquid, lighter)."
                        },
                        "categories": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Display category keys or aliases (e.g. \"politics\", \"economics\", \"sports\", \"crypto\", or exact keys from GET /v1/discover/taxonomy)."
                        },
                        "exclude_categories": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Exclude events carrying any of these category keys or aliases (e.g. [\"sports\"] to find non-sports markets)."
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Include events matching any of these tags (ORed with categories)."
                        },
                        "exclude_tags": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Exclude events carrying any of these tags (even when they match a selected category)."
                        },
                        "frequencies": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "fiveMin",
                              "fifteenMin",
                              "hourly",
                              "fourHour",
                              "daily",
                              "weekly",
                              "monthly",
                              "quarterly",
                              "annual"
                            ]
                          },
                          "maxItems": 16,
                          "description": "Only recurring series on these cadences (fiveMin, fifteenMin, hourly, fourHour, daily, weekly, monthly, quarterly, annual)."
                        },
                        "market_types": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "mentions",
                              "priceUpDown",
                              "dailyTemperature"
                            ]
                          },
                          "maxItems": 16,
                          "description": "Only events of these structured types (mentions, priceUpDown, dailyTemperature)."
                        },
                        "rewards": {
                          "type": "string",
                          "enum": [
                            "any",
                            "has",
                            "none"
                          ],
                          "description": "Filter by liquidity rewards: any (default), has, or none."
                        },
                        "search": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "Ranked free-text search across titles, outcomes, and tags (all words must match)."
                        },
                        "include_keywords": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 20,
                          "description": "Match events containing any of these substrings."
                        },
                        "exclude_keywords": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 20,
                          "description": "Exclude events containing any of these substrings."
                        },
                        "keyword_scope": {
                          "type": "string",
                          "enum": [
                            "title",
                            "titleAndOutcomes"
                          ],
                          "description": "Where include/exclude keywords match: title or titleAndOutcomes (default)."
                        },
                        "min_bid": {
                          "type": "string",
                          "description": "Minimum live YES bid price in dollars (0 to 1, e.g. \"0.10\" for 10¢)."
                        },
                        "max_bid": {
                          "type": "string",
                          "description": "Maximum live YES bid price in dollars (0 to 1, e.g. \"0.45\" for 45¢)."
                        },
                        "min_ask": {
                          "type": "string",
                          "description": "Minimum live YES ask price in dollars (0 to 1, e.g. \"0.12\" for 12¢)."
                        },
                        "max_ask": {
                          "type": "string",
                          "description": "Maximum live YES ask price in dollars (0 to 1, e.g. \"0.50\" for 50¢)."
                        },
                        "min_spread": {
                          "type": "string",
                          "description": "Minimum live YES bid-ask spread in dollars (e.g. \"0.01\")."
                        },
                        "max_spread": {
                          "type": "string",
                          "description": "Maximum live YES bid-ask spread in dollars (e.g. \"0.03\" for 3¢)."
                        },
                        "min_change_24h": {
                          "type": "string",
                          "description": "Minimum absolute 24h price change in dollars (e.g. \"0.05\" for 5¢ move)."
                        },
                        "max_change_24h": {
                          "type": "string",
                          "description": "Maximum absolute 24h price change in dollars."
                        },
                        "move_direction": {
                          "type": "string",
                          "enum": [
                            "any",
                            "up",
                            "down"
                          ],
                          "description": "Direction of 24h price move: any, up, or down."
                        },
                        "match_any_outcome": {
                          "type": "boolean",
                          "description": "When true (default for /v1), bid/ask/spread/change filters match if ANY outcome in a multi-strike event passes, and matching strikes appear first."
                        },
                        "min_volume_24h": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "Minimum 24h dollars traded, as `volume_24h_usd` reports it."
                        },
                        "max_volume_24h": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "Maximum 24h dollars traded, as `volume_24h_usd` reports it."
                        },
                        "min_open_interest": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Minimum open interest in contracts."
                        },
                        "max_open_interest": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "Maximum open interest in contracts."
                        },
                        "expires_after": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Only events closing at or after this ISO 8601 time."
                        },
                        "expires_before": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Only events closing before this ISO 8601 time."
                        },
                        "created_after": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Only events created at or after this ISO 8601 time."
                        },
                        "created_before": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Only events created before this ISO 8601 time."
                        },
                        "series_tickers": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Restrict discovery to these exact series tickers (e.g. [\"KXFED\", \"KXHIGHNY\"])."
                        },
                        "event_tickers": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "maxItems": 50,
                          "description": "Restrict discovery to these exact event tickers."
                        },
                        "exclude_event_ids": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 300
                          },
                          "maxItems": 200,
                          "description": "Exclude events with these exact event `id`s (from prior discover_markets results) to paginate across unseen markets without repeats. For a collapsed row, also pass every event_group.members[].id, since another member of the same real-world event can otherwise lead the row on a later page."
                        },
                        "collapse_event_groups": {
                          "type": "boolean",
                          "description": "When true (default), merge cross-venue listings of the same real-world event into one row with event_group.members."
                        },
                        "sort": {
                          "type": "string",
                          "enum": [
                            "volume",
                            "open_interest",
                            "bid",
                            "ask",
                            "spread",
                            "change",
                            "close",
                            "rewards",
                            "yes_taker",
                            "title"
                          ],
                          "description": "Sort order: volume (default), open_interest, bid, ask, spread, change, close, rewards, yes_taker, or title."
                        },
                        "descending": {
                          "type": "boolean",
                          "description": "Sort descending (default true; pass false for tightest spreads or soonest close)."
                        },
                        "outcome_limit": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 50,
                          "description": "Maximum outcomes returned per event (default 5, max 50), applied after book filters."
                        },
                        "start": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000,
                          "description": "Offset into the filtered result list (default 0)."
                        },
                        "limit": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 25,
                          "description": "Maximum events returned for this query (default 10, max 25)."
                        },
                        "include_books": {
                          "type": "boolean",
                          "description": "When true, fetches live WS-backed L2 orderbooks for the discovered outcomes in the same call (up to 100 outcomes) and attaches each outcome.book. With min_bid_notional_usd, min_ask_notional_usd, or only_liquid, every candidate outcome of each selected event is checked before outcome_limit applies, so a request needing more than 100 outcome books, or an event with more than 50 candidate outcomes, returns 400 instead of dropping unchecked outcomes."
                        },
                        "include_rules": {
                          "type": "boolean",
                          "description": "When true, fetches batched settlement rules (`resolution`) and venue `fees` for every discovered outcome in one call (zero N+1 get_market loops)."
                        },
                        "book_depth": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 100,
                          "description": "Levels per side when include_books is true (default 10, max 100)."
                        },
                        "min_bid_notional_usd": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "When include_books is true, drop outcomes whose live total bid notional is below this USD amount."
                        },
                        "min_ask_notional_usd": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "When include_books is true, drop outcomes whose live total ask notional is below this USD amount."
                        },
                        "only_liquid": {
                          "type": "boolean",
                          "description": "When include_books is true, drop outcomes with an empty live book (no bids and no asks)."
                        },
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "description": "Caller-chosen label identifying this search in the batch response (e.g. \"fed\", \"weather\", \"ai\")."
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 15,
                    "description": "From 1 to 15 independent labeled discovery queries to execute concurrently in one call, sharing deduplicated live book and rules lookups."
                  }
                },
                "required": [
                  "queries"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Labeled discovery results for each requested query, with optional shared live L2 books and settlement rules",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "events": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid",
                                            "lighter"
                                          ]
                                        },
                                        "event_ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "title": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "categories": {
                                          "type": "array",
                                          "items": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "tags": {
                                          "type": "array",
                                          "items": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "series_ticker": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "is_recurring": {
                                          "type": "boolean"
                                        },
                                        "recurrence": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "frequency": {
                                          "type": "string",
                                          "nullable": true,
                                          "enum": [
                                            "fiveMin",
                                            "fifteenMin",
                                            "hourly",
                                            "fourHour",
                                            "daily",
                                            "weekly",
                                            "monthly",
                                            "quarterly",
                                            "annual"
                                          ]
                                        },
                                        "close_time": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "date-time"
                                        },
                                        "created_time": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "date-time"
                                        },
                                        "volume_24h_usd": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$",
                                          "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                        },
                                        "open_interest": {
                                          "type": "integer",
                                          "nullable": true,
                                          "minimum": 0
                                        },
                                        "rewards_daily_rate_usd": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "market_count": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "exclusiveMinimum": true
                                        },
                                        "lean_url": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "uri"
                                        },
                                        "venue_url": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "uri"
                                        },
                                        "event_group": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "title": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "volume_24h_usd": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                            },
                                            "members": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "description": "Discovery event `id` of this venue event; pass it in exclude_event_ids with the row `id`."
                                                  },
                                                  "venue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "kalshi",
                                                      "polymarket",
                                                      "polymarket_us",
                                                      "hyperliquid",
                                                      "lighter"
                                                    ]
                                                  },
                                                  "event_ticker": {
                                                    "type": "string",
                                                    "minLength": 1
                                                  },
                                                  "title": {
                                                    "type": "string",
                                                    "minLength": 1
                                                  },
                                                  "volume_24h_usd": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                                    "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                                  },
                                                  "market_count": {
                                                    "type": "integer",
                                                    "minimum": 0,
                                                    "exclusiveMinimum": true
                                                  },
                                                  "lean_url": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "format": "uri"
                                                  },
                                                  "venue_url": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "format": "uri"
                                                  }
                                                },
                                                "required": [
                                                  "id",
                                                  "venue",
                                                  "event_ticker",
                                                  "title",
                                                  "volume_24h_usd",
                                                  "market_count",
                                                  "lean_url",
                                                  "venue_url"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "title",
                                            "volume_24h_usd",
                                            "members"
                                          ]
                                        },
                                        "outcomes": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "market_id": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "Orderable Lean market_id for the YES (or UP) outcome."
                                              },
                                              "no_market_id": {
                                                "type": "string",
                                                "minLength": 1,
                                                "description": "Orderable Lean market_id for the NO (or DOWN) outcome, ready for preview/order calls without extra lookups."
                                              },
                                              "ticker": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "title": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "label": {
                                                "type": "string",
                                                "minLength": 1
                                              },
                                              "yes_bid": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "yes_ask": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "no_bid": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "no_ask": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "spread": {
                                                "type": "string",
                                                "nullable": true
                                              },
                                              "price_change_24h": {
                                                "type": "string",
                                                "nullable": true,
                                                "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                              },
                                              "volume_24h_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$",
                                                "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                              },
                                              "open_interest": {
                                                "type": "integer",
                                                "nullable": true,
                                                "minimum": 0
                                              },
                                              "yes_taker_pct_24h": {
                                                "type": "string",
                                                "nullable": true,
                                                "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                              },
                                              "close_time": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "date-time"
                                              },
                                              "rewards_daily_rate_usd": {
                                                "type": "string",
                                                "nullable": true,
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "lean_url": {
                                                "type": "string",
                                                "format": "uri"
                                              },
                                              "venue_url": {
                                                "type": "string",
                                                "nullable": true,
                                                "format": "uri"
                                              },
                                              "book": {
                                                "type": "object",
                                                "nullable": true,
                                                "properties": {
                                                  "market_id": {
                                                    "type": "string",
                                                    "minLength": 1,
                                                    "description": "The market id from GET /markets, however the request named the market."
                                                  },
                                                  "venues": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "venue": {
                                                          "type": "string",
                                                          "enum": [
                                                            "kalshi",
                                                            "polymarket",
                                                            "polymarket_us",
                                                            "hyperliquid",
                                                            "lighter"
                                                          ]
                                                        },
                                                        "ticker": {
                                                          "type": "string",
                                                          "minLength": 1
                                                        },
                                                        "side": {
                                                          "type": "string",
                                                          "enum": [
                                                            "yes",
                                                            "no"
                                                          ]
                                                        },
                                                        "bids": {
                                                          "type": "array",
                                                          "items": {
                                                            "type": "object",
                                                            "properties": {
                                                              "price": {
                                                                "type": "string"
                                                              },
                                                              "quantity": {
                                                                "type": "string",
                                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                                              }
                                                            },
                                                            "required": [
                                                              "price",
                                                              "quantity"
                                                            ]
                                                          }
                                                        },
                                                        "asks": {
                                                          "type": "array",
                                                          "items": {
                                                            "type": "object",
                                                            "properties": {
                                                              "price": {
                                                                "type": "string"
                                                              },
                                                              "quantity": {
                                                                "type": "string",
                                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                                              }
                                                            },
                                                            "required": [
                                                              "price",
                                                              "quantity"
                                                            ]
                                                          }
                                                        },
                                                        "bid_quantity": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        },
                                                        "ask_quantity": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        },
                                                        "bid_notional_usd": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        },
                                                        "ask_notional_usd": {
                                                          "type": "string",
                                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                                        },
                                                        "lean_url": {
                                                          "type": "string",
                                                          "format": "uri"
                                                        },
                                                        "venue_url": {
                                                          "type": "string",
                                                          "nullable": true,
                                                          "format": "uri"
                                                        }
                                                      },
                                                      "required": [
                                                        "venue",
                                                        "ticker",
                                                        "side",
                                                        "bids",
                                                        "asks",
                                                        "bid_quantity",
                                                        "ask_quantity",
                                                        "bid_notional_usd",
                                                        "ask_notional_usd",
                                                        "lean_url",
                                                        "venue_url"
                                                      ]
                                                    }
                                                  },
                                                  "combined": {
                                                    "type": "object",
                                                    "properties": {
                                                      "bids": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "price": {
                                                              "type": "string"
                                                            },
                                                            "quantity": {
                                                              "type": "string",
                                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                                            },
                                                            "venues": {
                                                              "type": "array",
                                                              "items": {
                                                                "type": "object",
                                                                "properties": {
                                                                  "venue": {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "kalshi",
                                                                      "polymarket",
                                                                      "polymarket_us",
                                                                      "hyperliquid",
                                                                      "lighter"
                                                                    ]
                                                                  },
                                                                  "quantity": {
                                                                    "type": "string",
                                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                                  }
                                                                },
                                                                "required": [
                                                                  "venue",
                                                                  "quantity"
                                                                ]
                                                              }
                                                            }
                                                          },
                                                          "required": [
                                                            "price",
                                                            "quantity",
                                                            "venues"
                                                          ]
                                                        }
                                                      },
                                                      "asks": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "price": {
                                                              "type": "string"
                                                            },
                                                            "quantity": {
                                                              "type": "string",
                                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                                            },
                                                            "venues": {
                                                              "type": "array",
                                                              "items": {
                                                                "type": "object",
                                                                "properties": {
                                                                  "venue": {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "kalshi",
                                                                      "polymarket",
                                                                      "polymarket_us",
                                                                      "hyperliquid",
                                                                      "lighter"
                                                                    ]
                                                                  },
                                                                  "quantity": {
                                                                    "type": "string",
                                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                                  }
                                                                },
                                                                "required": [
                                                                  "venue",
                                                                  "quantity"
                                                                ]
                                                              }
                                                            }
                                                          },
                                                          "required": [
                                                            "price",
                                                            "quantity",
                                                            "venues"
                                                          ]
                                                        }
                                                      }
                                                    },
                                                    "required": [
                                                      "bids",
                                                      "asks"
                                                    ]
                                                  },
                                                  "total_bid_quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "total_ask_quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "total_bid_notional_usd": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "total_ask_notional_usd": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "unavailable": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string",
                                                      "enum": [
                                                        "kalshi",
                                                        "polymarket",
                                                        "polymarket_us",
                                                        "hyperliquid",
                                                        "lighter"
                                                      ]
                                                    }
                                                  },
                                                  "as_of": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                  },
                                                  "no_market_id": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "minLength": 1,
                                                    "description": "Orderable Lean market_id for the opposite NO/DOWN outcome when this book is a YES/UP binary market, enabling direct NO-side previews and orders without extra lookups."
                                                  },
                                                  "title": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "minLength": 1
                                                  },
                                                  "outcome": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "minLength": 1
                                                  },
                                                  "best_bid": {
                                                    "type": "string",
                                                    "nullable": true
                                                  },
                                                  "best_ask": {
                                                    "type": "string",
                                                    "nullable": true
                                                  },
                                                  "mid": {
                                                    "type": "string",
                                                    "nullable": true
                                                  },
                                                  "weighted_mid": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "description": "Top-of-book depth-weighted midpoint (microprice) across venues; null when either side is empty."
                                                  },
                                                  "spread": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                                  },
                                                  "book_source": {
                                                    "type": "string",
                                                    "enum": [
                                                      "live",
                                                      "rest",
                                                      "mixed"
                                                    ],
                                                    "description": "`live`: served from live venue WebSocket feeds. `rest`: fetched via venue REST. `mixed`: combination across venues."
                                                  },
                                                  "resolution": {
                                                    "type": "object",
                                                    "nullable": true,
                                                    "properties": {
                                                      "source": {
                                                        "type": "string",
                                                        "nullable": true,
                                                        "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                      },
                                                      "rules": {
                                                        "type": "string",
                                                        "nullable": true,
                                                        "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                      },
                                                      "end_date": {
                                                        "type": "string",
                                                        "nullable": true,
                                                        "format": "date-time",
                                                        "description": "When the venue market is scheduled to close, if the venue gives one."
                                                      }
                                                    },
                                                    "required": [
                                                      "source",
                                                      "rules",
                                                      "end_date"
                                                    ],
                                                    "description": "Attached when `include_rules: true`: the listing's settlement rules, source, and scheduled end date; null when the book combines several venue listings (pass `venue` to read one listing's terms)."
                                                  },
                                                  "fees": {
                                                    "type": "object",
                                                    "nullable": true,
                                                    "properties": {
                                                      "formula": {
                                                        "type": "string",
                                                        "enum": [
                                                          "price_curve",
                                                          "flat",
                                                          "notional_on_exit"
                                                        ],
                                                        "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                      },
                                                      "taker_rate": {
                                                        "type": "string",
                                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                                        "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                      },
                                                      "maker_rate": {
                                                        "type": "string",
                                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                                        "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                      },
                                                      "exponent": {
                                                        "type": "integer",
                                                        "nullable": true,
                                                        "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                      }
                                                    },
                                                    "required": [
                                                      "formula",
                                                      "taker_rate",
                                                      "maker_rate",
                                                      "exponent"
                                                    ],
                                                    "description": "Attached when `include_rules: true`: the listing's venue fee formula and taker/maker rates; null when the book combines several venue listings (pass `venue` to read one listing's terms), or when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                                  }
                                                },
                                                "required": [
                                                  "market_id",
                                                  "venues",
                                                  "combined",
                                                  "total_bid_quantity",
                                                  "total_ask_quantity",
                                                  "total_bid_notional_usd",
                                                  "total_ask_notional_usd",
                                                  "unavailable",
                                                  "as_of",
                                                  "title",
                                                  "outcome",
                                                  "best_bid",
                                                  "best_ask",
                                                  "mid",
                                                  "weighted_mid",
                                                  "spread",
                                                  "book_source"
                                                ]
                                              },
                                              "resolution": {
                                                "type": "object",
                                                "nullable": true,
                                                "properties": {
                                                  "source": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                                  },
                                                  "rules": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                                  },
                                                  "end_date": {
                                                    "type": "string",
                                                    "nullable": true,
                                                    "format": "date-time",
                                                    "description": "When the venue market is scheduled to close, if the venue gives one."
                                                  }
                                                },
                                                "required": [
                                                  "source",
                                                  "rules",
                                                  "end_date"
                                                ],
                                                "description": "Attached when `include_rules: true`: settlement rules, source, and scheduled end date."
                                              },
                                              "fees": {
                                                "type": "object",
                                                "nullable": true,
                                                "properties": {
                                                  "formula": {
                                                    "type": "string",
                                                    "enum": [
                                                      "price_curve",
                                                      "flat",
                                                      "notional_on_exit"
                                                    ],
                                                    "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                                  },
                                                  "taker_rate": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                                    "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                  },
                                                  "maker_rate": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                                    "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                                  },
                                                  "exponent": {
                                                    "type": "integer",
                                                    "nullable": true,
                                                    "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                                  }
                                                },
                                                "required": [
                                                  "formula",
                                                  "taker_rate",
                                                  "maker_rate",
                                                  "exponent"
                                                ],
                                                "description": "Attached when `include_rules: true`: venue fee formula and taker/maker rates; null when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                              }
                                            },
                                            "required": [
                                              "market_id",
                                              "no_market_id",
                                              "ticker",
                                              "title",
                                              "label",
                                              "yes_bid",
                                              "yes_ask",
                                              "no_bid",
                                              "no_ask",
                                              "spread",
                                              "price_change_24h",
                                              "volume_24h_usd",
                                              "open_interest",
                                              "yes_taker_pct_24h",
                                              "close_time",
                                              "rewards_daily_rate_usd",
                                              "lean_url",
                                              "venue_url",
                                              "book"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "venue",
                                        "event_ticker",
                                        "title",
                                        "categories",
                                        "tags",
                                        "series_ticker",
                                        "is_recurring",
                                        "recurrence",
                                        "frequency",
                                        "close_time",
                                        "created_time",
                                        "volume_24h_usd",
                                        "open_interest",
                                        "rewards_daily_rate_usd",
                                        "market_count",
                                        "lean_url",
                                        "venue_url",
                                        "event_group",
                                        "outcomes"
                                      ]
                                    }
                                  },
                                  "total_events": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "total_markets": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "universe_events": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "description": "Events in the whole discovery catalog; null when the database fallback answered."
                                  },
                                  "universe_markets": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "description": "Markets in the whole discovery catalog; null when the database fallback answered."
                                  },
                                  "related_tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "key": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "markets": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "key",
                                        "markets"
                                      ]
                                    }
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "discovery_index",
                                      "database_fallback"
                                    ]
                                  },
                                  "as_of": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "events",
                                  "total_events",
                                  "total_markets",
                                  "universe_events",
                                  "universe_markets",
                                  "related_tags",
                                  "source",
                                  "as_of",
                                  "id"
                                ]
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "results",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/discover/taxonomy": {
      "get": {
        "operationId": "getDiscoveryTaxonomy",
        "summary": "List live discovery categories, tags, and trending topics",
        "description": "Returns the live category tree, tag counts, trending categories/tags, and open-market universe counts from the Market Discovery engine.",
        "tags": [
          "Markets"
        ],
        "responses": {
          "200": {
            "description": "Live discovery taxonomy, tags, and trending topics",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "categories": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "markets": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "description": "Markets in this category; null when the database fallback answered."
                                  },
                                  "tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "key": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "markets": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "key",
                                        "markets"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "key",
                                  "markets",
                                  "tags"
                                ]
                              }
                            },
                            "trending": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "enum": [
                                      "category",
                                      "tag"
                                    ]
                                  },
                                  "key": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "volume_24h_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Dollars traded in the last 24h. Computed from trades, each fill counts its YES-equivalent price times contracts. A Hyperliquid or Lighter market can instead carry the venue's own reported 24h dollar notional; Hyperliquid's adds its YES- and NO-token notional."
                                  },
                                  "markets": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "move_pct": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "key",
                                  "volume_24h_usd",
                                  "markets",
                                  "move_pct"
                                ]
                              }
                            },
                            "universe_markets": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "description": "Markets in the whole discovery catalog; null when the database fallback answered."
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "categories",
                            "trending",
                            "universe_markets",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}/book": {
      "get": {
        "operationId": "getMarketBook",
        "summary": "Get a market orderbook",
        "description": "Resting bids and asks for the market on each venue, and the same levels merged across venues. Pass `venue` to read one venue only; a venue symbol reads only the listing it names. A venue whose book could not be read is listed in `unavailable`.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only this venue. Defaults to every venue listing it."
            },
            "required": false,
            "description": "Only this venue. Defaults to every venue listing it.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "Price levels returned per side. Depth totals always cover the whole book read."
            },
            "required": false,
            "description": "Price levels returned per side. Depth totals always cover the whole book read.",
            "name": "depth",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Executable levels per venue and combined across venues, with depth totals",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "bids": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "price": {
                                          "type": "string"
                                        },
                                        "quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        }
                                      },
                                      "required": [
                                        "price",
                                        "quantity"
                                      ]
                                    }
                                  },
                                  "asks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "price": {
                                          "type": "string"
                                        },
                                        "quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        }
                                      },
                                      "required": [
                                        "price",
                                        "quantity"
                                      ]
                                    }
                                  },
                                  "bid_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "ask_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "bid_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "ask_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "bids",
                                  "asks",
                                  "bid_quantity",
                                  "ask_quantity",
                                  "bid_notional_usd",
                                  "ask_notional_usd",
                                  "lean_url",
                                  "venue_url"
                                ]
                              }
                            },
                            "combined": {
                              "type": "object",
                              "properties": {
                                "bids": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "price": {
                                        "type": "string"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "venues": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "quantity"
                                          ]
                                        }
                                      }
                                    },
                                    "required": [
                                      "price",
                                      "quantity",
                                      "venues"
                                    ]
                                  }
                                },
                                "asks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "price": {
                                        "type": "string"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "venues": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "quantity"
                                          ]
                                        }
                                      }
                                    },
                                    "required": [
                                      "price",
                                      "quantity",
                                      "venues"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "bids",
                                "asks"
                              ]
                            },
                            "total_bid_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "total_ask_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "total_bid_notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "total_ask_notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "no_market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "description": "Orderable Lean market_id for the opposite NO/DOWN outcome when this book is a YES/UP binary market, enabling direct NO-side previews and orders without extra lookups."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "best_bid": {
                              "type": "string",
                              "nullable": true
                            },
                            "best_ask": {
                              "type": "string",
                              "nullable": true
                            },
                            "mid": {
                              "type": "string",
                              "nullable": true
                            },
                            "weighted_mid": {
                              "type": "string",
                              "nullable": true,
                              "description": "Top-of-book depth-weighted midpoint (microprice) across venues; null when either side is empty."
                            },
                            "spread": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^-?\\d+(?:\\.\\d+)?$"
                            },
                            "book_source": {
                              "type": "string",
                              "enum": [
                                "live",
                                "rest",
                                "mixed"
                              ],
                              "description": "`live`: served from live venue WebSocket feeds. `rest`: fetched via venue REST. `mixed`: combination across venues."
                            },
                            "resolution": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "nullable": true,
                                  "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                },
                                "rules": {
                                  "type": "string",
                                  "nullable": true,
                                  "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                },
                                "end_date": {
                                  "type": "string",
                                  "nullable": true,
                                  "format": "date-time",
                                  "description": "When the venue market is scheduled to close, if the venue gives one."
                                }
                              },
                              "required": [
                                "source",
                                "rules",
                                "end_date"
                              ],
                              "description": "Attached when `include_rules: true`: the listing's settlement rules, source, and scheduled end date; null when the book combines several venue listings (pass `venue` to read one listing's terms)."
                            },
                            "fees": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "formula": {
                                  "type": "string",
                                  "enum": [
                                    "price_curve",
                                    "flat",
                                    "notional_on_exit"
                                  ],
                                  "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                },
                                "taker_rate": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                  "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                },
                                "maker_rate": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                  "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                },
                                "exponent": {
                                  "type": "integer",
                                  "nullable": true,
                                  "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                }
                              },
                              "required": [
                                "formula",
                                "taker_rate",
                                "maker_rate",
                                "exponent"
                              ],
                              "description": "Attached when `include_rules: true`: the listing's venue fee formula and taker/maker rates; null when the book combines several venue listings (pass `venue` to read one listing's terms), or when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                            }
                          },
                          "required": [
                            "market_id",
                            "venues",
                            "combined",
                            "total_bid_quantity",
                            "total_ask_quantity",
                            "total_bid_notional_usd",
                            "total_ask_notional_usd",
                            "unavailable",
                            "as_of",
                            "livemode",
                            "title",
                            "outcome",
                            "best_bid",
                            "best_ask",
                            "mid",
                            "weighted_mid",
                            "spread",
                            "book_source"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "title": "Denver Broncos -3.5",
                    "outcome": "Denver Broncos -3.5",
                    "venues": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "lean_url": "https://lean.xyz/trade?ticker=hl%3A9999",
                        "venue_url": "https://app.hyperliquid.xyz/trade",
                        "bids": [
                          {
                            "price": "0.54",
                            "quantity": "100"
                          }
                        ],
                        "asks": [
                          {
                            "price": "0.56",
                            "quantity": "80"
                          }
                        ],
                        "bid_quantity": "100",
                        "ask_quantity": "80",
                        "bid_notional_usd": "54",
                        "ask_notional_usd": "44.8"
                      },
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "lean_url": "https://lean.xyz/trade?ticker=pm%3A0x2222222222222222222222222222222222222222222222222222222222222222",
                        "venue_url": null,
                        "bids": [
                          {
                            "price": "0.54",
                            "quantity": "50"
                          },
                          {
                            "price": "0.53",
                            "quantity": "200"
                          }
                        ],
                        "asks": [
                          {
                            "price": "0.55",
                            "quantity": "120"
                          }
                        ],
                        "bid_quantity": "250",
                        "ask_quantity": "120",
                        "bid_notional_usd": "133",
                        "ask_notional_usd": "66"
                      }
                    ],
                    "combined": {
                      "bids": [
                        {
                          "price": "0.54",
                          "quantity": "150",
                          "venues": [
                            {
                              "venue": "hyperliquid",
                              "quantity": "100"
                            },
                            {
                              "venue": "polymarket",
                              "quantity": "50"
                            }
                          ]
                        },
                        {
                          "price": "0.53",
                          "quantity": "200",
                          "venues": [
                            {
                              "venue": "polymarket",
                              "quantity": "200"
                            }
                          ]
                        }
                      ],
                      "asks": [
                        {
                          "price": "0.55",
                          "quantity": "120",
                          "venues": [
                            {
                              "venue": "polymarket",
                              "quantity": "120"
                            }
                          ]
                        },
                        {
                          "price": "0.56",
                          "quantity": "80",
                          "venues": [
                            {
                              "venue": "hyperliquid",
                              "quantity": "80"
                            }
                          ]
                        }
                      ]
                    },
                    "best_bid": "0.54",
                    "best_ask": "0.55",
                    "mid": "0.545",
                    "weighted_mid": "0.54555556",
                    "spread": "0.01",
                    "total_bid_quantity": "350",
                    "total_ask_quantity": "200",
                    "total_bid_notional_usd": "187",
                    "total_ask_notional_usd": "110.8",
                    "book_source": "live",
                    "unavailable": [],
                    "as_of": "2026-10-29T18:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market with this id, or none on the requested venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market with this id, or none on the requested venue"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/books": {
      "post": {
        "operationId": "getMarketBooks",
        "summary": "Get live orderbooks in bulk",
        "description": "Read live L2 orderbooks for up to 100 markets in one call, named by `market_ids`, `event_ticker`, or `series_ticker`. Announces live WebSocket interest for every requested ticker across all venues so repeated reads serve live copies from Redis without venue REST rate limits. Returns per-venue and combined L2 depth, weighted midpoint, Lean trade links, and freshness source.",
        "tags": [
          "Markets"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
                    },
                    "minItems": 1,
                    "maxItems": 100,
                    "description": "Up to 100 market ids or venue symbols to fetch live orderbooks for in one call."
                  },
                  "event_ticker": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Fetch live orderbooks for up to 100 open markets in this event ticker."
                  },
                  "series_ticker": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Fetch live orderbooks for up to 100 open markets in this series ticker."
                  },
                  "discover": {
                    "type": "object",
                    "properties": {
                      "venues": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "kalshi",
                            "polymarket",
                            "polymarket_us",
                            "hyperliquid",
                            "lighter"
                          ]
                        },
                        "maxItems": 8,
                        "description": "Restrict discovery to these venues (kalshi, polymarket, polymarket_us, hyperliquid, lighter)."
                      },
                      "categories": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Display category keys or aliases (e.g. \"politics\", \"economics\", \"sports\", \"crypto\", or exact keys from GET /v1/discover/taxonomy)."
                      },
                      "exclude_categories": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Exclude events carrying any of these category keys or aliases (e.g. [\"sports\"] to find non-sports markets)."
                      },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Include events matching any of these tags (ORed with categories)."
                      },
                      "exclude_tags": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Exclude events carrying any of these tags (even when they match a selected category)."
                      },
                      "frequencies": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "fiveMin",
                            "fifteenMin",
                            "hourly",
                            "fourHour",
                            "daily",
                            "weekly",
                            "monthly",
                            "quarterly",
                            "annual"
                          ]
                        },
                        "maxItems": 16,
                        "description": "Only recurring series on these cadences (fiveMin, fifteenMin, hourly, fourHour, daily, weekly, monthly, quarterly, annual)."
                      },
                      "market_types": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "mentions",
                            "priceUpDown",
                            "dailyTemperature"
                          ]
                        },
                        "maxItems": 16,
                        "description": "Only events of these structured types (mentions, priceUpDown, dailyTemperature)."
                      },
                      "rewards": {
                        "type": "string",
                        "enum": [
                          "any",
                          "has",
                          "none"
                        ],
                        "description": "Filter by liquidity rewards: any (default), has, or none."
                      },
                      "search": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200,
                        "description": "Ranked free-text search across titles, outcomes, and tags (all words must match)."
                      },
                      "include_keywords": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 20,
                        "description": "Match events containing any of these substrings."
                      },
                      "exclude_keywords": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 20,
                        "description": "Exclude events containing any of these substrings."
                      },
                      "keyword_scope": {
                        "type": "string",
                        "enum": [
                          "title",
                          "titleAndOutcomes"
                        ],
                        "description": "Where include/exclude keywords match: title or titleAndOutcomes (default)."
                      },
                      "min_bid": {
                        "type": "string",
                        "description": "Minimum live YES bid price in dollars (0 to 1, e.g. \"0.10\" for 10¢)."
                      },
                      "max_bid": {
                        "type": "string",
                        "description": "Maximum live YES bid price in dollars (0 to 1, e.g. \"0.45\" for 45¢)."
                      },
                      "min_ask": {
                        "type": "string",
                        "description": "Minimum live YES ask price in dollars (0 to 1, e.g. \"0.12\" for 12¢)."
                      },
                      "max_ask": {
                        "type": "string",
                        "description": "Maximum live YES ask price in dollars (0 to 1, e.g. \"0.50\" for 50¢)."
                      },
                      "min_spread": {
                        "type": "string",
                        "description": "Minimum live YES bid-ask spread in dollars (e.g. \"0.01\")."
                      },
                      "max_spread": {
                        "type": "string",
                        "description": "Maximum live YES bid-ask spread in dollars (e.g. \"0.03\" for 3¢)."
                      },
                      "min_change_24h": {
                        "type": "string",
                        "description": "Minimum absolute 24h price change in dollars (e.g. \"0.05\" for 5¢ move)."
                      },
                      "max_change_24h": {
                        "type": "string",
                        "description": "Maximum absolute 24h price change in dollars."
                      },
                      "move_direction": {
                        "type": "string",
                        "enum": [
                          "any",
                          "up",
                          "down"
                        ],
                        "description": "Direction of 24h price move: any, up, or down."
                      },
                      "match_any_outcome": {
                        "type": "boolean",
                        "description": "When true (default for /v1), bid/ask/spread/change filters match if ANY outcome in a multi-strike event passes, and matching strikes appear first."
                      },
                      "min_volume_24h": {
                        "type": "string",
                        "pattern": "^\\d+(?:\\.\\d+)?$",
                        "description": "Minimum 24h dollars traded, as `volume_24h_usd` reports it."
                      },
                      "max_volume_24h": {
                        "type": "string",
                        "pattern": "^\\d+(?:\\.\\d+)?$",
                        "description": "Maximum 24h dollars traded, as `volume_24h_usd` reports it."
                      },
                      "min_open_interest": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Minimum open interest in contracts."
                      },
                      "max_open_interest": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Maximum open interest in contracts."
                      },
                      "expires_after": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Only events closing at or after this ISO 8601 time."
                      },
                      "expires_before": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Only events closing before this ISO 8601 time."
                      },
                      "created_after": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Only events created at or after this ISO 8601 time."
                      },
                      "created_before": {
                        "type": "string",
                        "format": "date-time",
                        "description": "Only events created before this ISO 8601 time."
                      },
                      "series_tickers": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Restrict discovery to these exact series tickers (e.g. [\"KXFED\", \"KXHIGHNY\"])."
                      },
                      "event_tickers": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "maxItems": 50,
                        "description": "Restrict discovery to these exact event tickers."
                      },
                      "exclude_event_ids": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 300
                        },
                        "maxItems": 200,
                        "description": "Exclude events with these exact event `id`s (from prior discover_markets results) to paginate across unseen markets without repeats. For a collapsed row, also pass every event_group.members[].id, since another member of the same real-world event can otherwise lead the row on a later page."
                      },
                      "collapse_event_groups": {
                        "type": "boolean",
                        "description": "When true (default), merge cross-venue listings of the same real-world event into one row with event_group.members."
                      },
                      "sort": {
                        "type": "string",
                        "enum": [
                          "volume",
                          "open_interest",
                          "bid",
                          "ask",
                          "spread",
                          "change",
                          "close",
                          "rewards",
                          "yes_taker",
                          "title"
                        ],
                        "description": "Sort order: volume (default), open_interest, bid, ask, spread, change, close, rewards, yes_taker, or title."
                      },
                      "descending": {
                        "type": "boolean",
                        "description": "Sort descending (default true; pass false for tightest spreads or soonest close)."
                      },
                      "outcome_limit": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 50,
                        "description": "Maximum outcomes returned per event (default 5, max 50), applied after book filters."
                      },
                      "start": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000,
                        "description": "Offset into the filtered result list (default 0)."
                      },
                      "limit": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100,
                        "description": "Maximum events returned (default 25, max 100)."
                      }
                    },
                    "additionalProperties": false,
                    "description": "Resolve up to 100 target markets directly from the live Market Discovery engine using any combination of categories, tags, venues, search, bid/ask/spread, volume, or expiry filters."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "Only include this venue."
                  },
                  "depth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 10,
                    "description": "Price levels returned per side. Depth totals always cover the whole book read."
                  },
                  "min_bid": {
                    "type": "string",
                    "description": "Filter returned live books to those with combined best_bid >= this dollar price."
                  },
                  "max_bid": {
                    "type": "string",
                    "description": "Filter returned live books to those with combined best_bid <= this dollar price."
                  },
                  "min_ask": {
                    "type": "string",
                    "description": "Filter returned live books to those with combined best_ask >= this dollar price."
                  },
                  "max_ask": {
                    "type": "string",
                    "description": "Filter returned live books to those with combined best_ask <= this dollar price."
                  },
                  "max_spread": {
                    "type": "string",
                    "description": "Filter returned live books to those with live bid-ask spread <= this dollar amount."
                  },
                  "min_bid_notional_usd": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Filter returned live books to those with at least this USD notional resting on bids."
                  },
                  "min_ask_notional_usd": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Filter returned live books to those with at least this USD notional resting on asks."
                  },
                  "only_with_liquidity": {
                    "type": "boolean",
                    "description": "When true, drop books with neither bids nor asks."
                  },
                  "include_rules": {
                    "type": "boolean",
                    "description": "When true, attach batched settlement rules (`resolution`) and venue `fees` to every returned book in one call. A book combining several venue listings carries null terms; pass `venue` to read one listing's terms."
                  },
                  "sort_by": {
                    "type": "string",
                    "enum": [
                      "input",
                      "spread_asc",
                      "liquidity_desc",
                      "ask_asc",
                      "bid_desc"
                    ],
                    "description": "Order returned books by input (default), spread_asc, liquidity_desc, ask_asc, or bid_desc."
                  }
                },
                "additionalProperties": false
              },
              "example": "Markets, event, or series whose live books to read"
            }
          }
        },
        "responses": {
          "200": {
            "description": "Live L2 orderbooks per market, plus any unresolved market ids",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "books": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "venues": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid",
                                            "lighter"
                                          ]
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "side": {
                                          "type": "string",
                                          "enum": [
                                            "yes",
                                            "no"
                                          ]
                                        },
                                        "bids": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "price": {
                                                "type": "string"
                                              },
                                              "quantity": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              }
                                            },
                                            "required": [
                                              "price",
                                              "quantity"
                                            ]
                                          }
                                        },
                                        "asks": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "price": {
                                                "type": "string"
                                              },
                                              "quantity": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              }
                                            },
                                            "required": [
                                              "price",
                                              "quantity"
                                            ]
                                          }
                                        },
                                        "bid_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "ask_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "bid_notional_usd": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "ask_notional_usd": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "lean_url": {
                                          "type": "string",
                                          "format": "uri"
                                        },
                                        "venue_url": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "uri"
                                        }
                                      },
                                      "required": [
                                        "venue",
                                        "ticker",
                                        "side",
                                        "bids",
                                        "asks",
                                        "bid_quantity",
                                        "ask_quantity",
                                        "bid_notional_usd",
                                        "ask_notional_usd",
                                        "lean_url",
                                        "venue_url"
                                      ]
                                    }
                                  },
                                  "combined": {
                                    "type": "object",
                                    "properties": {
                                      "bids": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "price": {
                                              "type": "string"
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "venues": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "venue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "kalshi",
                                                      "polymarket",
                                                      "polymarket_us",
                                                      "hyperliquid",
                                                      "lighter"
                                                    ]
                                                  },
                                                  "quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  }
                                                },
                                                "required": [
                                                  "venue",
                                                  "quantity"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "price",
                                            "quantity",
                                            "venues"
                                          ]
                                        }
                                      },
                                      "asks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "price": {
                                              "type": "string"
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "venues": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "venue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "kalshi",
                                                      "polymarket",
                                                      "polymarket_us",
                                                      "hyperliquid",
                                                      "lighter"
                                                    ]
                                                  },
                                                  "quantity": {
                                                    "type": "string",
                                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                                  }
                                                },
                                                "required": [
                                                  "venue",
                                                  "quantity"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "price",
                                            "quantity",
                                            "venues"
                                          ]
                                        }
                                      }
                                    },
                                    "required": [
                                      "bids",
                                      "asks"
                                    ]
                                  },
                                  "total_bid_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "total_ask_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "total_bid_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "total_ask_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "unavailable": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "enum": [
                                        "kalshi",
                                        "polymarket",
                                        "polymarket_us",
                                        "hyperliquid",
                                        "lighter"
                                      ]
                                    }
                                  },
                                  "as_of": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "no_market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "Orderable Lean market_id for the opposite NO/DOWN outcome when this book is a YES/UP binary market, enabling direct NO-side previews and orders without extra lookups."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "best_bid": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "best_ask": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "mid": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "weighted_mid": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Top-of-book depth-weighted midpoint (microprice) across venues; null when either side is empty."
                                  },
                                  "spread": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "book_source": {
                                    "type": "string",
                                    "enum": [
                                      "live",
                                      "rest",
                                      "mixed"
                                    ],
                                    "description": "`live`: served from live venue WebSocket feeds. `rest`: fetched via venue REST. `mixed`: combination across venues."
                                  },
                                  "resolution": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "source": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "How the venue's resolution was recorded, such as the oracle event; null until it resolves."
                                      },
                                      "rules": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "The venue's resolution rules verbatim, secondary rules after a blank line."
                                      },
                                      "end_date": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time",
                                        "description": "When the venue market is scheduled to close, if the venue gives one."
                                      }
                                    },
                                    "required": [
                                      "source",
                                      "rules",
                                      "end_date"
                                    ],
                                    "description": "Attached when `include_rules: true`: the listing's settlement rules, source, and scheduled end date; null when the book combines several venue listings (pass `venue` to read one listing's terms)."
                                  },
                                  "fees": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "formula": {
                                        "type": "string",
                                        "enum": [
                                          "price_curve",
                                          "flat",
                                          "notional_on_exit"
                                        ],
                                        "description": "`price_curve`: every fill, buy or sell, pays quantity × rate × (price × (1 − price))^exponent. `notional_on_exit`: a buy pays nothing; a sell pays quantity × price × rate, and each winning share pays rate × $1 at settlement."
                                      },
                                      "taker_rate": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "The rate, as a fraction of 1, a fill that takes liquidity pays. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                      },
                                      "maker_rate": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "The rate, as a fraction of 1, a resting order pays when it fills. For `notional_on_exit` (Hyperliquid) this is the base volume tier's rate, an upper bound: accounts on a discounted tier pay less."
                                      },
                                      "exponent": {
                                        "type": "integer",
                                        "nullable": true,
                                        "description": "The exponent of `price_curve`; null for `notional_on_exit`."
                                      }
                                    },
                                    "required": [
                                      "formula",
                                      "taker_rate",
                                      "maker_rate",
                                      "exponent"
                                    ],
                                    "description": "Attached when `include_rules: true`: the listing's venue fee formula and taker/maker rates; null when the book combines several venue listings (pass `venue` to read one listing's terms), or when the venue's fee terms are not recorded or depend on an account fee multiplier Lean cannot read (Lighter)."
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "venues",
                                  "combined",
                                  "total_bid_quantity",
                                  "total_ask_quantity",
                                  "total_bid_notional_usd",
                                  "total_ask_notional_usd",
                                  "unavailable",
                                  "as_of",
                                  "title",
                                  "outcome",
                                  "best_bid",
                                  "best_ask",
                                  "mid",
                                  "weighted_mid",
                                  "spread",
                                  "book_source"
                                ]
                              }
                            },
                            "matched_count": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "filtered_out_count": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "not_found": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "books",
                            "matched_count",
                            "filtered_out_count",
                            "not_found",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}/trades": {
      "get": {
        "operationId": "getMarketTrades",
        "summary": "Get recent trades",
        "description": "The latest trades on each venue leg of the market, newest first. Pass `venue` to read one venue only; a venue symbol reads only the listing it names. Pass the `next_cursor` of a page as `cursor` to read older trades.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ]
            },
            "required": false,
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "`next_cursor` of the previous page, for older trades."
            },
            "required": false,
            "description": "`next_cursor` of the previous page, for older trades.",
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "The market's most recent venue trades, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "trades": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "trade_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "price": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "taker_side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "executed_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "trade_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "price",
                                  "quantity",
                                  "taker_side",
                                  "executed_at"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_id",
                            "trades",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "trades": [
                      {
                        "trade_id": "18342977",
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "price": "0.55",
                        "quantity": "25",
                        "taker_side": "yes",
                        "executed_at": "2026-10-29T17:59:12.000Z"
                      },
                      {
                        "trade_id": "90517",
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "price": "0.54",
                        "quantity": "40",
                        "taker_side": "no",
                        "executed_at": "2026-10-29T17:58:47.000Z"
                      }
                    ],
                    "next_cursor": "eyJ0c01zIjoxNzkzMjk2NzI3MDAwLCJyZWNlaXZlZEF0TXMiOjE3OTMyOTY3MjcxMTQsInRyYWRlSWQiOiI5MDUxNyJ9",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market with this id, or none on the requested venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market with this id, or none on the requested venue"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/markets/{id}/candles": {
      "get": {
        "operationId": "getMarketCandles",
        "summary": "Get price candles",
        "description": "Open, high, low and close prices and volume per interval for each venue leg of the market, oldest first. Prices are for the side the leg buys. A request covers at most 1000 intervals. Pass `venue` to read one venue only.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
              "example": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
            },
            "required": true,
            "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "1s",
                "1m",
                "3m",
                "5m",
                "15m",
                "1h",
                "2h",
                "4h",
                "1d"
              ],
              "default": "1m",
              "description": "Length of each candle (1s, 1m, 3m, 5m, 15m, 1h, 2h, 4h, 1d)."
            },
            "required": false,
            "description": "Length of each candle (1s, 1m, 3m, 5m, 15m, 1h, 2h, 4h, 1d).",
            "name": "interval",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "First candle at or after this time, rounded down to the interval. Defaults to 100 intervals before `end`."
            },
            "required": false,
            "description": "First candle at or after this time, rounded down to the interval. Defaults to 100 intervals before `end`.",
            "name": "start",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Candles that open before this time. Defaults to now for open markets, or to the market end_date for already-closed/settled markets."
            },
            "required": false,
            "description": "Candles that open before this time. Defaults to now for open markets, or to the market end_date for already-closed/settled markets.",
            "name": "end",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only this venue leg."
            },
            "required": false,
            "description": "Only this venue leg.",
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Candles for each venue leg, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "interval": {
                              "type": "string",
                              "enum": [
                                "1s",
                                "1m",
                                "3m",
                                "5m",
                                "15m",
                                "1h",
                                "2h",
                                "4h",
                                "1d"
                              ]
                            },
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "candles": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "time": {
                                          "type": "string",
                                          "format": "date-time"
                                        },
                                        "open": {
                                          "type": "string"
                                        },
                                        "high": {
                                          "type": "string"
                                        },
                                        "low": {
                                          "type": "string"
                                        },
                                        "close": {
                                          "type": "string"
                                        },
                                        "volume": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        }
                                      },
                                      "required": [
                                        "time",
                                        "open",
                                        "high",
                                        "low",
                                        "close",
                                        "volume"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "candles"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_id",
                            "interval",
                            "start",
                            "end",
                            "legs",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "interval": "5m",
                    "start": "2026-10-29T17:50:00.000Z",
                    "end": "2026-10-29T18:00:00.000Z",
                    "legs": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "candles": [
                          {
                            "time": "2026-10-29T17:50:00.000Z",
                            "open": "0.52",
                            "high": "0.55",
                            "low": "0.51",
                            "close": "0.54",
                            "volume": "120"
                          }
                        ]
                      },
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "candles": [
                          {
                            "time": "2026-10-29T17:50:00.000Z",
                            "open": "0.53",
                            "high": "0.55",
                            "low": "0.52",
                            "close": "0.54",
                            "volume": "310.5"
                          },
                          {
                            "time": "2026-10-29T17:55:00.000Z",
                            "open": "0.54",
                            "high": "0.56",
                            "low": "0.54",
                            "close": "0.55",
                            "volume": "82"
                          }
                        ]
                      }
                    ],
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown interval, start not before end, or more than 1000 intervals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Unknown interval, start not before end, or more than 1000 intervals"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market with this id, or none on the requested venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market with this id, or none on the requested venue"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/candles": {
      "post": {
        "operationId": "getMarketCandlesBatch",
        "summary": "Get price candles in bulk",
        "description": "Open, high, low and close prices and volume per interval for up to 50 markets in one call, oldest first. Accepts Lean market ids and bare venue symbols, and works on both live and past settled markets (automatically anchoring `end` to close time when `end` is omitted on a closed/settled market). Each market spans at most 1000 intervals. Pass `venue` to read one venue only and `limit` to keep only the latest N candles per leg.",
        "tags": [
          "Markets"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512,
                      "description": "A Lean market id or bare venue symbol. A bare symbol matching multiple listings selects its unique YES/UP listing, or returns 400 if there is no unique YES/UP match."
                    },
                    "minItems": 1,
                    "maxItems": 50,
                    "description": "From 1 to 50 Lean market ids or bare venue symbols (Kalshi tickers, pm:/pmus:/hl:/lt:, Polymarket token ids, Hyperliquid #coins). Bare two-outcome symbols default to YES/UP."
                  },
                  "interval": {
                    "type": "string",
                    "enum": [
                      "1s",
                      "1m",
                      "3m",
                      "5m",
                      "15m",
                      "1h",
                      "2h",
                      "4h",
                      "1d"
                    ],
                    "default": "1h",
                    "description": "Length of each candle (1s, 1m, 3m, 5m, 15m, 1h, 2h, 4h, 1d). Defaults to 1h."
                  },
                  "start": {
                    "type": "string",
                    "format": "date-time",
                    "description": "First candle at or after this time, rounded down to the interval. Defaults to 100 intervals before `end` (or `limit` intervals when `limit` is larger)."
                  },
                  "end": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Candles that open before this time. Defaults to now for open markets, or to the market end_date for already-closed/settled markets."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "Only this venue leg."
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000,
                    "description": "Optional cap returning only the latest N candles per leg (1 to 1000), useful for keeping batched responses compact."
                  }
                },
                "required": [
                  "market_ids"
                ],
                "additionalProperties": false
              },
              "example": {
                "market_ids": [
                  "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Candles per resolved market, plus any unresolved market ids",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "candles": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "interval": {
                                    "type": "string",
                                    "enum": [
                                      "1s",
                                      "1m",
                                      "3m",
                                      "5m",
                                      "15m",
                                      "1h",
                                      "2h",
                                      "4h",
                                      "1d"
                                    ]
                                  },
                                  "start": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "end": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "legs": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid",
                                            "lighter"
                                          ]
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "side": {
                                          "type": "string",
                                          "enum": [
                                            "yes",
                                            "no"
                                          ]
                                        },
                                        "candles": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "time": {
                                                "type": "string",
                                                "format": "date-time"
                                              },
                                              "open": {
                                                "type": "string"
                                              },
                                              "high": {
                                                "type": "string"
                                              },
                                              "low": {
                                                "type": "string"
                                              },
                                              "close": {
                                                "type": "string"
                                              },
                                              "volume": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              }
                                            },
                                            "required": [
                                              "time",
                                              "open",
                                              "high",
                                              "low",
                                              "close",
                                              "volume"
                                            ]
                                          }
                                        }
                                      },
                                      "required": [
                                        "venue",
                                        "ticker",
                                        "side",
                                        "candles"
                                      ]
                                    }
                                  },
                                  "requested_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "interval",
                                  "start",
                                  "end",
                                  "legs",
                                  "requested_id",
                                  "title",
                                  "outcome"
                                ]
                              }
                            },
                            "not_found": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "candles",
                            "not_found",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "candles": [
                      {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "requested_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "outcome": "DEN",
                        "interval": "5m",
                        "start": "2026-10-29T17:50:00.000Z",
                        "end": "2026-10-29T18:00:00.000Z",
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "hl:9999",
                            "side": "yes",
                            "candles": [
                              {
                                "time": "2026-10-29T17:50:00.000Z",
                                "open": "0.52",
                                "high": "0.55",
                                "low": "0.51",
                                "close": "0.54",
                                "volume": "120"
                              }
                            ]
                          },
                          {
                            "venue": "polymarket",
                            "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                            "side": "yes",
                            "candles": [
                              {
                                "time": "2026-10-29T17:50:00.000Z",
                                "open": "0.53",
                                "high": "0.55",
                                "low": "0.52",
                                "close": "0.54",
                                "volume": "310.5"
                              },
                              {
                                "time": "2026-10-29T17:55:00.000Z",
                                "open": "0.54",
                                "high": "0.56",
                                "low": "0.54",
                                "close": "0.55",
                                "volume": "82"
                              }
                            ]
                          }
                        ]
                      }
                    ],
                    "not_found": [],
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid market id, unknown interval, start not before end, or more than 1000 intervals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid market id, unknown interval, start not before end, or more than 1000 intervals"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/prices": {
      "get": {
        "operationId": "getPrices",
        "summary": "Get prices",
        "description": "Best bid and ask with the quantity resting at each, mid and last trade for up to 50 markets in one call, across venues and per venue. Ids that match no market are returned in `not_found`.",
        "tags": [
          "Markets"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Markets separated by commas, at most 50: market ids from GET /markets or venue symbols that each name one market, such as Polymarket token ids or Hyperliquid book coins. A venue symbol is priced on the one listing it names, as an order naming it would trade, under its market id with that listing in `venues`. A market id is priced across every listing. Ids naming the same listings are priced once. The request line, query included, must stay within 8 KiB, so split a list of long venue symbols across requests."
            },
            "required": true,
            "description": "Markets separated by commas, at most 50: market ids from GET /markets or venue symbols that each name one market, such as Polymarket token ids or Hyperliquid book coins. A venue symbol is priced on the one listing it names, as an order naming it would trade, under its market id with that listing in `venues`. A market id is priced across every listing. Ids naming the same listings are priced once. The request line, query included, must stay within 8 KiB, so split a list of long venue symbols across requests.",
            "name": "market_ids",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Top of book per market, best across venues and per venue",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "prices": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "best_bid": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "best_bid_quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares resting at `best_bid`, summed over every venue at that price; null when `best_bid` is null."
                                  },
                                  "best_ask": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "best_ask_quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares resting at `best_ask`, summed over every venue at that price; null when `best_ask` is null."
                                  },
                                  "mid": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "weighted_mid": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Top-of-book depth-weighted midpoint (microprice) across venues; null when either side is empty."
                                  },
                                  "spread": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "last_trade_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "last_trade_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "venues": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid",
                                            "lighter"
                                          ]
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "best_bid": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "best_bid_quantity": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^\\d+(?:\\.\\d+)?$",
                                          "description": "Shares resting at `best_bid`, summed over every venue at that price; null when `best_bid` is null."
                                        },
                                        "best_ask": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "best_ask_quantity": {
                                          "type": "string",
                                          "nullable": true,
                                          "pattern": "^\\d+(?:\\.\\d+)?$",
                                          "description": "Shares resting at `best_ask`, summed over every venue at that price; null when `best_ask` is null."
                                        }
                                      },
                                      "required": [
                                        "venue",
                                        "ticker",
                                        "best_bid",
                                        "best_bid_quantity",
                                        "best_ask",
                                        "best_ask_quantity"
                                      ]
                                    }
                                  },
                                  "unavailable": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "enum": [
                                        "kalshi",
                                        "polymarket",
                                        "polymarket_us",
                                        "hyperliquid",
                                        "lighter"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "best_bid",
                                  "best_bid_quantity",
                                  "best_ask",
                                  "best_ask_quantity",
                                  "mid",
                                  "weighted_mid",
                                  "spread",
                                  "last_trade_price",
                                  "last_trade_at",
                                  "venues",
                                  "unavailable"
                                ]
                              }
                            },
                            "not_found": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "prices",
                            "not_found",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "prices": [
                      {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "best_bid": "0.54",
                        "best_bid_quantity": "150",
                        "best_ask": "0.55",
                        "best_ask_quantity": "120",
                        "mid": "0.545",
                        "weighted_mid": "0.54555556",
                        "spread": "0.01",
                        "last_trade_price": "0.55",
                        "last_trade_at": "2026-10-29T17:59:12.000Z",
                        "venues": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "hl:9999",
                            "best_bid": "0.54",
                            "best_bid_quantity": "100",
                            "best_ask": "0.56",
                            "best_ask_quantity": "80"
                          },
                          {
                            "venue": "polymarket",
                            "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                            "best_bid": "0.54",
                            "best_bid_quantity": "50",
                            "best_ask": "0.55",
                            "best_ask_quantity": "120"
                          }
                        ],
                        "unavailable": []
                      }
                    ],
                    "not_found": [],
                    "as_of": "2026-10-29T18:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/weather/{stationCode}": {
      "get": {
        "operationId": "getWeatherStation",
        "summary": "Get weather observations and forecasts",
        "description": "Stored observations from the last 24 hours, forecast models, accuracy and release estimates for a four-character station code. Observations and six_hour_extremes report six_hour_high_c and six_hour_low_c in Celsius. six_hour_extremes and CLI/DSM daily_reports each include up to 60 entries, newest first. Timestamps are Unix seconds. Observation, forecast and daily report temperatures use station.temperature_unit. dew_point_c is Celsius. Public weather data is available to live and test keys. Requires read scope.",
        "tags": [
          "Weather"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "pattern": "^[A-Z0-9]{4}$"
            },
            "required": true,
            "name": "stationCode",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Weather station snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "livemode": {
                              "type": "boolean"
                            },
                            "station": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "timezone": {
                                  "type": "string"
                                },
                                "temperature_unit": {
                                  "type": "string",
                                  "enum": [
                                    "C",
                                    "F"
                                  ]
                                }
                              },
                              "required": [
                                "code",
                                "name",
                                "timezone",
                                "temperature_unit"
                              ]
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "observed_at": {
                                    "type": "number"
                                  },
                                  "temperature": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "dew_point_c": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "humidity": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "wind_speed_knots": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "source": {
                                    "type": "string"
                                  },
                                  "received_at": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "six_hour_high_c": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "six_hour_low_c": {
                                    "type": "number",
                                    "nullable": true
                                  }
                                },
                                "required": [
                                  "id",
                                  "observed_at",
                                  "temperature",
                                  "dew_point_c",
                                  "humidity",
                                  "wind_speed_knots",
                                  "source",
                                  "received_at",
                                  "six_hour_high_c",
                                  "six_hour_low_c"
                                ]
                              }
                            },
                            "six_hour_extremes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "observed_at": {
                                    "type": "number"
                                  },
                                  "received_at": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "six_hour_high_c": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "six_hour_low_c": {
                                    "type": "number",
                                    "nullable": true
                                  }
                                },
                                "required": [
                                  "id",
                                  "observed_at",
                                  "received_at",
                                  "six_hour_high_c",
                                  "six_hour_low_c"
                                ]
                              }
                            },
                            "daily_reports": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "CLI",
                                      "DSM"
                                    ]
                                  },
                                  "observed_at": {
                                    "type": "number"
                                  },
                                  "received_at": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "temperature": {
                                    "type": "number",
                                    "nullable": true
                                  }
                                },
                                "required": [
                                  "id",
                                  "source",
                                  "observed_at",
                                  "received_at",
                                  "temperature"
                                ]
                              }
                            },
                            "accuracy": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "window": {
                                    "type": "string",
                                    "enum": [
                                      "7d",
                                      "30d"
                                    ]
                                  },
                                  "extreme": {
                                    "type": "string",
                                    "enum": [
                                      "high",
                                      "low"
                                    ]
                                  },
                                  "models": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "mae": {
                                          "type": "number",
                                          "minimum": 0
                                        },
                                        "samples": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "mae",
                                        "samples"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "window",
                                  "extreme",
                                  "models"
                                ]
                              }
                            },
                            "models": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "points": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "valid_at": {
                                          "type": "number"
                                        },
                                        "temperature": {
                                          "type": "number",
                                          "nullable": true
                                        }
                                      },
                                      "required": [
                                        "valid_at",
                                        "temperature"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "model",
                                  "points"
                                ]
                              }
                            },
                            "releases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string"
                                  },
                                  "published_at": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "source",
                                  "published_at"
                                ]
                              }
                            },
                            "release_estimates": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string"
                                  },
                                  "expected_at": {
                                    "type": "number"
                                  },
                                  "earliest_at": {
                                    "type": "number"
                                  },
                                  "latest_at": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "source",
                                  "expected_at",
                                  "earliest_at",
                                  "latest_at"
                                ]
                              }
                            }
                          },
                          "required": [
                            "livemode",
                            "station",
                            "observations",
                            "six_hour_extremes",
                            "daily_reports",
                            "accuracy",
                            "models",
                            "releases",
                            "release_estimates"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid station code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid station code"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown weather station",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Unknown weather station"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Weather snapshot is warming up or temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Weather snapshot is warming up or temporarily unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/resolution/markets": {
      "get": {
        "operationId": "listResolutionMarkets",
        "summary": "List recently resolved markets",
        "description": "Kalshi and Polymarket resolutions from the resolution read model, newest first, grouped once per event. market_tickers lists all markets in that event. limit defaults to 100 and is capped at 200. source optionally filters one exact resolution source. Pass both next_cursor fields as before_changed_at and before_id to fetch older events, preserving source. A null next_cursor ends pagination. Public resolution data is available to live and test keys. Requires read scope.",
        "tags": [
          "Resolution"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": false,
            "name": "source",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "required": false,
            "name": "before_changed_at",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 19,
              "pattern": "^\\d+$"
            },
            "required": false,
            "name": "before_id",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Recent event resolutions and pagination cursor",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "livemode": {
                              "type": "boolean"
                            },
                            "markets": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "ticker": {
                                    "type": "string"
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "market_tickers": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "category_keys": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "yes_sub_title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "no_sub_title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "hyperliquid",
                                      "polymarket_us",
                                      "lighter"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "unopened",
                                      "open",
                                      "closed",
                                      "resolving",
                                      "resolved"
                                    ]
                                  },
                                  "result": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "source": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 128
                                  },
                                  "tx_hash": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "block_number": {
                                    "type": "number",
                                    "nullable": true
                                  },
                                  "changed_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "ticker",
                                  "event_ticker",
                                  "market_tickers",
                                  "title",
                                  "tags",
                                  "category_keys",
                                  "yes_sub_title",
                                  "no_sub_title",
                                  "venue",
                                  "status",
                                  "result",
                                  "source",
                                  "tx_hash",
                                  "block_number",
                                  "changed_at"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "before_changed_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "before_id": {
                                  "type": "string",
                                  "maxLength": 19,
                                  "pattern": "^\\d+$"
                                }
                              },
                              "required": [
                                "before_changed_at",
                                "before_id"
                              ]
                            }
                          },
                          "required": [
                            "livemode",
                            "markets",
                            "next_cursor"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or incomplete cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid filters or incomplete cursor"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Resolution read model is temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Resolution read model is temporarily unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/resolution/oracle-events": {
      "get": {
        "operationId": "listResolutionOracleEvents",
        "summary": "List UMA Optimistic Oracle events",
        "description": "Returns UMA Optimistic Oracle requests (request_price), proposals (propose_price), disputes (dispute_price) and settlements (settle), newest first. Filter by kind or ticker. Each page defaults to 50 events and is capped at 100. Pass all four next_cursor fields with the same filters to fetch older events. A null next_cursor ends pagination. Available to live and test keys with read scope.",
        "tags": [
          "Resolution"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "request_price",
                "propose_price",
                "dispute_price",
                "settle"
              ]
            },
            "required": false,
            "name": "kind",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "required": false,
            "name": "ticker",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 19,
              "pattern": "^\\d+$"
            },
            "required": false,
            "name": "before_block_ts",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 19,
              "pattern": "^\\d+$"
            },
            "required": false,
            "name": "before_block_number",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "maxLength": 19,
              "pattern": "^\\d+$"
            },
            "required": false,
            "name": "before_log_index",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": false,
            "name": "before_tx_hash",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Oracle events and pagination cursor",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "livemode": {
                              "type": "boolean"
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "kind": {
                                    "type": "string",
                                    "enum": [
                                      "request_price",
                                      "propose_price",
                                      "dispute_price",
                                      "settle"
                                    ]
                                  },
                                  "oracle_address": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "yes_sub_title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "no_sub_title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "market_status": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "unopened",
                                      "open",
                                      "closed",
                                      "resolving",
                                      "resolved"
                                    ]
                                  },
                                  "market_result": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "identifier": {
                                    "type": "string"
                                  },
                                  "ancillary_hash": {
                                    "type": "string"
                                  },
                                  "ancillary_title": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "request_time": {
                                    "type": "integer"
                                  },
                                  "requester": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "proposer": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "disputer": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "proposed_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "final_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "reward": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "bond": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "payout": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "expiration_timestamp": {
                                    "type": "integer",
                                    "nullable": true
                                  },
                                  "tx_hash": {
                                    "type": "string"
                                  },
                                  "log_index": {
                                    "type": "integer"
                                  },
                                  "block_number": {
                                    "type": "integer"
                                  },
                                  "block_ts": {
                                    "type": "integer"
                                  }
                                },
                                "required": [
                                  "id",
                                  "kind",
                                  "oracle_address",
                                  "ticker",
                                  "event_ticker",
                                  "title",
                                  "yes_sub_title",
                                  "no_sub_title",
                                  "market_status",
                                  "market_result",
                                  "identifier",
                                  "ancillary_hash",
                                  "ancillary_title",
                                  "request_time",
                                  "requester",
                                  "proposer",
                                  "disputer",
                                  "proposed_price",
                                  "final_price",
                                  "reward",
                                  "bond",
                                  "payout",
                                  "expiration_timestamp",
                                  "tx_hash",
                                  "log_index",
                                  "block_number",
                                  "block_ts"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "before_block_ts": {
                                  "type": "string",
                                  "maxLength": 19,
                                  "pattern": "^\\d+$"
                                },
                                "before_block_number": {
                                  "type": "string",
                                  "maxLength": 19,
                                  "pattern": "^\\d+$"
                                },
                                "before_log_index": {
                                  "type": "string",
                                  "maxLength": 19,
                                  "pattern": "^\\d+$"
                                },
                                "before_tx_hash": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "before_block_ts",
                                "before_block_number",
                                "before_log_index",
                                "before_tx_hash"
                              ]
                            }
                          },
                          "required": [
                            "livemode",
                            "events",
                            "next_cursor"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or incomplete cursor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid filters or incomplete cursor"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Resolution read model is temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Resolution read model is temporarily unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/cancel-all": {
      "post": {
        "operationId": "cancelAllOrders",
        "summary": "Cancel every open order",
        "description": "Cancels each open order of this key's trading account in this key's mode, optionally only on one venue or market, the same way canceling each order would. One failed cancel does not stop the rest; each result says what happened. Works while trading is paused. Orders placed in the Lean app, which GET /v1/orders lists with `source` app, are left resting.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "Only this venue. Defaults to every venue."
                  },
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "Only this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "venue": "hyperliquid"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per open order the call reached",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "order_id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "client_order_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "canceled",
                                      "finished",
                                      "failed"
                                    ]
                                  },
                                  "order": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      "client_order_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "description": "The market id from GET /markets, however the request named the market."
                                      },
                                      "title": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "source": {
                                        "type": "string",
                                        "enum": [
                                          "api",
                                          "app"
                                        ]
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "action": {
                                        "type": "string",
                                        "enum": [
                                          "buy",
                                          "sell"
                                        ]
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "market"
                                        ]
                                      },
                                      "time_in_force": {
                                        "type": "string",
                                        "enum": [
                                          "gtc",
                                          "ioc",
                                          "fok",
                                          "gtd"
                                        ]
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "remaining_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "avg_fill_price": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                                      },
                                      "notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_notional_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "open",
                                          "partially_filled",
                                          "filled",
                                          "canceled",
                                          "rejected",
                                          "expired",
                                          "unconfirmed",
                                          "needs_attention",
                                          "cancel_requested"
                                        ]
                                      },
                                      "venue_status": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue_order_id": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "status_reason": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "code": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "message": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "code",
                                          "message"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "filled_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "limit_price": {
                                              "type": "string"
                                            },
                                            "avg_fill_price": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "open",
                                                "partially_filled",
                                                "filled",
                                                "canceled",
                                                "rejected",
                                                "expired",
                                                "unconfirmed",
                                                "needs_attention",
                                                "cancel_requested"
                                              ]
                                            },
                                            "venue_status": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "venue_order_id": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "cancel_requested_at": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            },
                                            "status_reason": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "code": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "message": {
                                                  "type": "string",
                                                  "minLength": 1
                                                }
                                              },
                                              "required": [
                                                "code",
                                                "message"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "quantity",
                                            "filled_quantity",
                                            "limit_price",
                                            "avg_fill_price",
                                            "status",
                                            "venue_status",
                                            "venue_order_id",
                                            "cancel_requested_at",
                                            "status_reason"
                                          ]
                                        }
                                      },
                                      "post_only": {
                                        "type": "boolean"
                                      },
                                      "replaces_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "replaced_by_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "updated_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "livemode": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "client_order_id",
                                      "market_id",
                                      "title",
                                      "outcome",
                                      "source",
                                      "venue",
                                      "ticker",
                                      "side",
                                      "action",
                                      "type",
                                      "time_in_force",
                                      "expires_at",
                                      "quantity",
                                      "filled_quantity",
                                      "remaining_quantity",
                                      "limit_price",
                                      "avg_fill_price",
                                      "notional_usd",
                                      "filled_notional_usd",
                                      "status",
                                      "venue_status",
                                      "venue_order_id",
                                      "status_reason",
                                      "legs",
                                      "post_only",
                                      "replaces_order_id",
                                      "replaced_by_order_id",
                                      "created_at",
                                      "updated_at",
                                      "livemode"
                                    ]
                                  },
                                  "error": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "details": {
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "order_id",
                                  "client_order_id",
                                  "status",
                                  "order",
                                  "error"
                                ]
                              }
                            },
                            "has_more": {
                              "type": "boolean"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "results",
                            "has_more",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "results": [
                      {
                        "order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                        "client_order_id": "bot-0001",
                        "status": "canceled",
                        "order": {
                          "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                          "client_order_id": "bot-0001",
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                          "outcome": "DEN",
                          "source": "api",
                          "venue": null,
                          "ticker": null,
                          "side": null,
                          "action": "buy",
                          "type": "limit",
                          "time_in_force": "gtc",
                          "expires_at": null,
                          "quantity": "10",
                          "filled_quantity": "4",
                          "remaining_quantity": "0",
                          "limit_price": "0.55",
                          "avg_fill_price": "0.55",
                          "notional_usd": "2.2",
                          "filled_notional_usd": "2.2",
                          "status": "canceled",
                          "venue_status": null,
                          "venue_order_id": null,
                          "status_reason": null,
                          "legs": [],
                          "post_only": false,
                          "replaces_order_id": null,
                          "replaced_by_order_id": null,
                          "created_at": "2026-10-29T18:00:00.000Z",
                          "updated_at": "2026-10-29T18:00:00.000Z",
                          "livemode": false
                        },
                        "error": null
                      }
                    ],
                    "has_more": false,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/positions/close": {
      "post": {
        "operationId": "closePositions",
        "summary": "Close positions",
        "description": "Sells each position of this key's trading account in this key's mode, optionally only on one venue or market, through the same checks and limits as POST /v1/orders. Each sell sells only what is held less what open sells already offer, on the venue that holds it, so a close never sells more than the account holds. Each placed sell is read back before the response, so one the venue matched at once reads filled with its filled quantity and average price. Cancel open orders first to close everything. A close answers 200 even when a sell fails: read outcome, which is failed or partial while positions are left unsold, and each failed leg's error.",
        "tags": [
          "Account"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_order_id": {
                    "type": "string",
                    "maxLength": 40,
                    "pattern": "^[A-Za-z0-9_-]{1,40}$",
                    "description": "Unique per API key, up to 40 characters. Each sell gets `<client_order_id>-close-<hash>-<hash>`, returned only in this response; replaying the id returns the sells already placed and places only those that are missing."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "Only this venue. Defaults to every venue."
                  },
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "Only this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
                  },
                  "max_slippage_bps": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000,
                    "description": "Furthest each sell may trade below the best bid as read when it is placed, in basis points."
                  },
                  "limit_price": {
                    "type": "string",
                    "description": "Lowest price per share each sell accepts. Without it the close is a market close: ioc, each venue sell placed 1 cent below the worst price its quantity reaches in that venue's book and never below max_slippage_bps."
                  },
                  "time_in_force": {
                    "type": "string",
                    "enum": [
                      "gtc",
                      "ioc"
                    ],
                    "description": "With limit_price: gtc rests the unfilled part, ioc cancels it. Defaults to gtc with limit_price and ioc without. A Lighter sell is always ioc, since nothing rests past its window end."
                  }
                },
                "required": [
                  "client_order_id",
                  "max_slippage_bps"
                ],
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "flatten-0001",
                "max_slippage_bps": 200
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One leg per position in scope",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "outcome": {
                              "type": "string",
                              "enum": [
                                "placed",
                                "partial",
                                "failed",
                                "nothing_to_close"
                              ],
                              "description": "What the close did overall. placed: every position that needed a sell has one. partial: some do, but a sell failed or a venue could not be read. failed: nothing that needed a sell got one. nothing_to_close: no position in scope needed a sell. A placed sell may still be filling or end unfilled; read each leg."
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "client_order_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "placed",
                                      "replayed",
                                      "failed",
                                      "skipped"
                                    ]
                                  },
                                  "order": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      "client_order_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "description": "The market id from GET /markets, however the request named the market."
                                      },
                                      "title": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "source": {
                                        "type": "string",
                                        "enum": [
                                          "api",
                                          "app"
                                        ]
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "action": {
                                        "type": "string",
                                        "enum": [
                                          "buy",
                                          "sell"
                                        ]
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "market"
                                        ]
                                      },
                                      "time_in_force": {
                                        "type": "string",
                                        "enum": [
                                          "gtc",
                                          "ioc",
                                          "fok",
                                          "gtd"
                                        ]
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "remaining_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "avg_fill_price": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                                      },
                                      "notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_notional_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "open",
                                          "partially_filled",
                                          "filled",
                                          "canceled",
                                          "rejected",
                                          "expired",
                                          "unconfirmed",
                                          "needs_attention",
                                          "cancel_requested"
                                        ]
                                      },
                                      "venue_status": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue_order_id": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "status_reason": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "code": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "message": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "code",
                                          "message"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "filled_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "limit_price": {
                                              "type": "string"
                                            },
                                            "avg_fill_price": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "open",
                                                "partially_filled",
                                                "filled",
                                                "canceled",
                                                "rejected",
                                                "expired",
                                                "unconfirmed",
                                                "needs_attention",
                                                "cancel_requested"
                                              ]
                                            },
                                            "venue_status": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "venue_order_id": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "cancel_requested_at": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            },
                                            "status_reason": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "code": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "message": {
                                                  "type": "string",
                                                  "minLength": 1
                                                }
                                              },
                                              "required": [
                                                "code",
                                                "message"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "quantity",
                                            "filled_quantity",
                                            "limit_price",
                                            "avg_fill_price",
                                            "status",
                                            "venue_status",
                                            "venue_order_id",
                                            "cancel_requested_at",
                                            "status_reason"
                                          ]
                                        }
                                      },
                                      "post_only": {
                                        "type": "boolean"
                                      },
                                      "replaces_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "replaced_by_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "updated_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "livemode": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "client_order_id",
                                      "market_id",
                                      "title",
                                      "outcome",
                                      "source",
                                      "venue",
                                      "ticker",
                                      "side",
                                      "action",
                                      "type",
                                      "time_in_force",
                                      "expires_at",
                                      "quantity",
                                      "filled_quantity",
                                      "remaining_quantity",
                                      "limit_price",
                                      "avg_fill_price",
                                      "notional_usd",
                                      "filled_notional_usd",
                                      "status",
                                      "venue_status",
                                      "venue_order_id",
                                      "status_reason",
                                      "legs",
                                      "post_only",
                                      "replaces_order_id",
                                      "replaced_by_order_id",
                                      "created_at",
                                      "updated_at",
                                      "livemode"
                                    ]
                                  },
                                  "error": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "details": {
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "market_id",
                                  "client_order_id",
                                  "quantity",
                                  "status",
                                  "order",
                                  "error"
                                ]
                              }
                            },
                            "unavailable_venues": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "outcome",
                            "legs",
                            "unavailable_venues",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "outcome": "placed",
                    "legs": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "client_order_id": "flatten-0001-close-9c1e4a7b-3f20d8e6",
                        "quantity": "10",
                        "status": "placed",
                        "order": {
                          "id": "5d9b2f71-0c3e-4a86-b7d4-1e6f8a2c9b05",
                          "client_order_id": "flatten-0001-close-9c1e4a7b-3f20d8e6",
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                          "outcome": "DEN",
                          "source": "api",
                          "venue": null,
                          "ticker": null,
                          "side": null,
                          "action": "sell",
                          "type": "limit",
                          "time_in_force": "ioc",
                          "expires_at": null,
                          "quantity": "10",
                          "filled_quantity": "10",
                          "remaining_quantity": "0",
                          "limit_price": "0.53",
                          "avg_fill_price": "0.54",
                          "notional_usd": "5.4",
                          "filled_notional_usd": "5.4",
                          "status": "filled",
                          "venue_status": null,
                          "venue_order_id": null,
                          "status_reason": null,
                          "legs": [],
                          "post_only": false,
                          "replaces_order_id": null,
                          "replaced_by_order_id": null,
                          "created_at": "2026-10-29T18:00:00.000Z",
                          "updated_at": "2026-10-29T18:00:00.000Z",
                          "livemode": false
                        },
                        "error": null
                      }
                    ],
                    "unavailable_venues": [],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_order_id was already used for a close with different parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "client_order_id was already used for a close with different parameters"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or Lean has halted live trading. details.reason is TRADING_PAUSED or LIVE_TRADING_DISABLED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "Trading is paused for this key or its trading account, or Lean has halted live trading"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/cancel-after": {
      "post": {
        "operationId": "setCancelAfter",
        "summary": "Set a cancel timer",
        "description": "A safety timer: unless this is called again in time, every open order of this key's trading account in this key's mode is canceled once the timeout runs out. Each call restarts the timer; 0 disarms it. The timer fires once and then disarms. It cancels the orders POST /v1/orders/cancel-all would, so orders placed in the Lean app are left resting.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "timeout_seconds": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 86400,
                    "description": "Cancel every open order of the trading account, in this key’s mode, unless this is called again within this many seconds: 0, or from 5 to 86400. 0 disarms the timer."
                  }
                },
                "required": [
                  "timeout_seconds"
                ],
                "additionalProperties": false
              },
              "example": {
                "timeout_seconds": 60
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The timer as armed, or disarmed",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "timeout_seconds": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deadline_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "timeout_seconds",
                            "deadline_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "timeout_seconds": 60,
                    "deadline_at": "2026-10-29T18:01:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/cancel-batch": {
      "post": {
        "operationId": "cancelOrdersBatch",
        "summary": "Cancel several orders",
        "description": "Cancels each named order of this key's trading account in this key's mode, the same way canceling each order would. Name orders by id, by client_order_id or both, up to 50 in one call. One failed cancel does not stop the rest; each result says what happened. An order id that matches no order of the account in this key's mode, or a client_order_id that matches no order this key placed, fails with NOT_FOUND. Works while trading is paused.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "order_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "description": "Orders to cancel by the id Lean gave them. Listing the same id twice returns 400."
                  },
                  "client_order_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9_-]{1,64}$"
                    },
                    "description": "Orders to cancel by the client_order_id they were placed with. Listing the same id twice returns 400."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "order_ids": [
                  "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
                ],
                "client_order_ids": [
                  "bot-0002"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per order named",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uuid"
                                  },
                                  "client_order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "canceled",
                                      "finished",
                                      "failed"
                                    ]
                                  },
                                  "order": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      "client_order_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "description": "The market id from GET /markets, however the request named the market."
                                      },
                                      "title": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "source": {
                                        "type": "string",
                                        "enum": [
                                          "api",
                                          "app"
                                        ]
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "action": {
                                        "type": "string",
                                        "enum": [
                                          "buy",
                                          "sell"
                                        ]
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "market"
                                        ]
                                      },
                                      "time_in_force": {
                                        "type": "string",
                                        "enum": [
                                          "gtc",
                                          "ioc",
                                          "fok",
                                          "gtd"
                                        ]
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "remaining_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "avg_fill_price": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                                      },
                                      "notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_notional_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "open",
                                          "partially_filled",
                                          "filled",
                                          "canceled",
                                          "rejected",
                                          "expired",
                                          "unconfirmed",
                                          "needs_attention",
                                          "cancel_requested"
                                        ]
                                      },
                                      "venue_status": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue_order_id": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "status_reason": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "code": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "message": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "code",
                                          "message"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "filled_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "limit_price": {
                                              "type": "string"
                                            },
                                            "avg_fill_price": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "open",
                                                "partially_filled",
                                                "filled",
                                                "canceled",
                                                "rejected",
                                                "expired",
                                                "unconfirmed",
                                                "needs_attention",
                                                "cancel_requested"
                                              ]
                                            },
                                            "venue_status": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "venue_order_id": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "cancel_requested_at": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            },
                                            "status_reason": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "code": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "message": {
                                                  "type": "string",
                                                  "minLength": 1
                                                }
                                              },
                                              "required": [
                                                "code",
                                                "message"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "quantity",
                                            "filled_quantity",
                                            "limit_price",
                                            "avg_fill_price",
                                            "status",
                                            "venue_status",
                                            "venue_order_id",
                                            "cancel_requested_at",
                                            "status_reason"
                                          ]
                                        }
                                      },
                                      "post_only": {
                                        "type": "boolean"
                                      },
                                      "replaces_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "replaced_by_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "updated_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "livemode": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "client_order_id",
                                      "market_id",
                                      "title",
                                      "outcome",
                                      "source",
                                      "venue",
                                      "ticker",
                                      "side",
                                      "action",
                                      "type",
                                      "time_in_force",
                                      "expires_at",
                                      "quantity",
                                      "filled_quantity",
                                      "remaining_quantity",
                                      "limit_price",
                                      "avg_fill_price",
                                      "notional_usd",
                                      "filled_notional_usd",
                                      "status",
                                      "venue_status",
                                      "venue_order_id",
                                      "status_reason",
                                      "legs",
                                      "post_only",
                                      "replaces_order_id",
                                      "replaced_by_order_id",
                                      "created_at",
                                      "updated_at",
                                      "livemode"
                                    ]
                                  },
                                  "error": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "details": {
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "order_id",
                                  "client_order_id",
                                  "status",
                                  "order",
                                  "error"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "results",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "results": [
                      {
                        "order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                        "client_order_id": "bot-0001",
                        "status": "canceled",
                        "order": {
                          "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                          "client_order_id": "bot-0001",
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                          "outcome": "DEN",
                          "source": "api",
                          "venue": null,
                          "ticker": null,
                          "side": null,
                          "action": "buy",
                          "type": "limit",
                          "time_in_force": "gtc",
                          "expires_at": null,
                          "quantity": "10",
                          "filled_quantity": "4",
                          "remaining_quantity": "0",
                          "limit_price": "0.55",
                          "avg_fill_price": "0.55",
                          "notional_usd": "2.2",
                          "filled_notional_usd": "2.2",
                          "status": "canceled",
                          "venue_status": null,
                          "venue_order_id": null,
                          "status_reason": null,
                          "legs": [],
                          "post_only": false,
                          "replaces_order_id": null,
                          "replaced_by_order_id": null,
                          "created_at": "2026-10-29T18:00:00.000Z",
                          "updated_at": "2026-10-29T18:00:00.000Z",
                          "livemode": false
                        },
                        "error": null
                      },
                      {
                        "order_id": null,
                        "client_order_id": "bot-0002",
                        "status": "failed",
                        "order": null,
                        "error": {
                          "code": "NOT_FOUND",
                          "message": "Order not found"
                        }
                      }
                    ],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "patch": {
        "operationId": "amendOrder",
        "summary": "Amend an order",
        "description": "Changes the limit price, total size, or both of a resting single-venue good til canceled order. Quantity includes prior fills. On live Kalshi and Polymarket US orders, the original API key can reduce size at the same price in place, retaining the Lean order and client IDs. Kalshi keeps queue priority and Polymarket US preserves post_only. Price changes, size increases, cross-key amends, test orders, and orders on other eligible venues use linked cancel-and-replace for the remaining size. Each order keeps its own fills. Lean checks the new terms, available funds or shares, and trading limits before dispatch. A concurrent fill or change in funds may affect replacement after cancellation. If cancellation is pending, send the same amend again once the old order reads canceled. Routed orders and orders split across venues cannot be amended.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit_price": {
                    "type": "string",
                    "description": "The new worst price per share, in dollars. Omit to keep the current one."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "The new total size in shares, counting what already filled. Omit to keep the current one."
                  },
                  "client_order_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "An unused client_order_id for a replacement order. Omit and Lean picks one if needed. An in-place amend keeps its original client_order_id."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "bot-0002",
                "limit_price": "0.52",
                "quantity": "12"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The amended order or its linked replacement",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "route": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "funding_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "execution_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "costs": {
                                  "type": "object",
                                  "properties": {
                                    "rebalance_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "gas_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "activation_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "network_cost_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "rebalance_fee_usd",
                                    "gas_usd",
                                    "activation_fee_usd",
                                    "network_cost_usd"
                                  ]
                                }
                              },
                              "required": [
                                "funding_venue",
                                "execution_venue",
                                "notional_usd",
                                "costs"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode",
                            "route"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "3f6b2d90-7c41-4e8a-b5d2-91a0c4e7f356",
                    "client_order_id": "bot-0002",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                    "outcome": "DEN",
                    "source": "api",
                    "venue": "hyperliquid",
                    "ticker": "hl:9999",
                    "side": "yes",
                    "action": "buy",
                    "type": "limit",
                    "time_in_force": "gtc",
                    "expires_at": null,
                    "quantity": "12",
                    "filled_quantity": "0",
                    "remaining_quantity": "12",
                    "limit_price": "0.52",
                    "avg_fill_price": null,
                    "notional_usd": "6.24",
                    "filled_notional_usd": null,
                    "status": "open",
                    "venue_status": null,
                    "venue_order_id": null,
                    "status_reason": null,
                    "legs": [],
                    "post_only": true,
                    "replaces_order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                    "replaced_by_order_id": null,
                    "created_at": "2026-10-29T18:00:00.000Z",
                    "updated_at": "2026-10-29T18:05:00.000Z",
                    "livemode": false,
                    "route": null
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No API order has this id. When GET /v1/orders listed the id for an order placed in the Lean app, `details.reason` is APP_ORDER_NOT_ADDRESSABLE: amend app orders in the Lean app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No API order has this id"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The order cannot be amended. details.reason is ORDER_NOT_OPEN, ORDER_REPLACED with details.replaced_by_order_id, ORDER_NOT_AMENDABLE, or REPLACEMENT_PENDING with details.order_id when the order’s cancel was requested and nothing was placed in its place yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The order cannot be amended"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "The new terms are refused: a key limit, the account’s cash or shares, or POST_ONLY_WOULD_CROSS for a post only order that would now trade",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getOrder",
        "summary": "Get an order",
        "description": "One API order by id, refreshed from its venues, with its market’s `title` and `outcome` and each leg’s status and the quantity filled so far. A canceled ioc order and its canceled legs carry `status_reason.code` `IOC_REMAINDER_CANCELED`: the venue canceled what did not fill at once, and `filled_quantity` is what filled.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Order refreshed from the venue",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Filled": {
                    "summary": "Refreshed from the venue",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                        "client_order_id": "bot-2026-10-29-0001",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "5",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": "0.47",
                        "notional_usd": "2.5",
                        "filled_notional_usd": "2.35",
                        "status": "filled",
                        "venue_status": "filled",
                        "venue_order_id": "91234567012",
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "5",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.47",
                            "status": "filled",
                            "venue_status": "filled",
                            "venue_order_id": "91234567012",
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Bad id": {
                    "summary": "id is not a UUID",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "id",
                            "message": "Invalid uuid"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No API order has this id. When GET /v1/orders listed the id for an order placed in the Lean app, `details.reason` is APP_ORDER_NOT_ADDRESSABLE: app orders are listed but cannot be read by id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "Order not found",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Order not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  },
                  "App order": {
                    "summary": "An order GET /v1/orders listed with source app",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "This order was placed in the Lean app. App orders are listed by GET /v1/orders but cannot be read by id, amended or canceled through the API; manage it in the Lean app.",
                        "details": {
                          "reason": "APP_ORDER_NOT_ADDRESSABLE"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "A venue could not be read or reached. The stored order is unchanged; read it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Venue unavailable": {
                    "summary": "Read the order again; the stored order is unchanged",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "Hyperliquid upstream request failed"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "post": {
        "operationId": "createOrder",
        "summary": "Place an order",
        "description": "The default way to buy across venues, in one call. Lean places the order on the venues that can fill it. A buy the account cannot pay for on those venues is bought through a route across venues instead when routing is on and the key has the route scope: Lean moves the money from the funding venue and buys on the execution venue, and `route` names both. A live key also needs the account to have enabled trading in the Lean app, because Lean signs the payment with its delegated signer; a test key routes against the simulator and never signs. Without a route, a buy the account cannot pay for is refused. To sign route payments yourself, use POST /v1/routed-orders and POST /v1/routed-orders/{id}/execute instead.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_order_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Unique per API key. Replaying an id returns the original order."
                  },
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead. An order named by a venue symbol trades only that listing, so it is refused when `venues` leaves out the symbol's venue. A buy routed automatically still buys that listing, paid from the other venue. The order is stored under the market id."
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Shares, in 0.01 steps. Send exactly one of quantity or notional. A sell of the whole position, as held or written to two decimals, sells what each venue's increment allows and keeps the rest."
                  },
                  "notional": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d{1,2})?$",
                    "description": "Dollars to spend on an ioc or fok buy, in place of quantity, at most two decimals. The buy walks the books from the best price and never spends more than this before fees; Lean works out the shares. Sells and resting orders are sized with quantity."
                  },
                  "limit_price": {
                    "type": "string",
                    "description": "Worst price per share you accept, in dollars. Required with quantity on a limit order. With notional or on a market order it defaults to 0.99 for a buy and 0.01 for a sell; a market order is then placed 1 cent past the worst price its quantity reaches in the book, tightened by max_slippage_bps when set."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "limit",
                      "market"
                    ],
                    "default": "limit",
                    "description": "limit trades at limit_price or better. market trades at once at the best prices: it needs time_in_force ioc or fok, and each venue order is placed 1 cent past the worst price its quantity reaches in the book of that venue. limit_price and max_slippage_bps are optional extra caps on the worst price it accepts."
                  },
                  "time_in_force": {
                    "type": "string",
                    "enum": [
                      "gtc",
                      "ioc",
                      "fok",
                      "gtd"
                    ],
                    "default": "gtc",
                    "description": "gtc rests until filled or canceled. ioc fills what it can at once and cancels the rest. fok fills the whole order at once or cancels all of it, and is placed whole on one venue: Polymarket, else Kalshi, since Hyperliquid has no fill or kill and Polymarket US can fill one in part. gtd rests like gtc until expires_at, on every venue. Hyperliquid has no order expiry, so there Lean places the order as gtc and cancels what is left at expires_at. Polymarket takes an ioc or fok buy only by dollar amount: one sized with notional can fill there, while one sized with quantity goes only to the other venues, and when Polymarket is the only one it is refused with 400 VALIDATION_ERROR, so send it with notional or as gtc. notional needs ioc or fok. A time window market takes only gtd or ioc, and its orders go to Lighter."
                  },
                  "expires_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "string",
                        "enum": [
                          "game_start"
                        ]
                      }
                    ],
                    "description": "When a gtd order expires, as an ISO 8601 time, or `game_start` to expire it when the event of its market starts. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. `game_start` reads the start Lean holds for the event, and is refused while that start is not known, once the event has started, or on a market Lean has not placed in an event. On a time window market, at least 6 minutes ahead and at or before the window end, and `game_start` is refused. Whatever has not filled by then is canceled, and the order reads expired."
                  },
                  "max_slippage_bps": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000,
                    "description": "Optional extra cap: the furthest each venue order may trade from that venue's own best price, in basis points; overrides the account's max_slippage_bps. Each venue is measured against its own book, not the best price across venues, so venues quoting different prices can each fill. Never looser than limit_price. Without one, a limit order trades to its limit and a market order to 1 cent past the worst price its quantity reaches in the book, as the Lean trading terminal places it."
                  },
                  "all_or_none": {
                    "type": "boolean",
                    "default": false,
                    "description": "Refuse the order unless the books, as read, fill the whole quantity within the slippage bound. Needs time_in_force ioc or fok. Best effort: venue orders are placed separately and books can move between the read and the fill, so a partial fill is still possible."
                  },
                  "post_only": {
                    "type": "boolean",
                    "default": false,
                    "description": "Only rest on the book, never take. Needs time_in_force gtc, cannot take best_price, and is placed on Kalshi, Polymarket US and Hyperliquid. On a time window market it needs gtd instead and rests on Lighter. An order that would trade at once against the books, as read, is refused with reason POST_ONLY_WOULD_CROSS, and the venue rejects one that would trade by the time it arrives."
                  },
                  "venues": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "kalshi",
                        "polymarket",
                        "polymarket_us",
                        "hyperliquid"
                      ]
                    },
                    "minItems": 1,
                    "description": "Only these venues may fill or fund the order, within the account's allowed venues. A single venue sends the order only there, and the order is refused if that venue can't fill it. Omit to use every allowed venue."
                  },
                  "best_price": {
                    "type": "boolean",
                    "default": false,
                    "description": "Buy at the best price across venues: when a route across venues that moves cash from another venue would cost less in all than buying where the account's cash is, the buy goes through that route. Needs the route scope. A test key prices a route at the order's limit, so there it wins only when the direct buy's fees cost more. Sells already sell across every venue that holds shares, so this does not change them."
                  }
                },
                "required": [
                  "client_order_id",
                  "market_id",
                  "action"
                ],
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "bot-0001",
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "action": "buy",
                "type": "limit",
                "quantity": "10",
                "limit_price": "0.55",
                "time_in_force": "gtc",
                "all_or_none": false,
                "post_only": false,
                "best_price": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The order as recorded after every venue answered, or the original on replay. Venue outcomes are statuses, not errors: an ioc reads canceled with status_reason.code IOC_REMAINDER_CANCELED when the venue canceled what did not fill at once, with filled_quantity 0 if nothing matched, a venue rejection reads rejected, and a submit the venue did not confirm reads unconfirmed. Each leg carries its own status and status_reason. A routed buy has no legs and `route` names its funding and execution venues: a live one stays pending while the router moves the payment, and a test one is filled by the simulator",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "route": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "funding_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "execution_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "costs": {
                                  "type": "object",
                                  "properties": {
                                    "rebalance_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "gas_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "activation_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "network_cost_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "rebalance_fee_usd",
                                    "gas_usd",
                                    "activation_fee_usd",
                                    "network_cost_usd"
                                  ]
                                }
                              },
                              "required": [
                                "funding_venue",
                                "execution_venue",
                                "notional_usd",
                                "costs"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode",
                            "route"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Filled": {
                    "summary": "An ioc order that filled",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                        "client_order_id": "bot-2026-10-29-0001",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "5",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": "0.47",
                        "notional_usd": "2.5",
                        "filled_notional_usd": "2.35",
                        "status": "filled",
                        "venue_status": "filled",
                        "venue_order_id": "91234567012",
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "5",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.47",
                            "status": "filled",
                            "venue_status": "filled",
                            "venue_order_id": "91234567012",
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741602600,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Resting": {
                    "summary": "A gtc order on the book",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                        "client_order_id": "bot-2026-10-29-0002",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "gtc",
                        "expires_at": null,
                        "quantity": "10",
                        "filled_quantity": "0",
                        "remaining_quantity": "10",
                        "limit_price": "0.45",
                        "avg_fill_price": null,
                        "notional_usd": "4.5",
                        "filled_notional_usd": "0",
                        "status": "open",
                        "venue_status": "open",
                        "venue_order_id": "91234567388",
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "10",
                            "filled_quantity": "0",
                            "limit_price": "0.45",
                            "avg_fill_price": null,
                            "status": "open",
                            "venue_status": "open",
                            "venue_order_id": "91234567388",
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:04:40.902Z",
                        "updated_at": "2026-10-11T18:04:41.317Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741881330,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Split": {
                    "summary": "A buy split across two venues",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "6b0f3d92-1e7c-4a85-b3d6-9c4a2f01e7b5",
                        "client_order_id": "bot-2026-10-29-0003",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": null,
                        "ticker": null,
                        "side": null,
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "quantity": "40",
                        "filled_quantity": "40",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": "0.48375",
                        "notional_usd": "20",
                        "filled_notional_usd": "19.35",
                        "status": "filled",
                        "venue_status": null,
                        "venue_order_id": null,
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "25",
                            "filled_quantity": "25",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.48",
                            "status": "filled",
                            "venue_status": "filled",
                            "venue_order_id": "91234567455",
                            "cancel_requested_at": null,
                            "status_reason": null
                          },
                          {
                            "venue": "polymarket",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "15",
                            "filled_quantity": "15",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.49",
                            "status": "filled",
                            "venue_status": "filled",
                            "venue_order_id": "0x<venue order id>",
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741603020,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Test order": {
                    "summary": "A test key: filled in full at the limit price, nothing sent to a venue",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "4c8e1f53-0a7d-4b29-96e4-d3b5a2f8c107",
                        "client_order_id": "bot-2026-10-29-0001",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "5",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": "0.50",
                        "notional_usd": "2.5",
                        "filled_notional_usd": "2.5",
                        "status": "filled",
                        "venue_status": null,
                        "venue_order_id": null,
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "5",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.50",
                            "status": "filled",
                            "venue_status": null,
                            "venue_order_id": null,
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.114Z",
                        "livemode": false,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741602130,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Unfilled ioc": {
                    "summary": "An ioc order that matched nothing: canceled, 0 filled",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "5b7d0e2c-3a91-4f68-b4c2-9e1f7a03d856",
                        "client_order_id": "bot-2026-10-29-0005",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "0",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": null,
                        "notional_usd": "2.5",
                        "filled_notional_usd": "0",
                        "status": "canceled",
                        "venue_status": "canceled",
                        "venue_order_id": null,
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "0",
                            "limit_price": "0.50",
                            "avg_fill_price": null,
                            "status": "canceled",
                            "venue_status": "canceled",
                            "venue_order_id": null,
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741602600,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Rejected": {
                    "summary": "The venue refused the order",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "0e4a9c71-d25b-4f3e-8a60-1b7c5d2e9f48",
                        "client_order_id": "bot-2026-10-29-0006",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "gtc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "0",
                        "remaining_quantity": "0",
                        "limit_price": "0.50",
                        "avg_fill_price": null,
                        "notional_usd": "2.5",
                        "filled_notional_usd": "0",
                        "status": "rejected",
                        "venue_status": null,
                        "venue_order_id": null,
                        "status_reason": {
                          "code": "VENUE_REJECTED",
                          "message": "<venue message>"
                        },
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "0",
                            "limit_price": "0.50",
                            "avg_fill_price": null,
                            "status": "rejected",
                            "venue_status": null,
                            "venue_order_id": null,
                            "cancel_requested_at": null,
                            "status_reason": {
                              "code": "VENUE_REJECTED",
                              "message": "<venue message>"
                            }
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741602600,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Unconfirmed": {
                    "summary": "The venue did not confirm the order; read it back, do not resend",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c83f1a6e-7b04-4d92-9e5a-2f6d0b8c4a17",
                        "client_order_id": "bot-2026-10-29-0007",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "gtc",
                        "expires_at": null,
                        "quantity": "5",
                        "filled_quantity": "0",
                        "remaining_quantity": "5",
                        "limit_price": "0.50",
                        "avg_fill_price": null,
                        "notional_usd": "2.5",
                        "filled_notional_usd": "0",
                        "status": "unconfirmed",
                        "venue_status": null,
                        "venue_order_id": null,
                        "status_reason": {
                          "code": "SUBMISSION_UNKNOWN",
                          "message": "The venue did not confirm this order. Read it back by client_order_id; do not resend it."
                        },
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "filled_quantity": "0",
                            "limit_price": "0.50",
                            "avg_fill_price": null,
                            "status": "unconfirmed",
                            "venue_status": null,
                            "venue_order_id": null,
                            "cancel_requested_at": null,
                            "status_reason": {
                              "code": "SUBMISSION_UNKNOWN",
                              "message": "The venue did not confirm this order. Read it back by client_order_id; do not resend it."
                            }
                          }
                        ],
                        "created_at": "2026-10-11T18:00:02.114Z",
                        "updated_at": "2026-10-11T18:00:02.587Z",
                        "livemode": true,
                        "route": null
                      },
                      "meta": {
                        "timestampMs": 1791741602600,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The order terms are invalid or no venue takes them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "market_gtc": {
                    "summary": "A market order that would rest",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "market orders need time_in_force ioc or fok"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "gtd_without_expiry": {
                    "summary": "gtd without expires_at",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "gtd orders need expires_at"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "Bad limit price": {
                    "summary": "limit_price outside (0, 1)",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "limit_price must be strictly between 0 and 1"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or a routed buy found the account has not enabled trading in the Lean app (ACCOUNT_NOT_DELEGATED, with details.order_id); nothing was paid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the trade scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the trade scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "Market not found",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Market not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_order_id was already used with a different request, or the Polymarket wallet changed while the order was being placed (for example its signer delegation was revoked). Nothing was placed in either case; for the wallet, check its signer delegation in Lean, then retry; the same client_order_id can be reused. A routed buy whose payment could not be authorized answers with details.reason (QUOTE_EXPIRED, ROUTE_MOVED, PAYMENT_MISMATCH, AGENT_APPROVAL_REQUIRED) and details.order_id; nothing was paid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "client_order_id_reused": {
                    "summary": "client_order_id reused with a different request",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "client_order_id was already used with a different request",
                        "details": {
                          "order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
                        }
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "polymarket_not_ready": {
                    "summary": "Polymarket wallet not ready for API orders",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "The Polymarket wallet is no longer ready for API orders. Check its signer delegation and try again."
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Refused by a key limit or a check made before any venue was called; nothing was placed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "quantity_and_notional": {
                    "summary": "Both or neither of quantity and notional",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Send exactly one of quantity or notional"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "notional_gtc": {
                    "summary": "notional on a resting order",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "notional needs time_in_force ioc or fok; size a resting order with quantity"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "notional_sell": {
                    "summary": "notional on a sell",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "notional sizes buys only; size a sell with quantity"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "Per-order limit": {
                    "summary": "quantity × limit_price is above the key limit",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Order notional exceeds this key's per-order limit",
                        "details": {
                          "reason": "ORDER_NOTIONAL_LIMIT",
                          "max_order_notional_micros": 5000000
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Insufficient funds": {
                    "summary": "No venue that could place it has the cash",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "The trading account cannot pay for this order on the venues that could place it",
                        "details": {
                          "reason": "INSUFFICIENT_FUNDS"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Below minimum": {
                    "summary": "Too small for every venue that could place it",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Order notional is below the minimum of every venue that could place it",
                        "details": {
                          "reason": "BELOW_VENUE_MINIMUM",
                          "min_order_notional_micros": 1000000
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Order placement is unavailable. UPSTREAM_ERROR without details.order_id means a venue failed or timed out; look the order up by client_order_id before you resend it. FEATURE_DISABLED with details.reason LIVE_TRADING_DISABLED means live keys cannot place orders right now and test keys still can; TRADING_PAUSED with details.scope api_key or trading_account means this key or its account is paused until resumed from the dashboard. UPSTREAM_ERROR with details.order_id means a routed buy could not have its payment signed; nothing was paid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Venue failed": {
                    "summary": "A venue failed before anything was placed",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "Hyperliquid upstream request failed"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Live trading off": {
                    "summary": "A live key on an account where live trading is not enabled yet; test keys still work",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FEATURE_DISABLED",
                        "message": "Live order placement is switched off. Test keys can still place simulated orders.",
                        "details": {
                          "reason": "LIVE_TRADING_DISABLED"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  },
                  "Key paused": {
                    "summary": "This key paused itself with POST /v1/account/pause; resume from the dashboard",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FEATURE_DISABLED",
                        "message": "Order placement is paused for this key: Strategy halted. Reads and cancels still work.",
                        "details": {
                          "reason": "TRADING_PAUSED",
                          "scope": "api_key"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4b8e1f27-9c3d-4a62-8e05-d7f9a1c3b640"
                      }
                    }
                  },
                  "Venue unavailable": {
                    "summary": "Retry later with the same client_order_id",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "Hyperliquid upstream request failed"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "9d2f6b18-3e7a-4c05-b8d1-4f0a7e2c6b93"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listOrders",
        "summary": "List orders",
        "description": "Orders on this key’s trading account, newest first: every order placed through the API, and, for a live key, each order placed in the Lean app that is still open on its venue. `source` says which; an app order has `client_order_id` `null`, an empty `legs` list, and `market_id`, `title` and `outcome` `null` when no market is listed for it. Each order names its `market_id`, `title` and `outcome`; the title and outcome are null for a market whose fixture started more than 7 days ago. App orders are read from the venues on each call, so a venue that could not be read is listed in `unavailable` and its app orders are left out. They cannot be read by id, amended or canceled through the API; manage them in the Lean app. Orders a limit chase, stop loss or conditional sell placed are not listed; read those through their own routes. Filter by status, venue, market, text in the market title or `client_order_id` (which matches API orders only), and pass `next_cursor` back as `cursor` for the next page.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query",
            "example": 50
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,64}$",
              "description": "Only orders placed with this client_order_id by any key on this trading account. It is unique per key, so orders from different keys can share one.",
              "example": "bot-0001"
            },
            "required": false,
            "description": "Only orders placed with this client_order_id by any key on this trading account. It is unique per key, so orders from different keys can share one.",
            "name": "client_order_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "open",
                "partially_filled",
                "filled",
                "canceled",
                "rejected",
                "expired",
                "unconfirmed",
                "needs_attention",
                "cancel_requested"
              ],
              "description": "Only orders in this one status. `open` leaves out `pending`, `partially_filled` and `cancel_requested` orders, so ask for each to list every working order."
            },
            "required": false,
            "description": "Only orders in this one status. `open` leaves out `pending`, `partially_filled` and `cancel_requested` orders, so ask for each to list every working order.",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only orders on this venue: a venue order there, or a routed order not yet placed that trades there."
            },
            "required": false,
            "description": "Only orders on this venue: a venue order there, or a routed order not yet placed that trades there.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Only orders on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
            },
            "required": false,
            "description": "Only orders on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "market_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Text, in any letter case, found in the title or outcome of the market the order trades."
            },
            "required": false,
            "description": "Text, in any letter case, found in the title or outcome of the market the order trades.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only orders placed at or after this time."
            },
            "required": false,
            "description": "Only orders placed at or after this time.",
            "name": "created_after",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only orders placed before this time."
            },
            "required": false,
            "description": "Only orders placed before this time.",
            "name": "created_before",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "API orders and open app orders on this key's trading account, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "orders": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "client_order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "api",
                                      "app"
                                    ]
                                  },
                                  "venue": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "action": {
                                    "type": "string",
                                    "enum": [
                                      "buy",
                                      "sell"
                                    ]
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "limit",
                                      "market"
                                    ]
                                  },
                                  "time_in_force": {
                                    "type": "string",
                                    "enum": [
                                      "gtc",
                                      "ioc",
                                      "fok",
                                      "gtd"
                                    ]
                                  },
                                  "expires_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "remaining_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                                  },
                                  "notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_notional_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  },
                                  "legs": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid",
                                            "lighter"
                                          ]
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "side": {
                                          "type": "string",
                                          "enum": [
                                            "yes",
                                            "no"
                                          ]
                                        },
                                        "quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "filled_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "limit_price": {
                                          "type": "string"
                                        },
                                        "avg_fill_price": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "open",
                                            "partially_filled",
                                            "filled",
                                            "canceled",
                                            "rejected",
                                            "expired",
                                            "unconfirmed",
                                            "needs_attention",
                                            "cancel_requested"
                                          ]
                                        },
                                        "venue_status": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "venue_order_id": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "cancel_requested_at": {
                                          "type": "string",
                                          "nullable": true,
                                          "format": "date-time"
                                        },
                                        "status_reason": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "code": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "message": {
                                              "type": "string",
                                              "minLength": 1
                                            }
                                          },
                                          "required": [
                                            "code",
                                            "message"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "venue",
                                        "ticker",
                                        "side",
                                        "quantity",
                                        "filled_quantity",
                                        "limit_price",
                                        "avg_fill_price",
                                        "status",
                                        "venue_status",
                                        "venue_order_id",
                                        "cancel_requested_at",
                                        "status_reason"
                                      ]
                                    }
                                  },
                                  "post_only": {
                                    "type": "boolean"
                                  },
                                  "replaces_order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uuid"
                                  },
                                  "replaced_by_order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uuid"
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "client_order_id",
                                  "market_id",
                                  "title",
                                  "outcome",
                                  "source",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "action",
                                  "type",
                                  "time_in_force",
                                  "expires_at",
                                  "quantity",
                                  "filled_quantity",
                                  "remaining_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "notional_usd",
                                  "filled_notional_usd",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "status_reason",
                                  "legs",
                                  "post_only",
                                  "replaces_order_id",
                                  "replaced_by_order_id",
                                  "created_at",
                                  "updated_at",
                                  "livemode"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "orders",
                            "next_cursor",
                            "unavailable",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Orders": {
                    "summary": "Newest first",
                    "value": {
                      "success": true,
                      "data": {
                        "orders": [
                          {
                            "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                            "client_order_id": "bot-2026-10-29-0002",
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "source": "api",
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "action": "buy",
                            "type": "limit",
                            "time_in_force": "gtc",
                            "expires_at": null,
                            "quantity": "10",
                            "filled_quantity": "0",
                            "remaining_quantity": "10",
                            "limit_price": "0.45",
                            "avg_fill_price": null,
                            "notional_usd": "4.5",
                            "filled_notional_usd": "0",
                            "status": "open",
                            "venue_status": "open",
                            "venue_order_id": "91234567388",
                            "status_reason": null,
                            "post_only": false,
                            "replaces_order_id": null,
                            "replaced_by_order_id": null,
                            "legs": [
                              {
                                "venue": "hyperliquid",
                                "ticker": "<venue ticker>",
                                "side": "yes",
                                "quantity": "10",
                                "filled_quantity": "0",
                                "limit_price": "0.45",
                                "avg_fill_price": null,
                                "status": "open",
                                "venue_status": "open",
                                "venue_order_id": "91234567388",
                                "cancel_requested_at": null,
                                "status_reason": null
                              }
                            ],
                            "created_at": "2026-10-11T18:04:40.902Z",
                            "updated_at": "2026-10-11T18:04:41.317Z",
                            "livemode": true
                          },
                          {
                            "id": "3f6c2a9e-71d4-5b08-9e3a-c45d0b7f1e26",
                            "client_order_id": null,
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "source": "app",
                            "venue": "polymarket",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "action": "buy",
                            "type": "limit",
                            "time_in_force": "gtc",
                            "expires_at": null,
                            "quantity": "20",
                            "filled_quantity": "0",
                            "limit_price": "0.42",
                            "avg_fill_price": null,
                            "notional_usd": "8.4",
                            "filled_notional_usd": "0",
                            "status": "open",
                            "venue_status": null,
                            "venue_order_id": "<venue order id>",
                            "status_reason": null,
                            "post_only": false,
                            "replaces_order_id": null,
                            "replaced_by_order_id": null,
                            "legs": [],
                            "created_at": "2026-10-11T18:02:15.000Z",
                            "updated_at": "2026-10-11T18:02:15.000Z",
                            "livemode": true
                          },
                          {
                            "id": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                            "client_order_id": "bot-2026-10-29-0001",
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "source": "api",
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "action": "buy",
                            "type": "limit",
                            "time_in_force": "ioc",
                            "expires_at": null,
                            "quantity": "5",
                            "filled_quantity": "5",
                            "remaining_quantity": "0",
                            "limit_price": "0.50",
                            "avg_fill_price": "0.47",
                            "notional_usd": "2.5",
                            "filled_notional_usd": "2.35",
                            "status": "filled",
                            "venue_status": "filled",
                            "venue_order_id": "91234567012",
                            "status_reason": null,
                            "post_only": false,
                            "replaces_order_id": null,
                            "replaced_by_order_id": null,
                            "legs": [
                              {
                                "venue": "hyperliquid",
                                "ticker": "<venue ticker>",
                                "side": "yes",
                                "quantity": "5",
                                "filled_quantity": "5",
                                "limit_price": "0.50",
                                "avg_fill_price": "0.47",
                                "status": "filled",
                                "venue_status": "filled",
                                "venue_order_id": "91234567012",
                                "cancel_requested_at": null,
                                "status_reason": null
                              }
                            ],
                            "created_at": "2026-10-11T18:00:02.114Z",
                            "updated_at": "2026-10-11T18:00:02.587Z",
                            "livemode": true
                          }
                        ],
                        "next_cursor": null,
                        "unavailable": [],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  },
                  "Venue not read": {
                    "summary": "Polymarket did not answer in time, so its app orders are missing",
                    "value": {
                      "success": true,
                      "data": {
                        "orders": [],
                        "next_cursor": null,
                        "unavailable": [
                          "polymarket"
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  },
                  "Not recorded": {
                    "summary": "No order with this client_order_id",
                    "value": {
                      "success": true,
                      "data": {
                        "orders": [],
                        "next_cursor": null,
                        "unavailable": [],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Bad cursor": {
                    "summary": "cursor is not a next_cursor value",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "cursor",
                            "message": "Invalid cursor"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "7a4c0e5d-1b9f-4e26-8d73-c5f2a1b08e64"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/batch": {
      "post": {
        "operationId": "createOrdersBatch",
        "summary": "Place several orders in one batch",
        "description": "Place up to 25 orders in one call (e.g. a multi-leg basket, cross-venue pair, or ladder of bids). Orders execute in order through the same risk, limit, balance, and idempotency checks as POST /v1/orders. One refused order does not stop the rest; each item carries its own status, order, or error. No venue request is sent, no Polymarket order is booked for sending, and no routed payment is committed more than 1000 ms after the batch arrives; the clock is checked immediately before each send. So the response always carries every placed order's result. An order stopped at that cutoff answers 503 UPSTREAM_ERROR and reached no venue: without details.order_id nothing was booked, and resending it with the same client_order_id places it; with details.order_id it was booked and is canceled with nothing filled, so resend it under a new client_order_id. A client_order_id that already placed an order is always answered with that order (or a conflict), so resending the batch with the same client_order_id values replays the placed orders and continues with the rest. Preview with POST /v1/orders/preview-batch first.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orders": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "client_order_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,64}$",
                          "description": "Unique per API key. Replaying an id returns the original order."
                        },
                        "market_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead. An order named by a venue symbol trades only that listing, so it is refused when `venues` leaves out the symbol's venue. A buy routed automatically still buys that listing, paid from the other venue. The order is stored under the market id."
                        },
                        "action": {
                          "type": "string",
                          "enum": [
                            "buy",
                            "sell"
                          ]
                        },
                        "quantity": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "Shares, in 0.01 steps. Send exactly one of quantity or notional. A sell of the whole position, as held or written to two decimals, sells what each venue's increment allows and keeps the rest."
                        },
                        "notional": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d{1,2})?$",
                          "description": "Dollars to spend on an ioc or fok buy, in place of quantity, at most two decimals. The buy walks the books from the best price and never spends more than this before fees; Lean works out the shares. Sells and resting orders are sized with quantity."
                        },
                        "limit_price": {
                          "type": "string",
                          "description": "Worst price per share you accept, in dollars. Required with quantity on a limit order. With notional or on a market order it defaults to 0.99 for a buy and 0.01 for a sell; a market order is then placed 1 cent past the worst price its quantity reaches in the book, tightened by max_slippage_bps when set."
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "limit",
                            "market"
                          ],
                          "default": "limit",
                          "description": "limit trades at limit_price or better. market trades at once at the best prices: it needs time_in_force ioc or fok, and each venue order is placed 1 cent past the worst price its quantity reaches in the book of that venue. limit_price and max_slippage_bps are optional extra caps on the worst price it accepts."
                        },
                        "time_in_force": {
                          "type": "string",
                          "enum": [
                            "gtc",
                            "ioc",
                            "fok",
                            "gtd"
                          ],
                          "default": "gtc",
                          "description": "gtc rests until filled or canceled. ioc fills what it can at once and cancels the rest. fok fills the whole order at once or cancels all of it, and is placed whole on one venue: Polymarket, else Kalshi, since Hyperliquid has no fill or kill and Polymarket US can fill one in part. gtd rests like gtc until expires_at, on every venue. Hyperliquid has no order expiry, so there Lean places the order as gtc and cancels what is left at expires_at. Polymarket takes an ioc or fok buy only by dollar amount: one sized with notional can fill there, while one sized with quantity goes only to the other venues, and when Polymarket is the only one it is refused with 400 VALIDATION_ERROR, so send it with notional or as gtc. notional needs ioc or fok. A time window market takes only gtd or ioc, and its orders go to Lighter."
                        },
                        "expires_at": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "string",
                              "enum": [
                                "game_start"
                              ]
                            }
                          ],
                          "description": "When a gtd order expires, as an ISO 8601 time, or `game_start` to expire it when the event of its market starts. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. `game_start` reads the start Lean holds for the event, and is refused while that start is not known, once the event has started, or on a market Lean has not placed in an event. On a time window market, at least 6 minutes ahead and at or before the window end, and `game_start` is refused. Whatever has not filled by then is canceled, and the order reads expired."
                        },
                        "max_slippage_bps": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 10000,
                          "description": "Optional extra cap: the furthest each venue order may trade from that venue's own best price, in basis points; overrides the account's max_slippage_bps. Each venue is measured against its own book, not the best price across venues, so venues quoting different prices can each fill. Never looser than limit_price. Without one, a limit order trades to its limit and a market order to 1 cent past the worst price its quantity reaches in the book, as the Lean trading terminal places it."
                        },
                        "all_or_none": {
                          "type": "boolean",
                          "default": false,
                          "description": "Refuse the order unless the books, as read, fill the whole quantity within the slippage bound. Needs time_in_force ioc or fok. Best effort: venue orders are placed separately and books can move between the read and the fill, so a partial fill is still possible."
                        },
                        "post_only": {
                          "type": "boolean",
                          "default": false,
                          "description": "Only rest on the book, never take. Needs time_in_force gtc, cannot take best_price, and is placed on Kalshi, Polymarket US and Hyperliquid. On a time window market it needs gtd instead and rests on Lighter. An order that would trade at once against the books, as read, is refused with reason POST_ONLY_WOULD_CROSS, and the venue rejects one that would trade by the time it arrives."
                        },
                        "venues": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "kalshi",
                              "polymarket",
                              "polymarket_us",
                              "hyperliquid"
                            ]
                          },
                          "minItems": 1,
                          "description": "Only these venues may fill or fund the order, within the account's allowed venues. A single venue sends the order only there, and the order is refused if that venue can't fill it. Omit to use every allowed venue."
                        },
                        "best_price": {
                          "type": "boolean",
                          "default": false,
                          "description": "Buy at the best price across venues: when a route across venues that moves cash from another venue would cost less in all than buying where the account's cash is, the buy goes through that route. Needs the route scope. A test key prices a route at the order's limit, so there it wins only when the direct buy's fees cost more. Sells already sell across every venue that holds shares, so this does not change them."
                        }
                      },
                      "required": [
                        "client_order_id",
                        "market_id",
                        "action"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 25,
                    "description": "Between 1 and 25 order bodies, each placed as POST /v1/orders places it, in order. Each order needs its own client_order_id."
                  }
                },
                "required": [
                  "orders"
                ],
                "additionalProperties": false
              },
              "example": "Between 1 and 25 order requests to place"
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per order, in input order",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "integer",
                                    "description": "HTTP status POST /v1/orders answers this order with (200/201 with order, else error)."
                                  },
                                  "order": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "format": "uuid"
                                      },
                                      "client_order_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "description": "The market id from GET /markets, however the request named the market."
                                      },
                                      "title": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "outcome": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "source": {
                                        "type": "string",
                                        "enum": [
                                          "api",
                                          "app"
                                        ]
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "action": {
                                        "type": "string",
                                        "enum": [
                                          "buy",
                                          "sell"
                                        ]
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "market"
                                        ]
                                      },
                                      "time_in_force": {
                                        "type": "string",
                                        "enum": [
                                          "gtc",
                                          "ioc",
                                          "fok",
                                          "gtd"
                                        ]
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "remaining_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "avg_fill_price": {
                                        "type": "string",
                                        "nullable": true,
                                        "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                                      },
                                      "notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "filled_notional_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "open",
                                          "partially_filled",
                                          "filled",
                                          "canceled",
                                          "rejected",
                                          "expired",
                                          "unconfirmed",
                                          "needs_attention",
                                          "cancel_requested"
                                        ]
                                      },
                                      "venue_status": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue_order_id": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "status_reason": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "code": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "message": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "code",
                                          "message"
                                        ]
                                      },
                                      "legs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "venue": {
                                              "type": "string",
                                              "enum": [
                                                "kalshi",
                                                "polymarket",
                                                "polymarket_us",
                                                "hyperliquid",
                                                "lighter"
                                              ]
                                            },
                                            "ticker": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "side": {
                                              "type": "string",
                                              "enum": [
                                                "yes",
                                                "no"
                                              ]
                                            },
                                            "quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "filled_quantity": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "limit_price": {
                                              "type": "string"
                                            },
                                            "avg_fill_price": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "open",
                                                "partially_filled",
                                                "filled",
                                                "canceled",
                                                "rejected",
                                                "expired",
                                                "unconfirmed",
                                                "needs_attention",
                                                "cancel_requested"
                                              ]
                                            },
                                            "venue_status": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "venue_order_id": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "cancel_requested_at": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            },
                                            "status_reason": {
                                              "type": "object",
                                              "nullable": true,
                                              "properties": {
                                                "code": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "message": {
                                                  "type": "string",
                                                  "minLength": 1
                                                }
                                              },
                                              "required": [
                                                "code",
                                                "message"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "venue",
                                            "ticker",
                                            "side",
                                            "quantity",
                                            "filled_quantity",
                                            "limit_price",
                                            "avg_fill_price",
                                            "status",
                                            "venue_status",
                                            "venue_order_id",
                                            "cancel_requested_at",
                                            "status_reason"
                                          ]
                                        }
                                      },
                                      "post_only": {
                                        "type": "boolean"
                                      },
                                      "replaces_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "replaced_by_order_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uuid"
                                      },
                                      "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "updated_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "livemode": {
                                        "type": "boolean"
                                      },
                                      "route": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "funding_venue": {
                                            "type": "string",
                                            "enum": [
                                              "polymarket",
                                              "hyperliquid"
                                            ]
                                          },
                                          "execution_venue": {
                                            "type": "string",
                                            "enum": [
                                              "polymarket",
                                              "hyperliquid"
                                            ]
                                          },
                                          "notional_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "costs": {
                                            "type": "object",
                                            "properties": {
                                              "rebalance_fee_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "gas_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "activation_fee_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "network_cost_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              }
                                            },
                                            "required": [
                                              "rebalance_fee_usd",
                                              "gas_usd",
                                              "activation_fee_usd",
                                              "network_cost_usd"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "funding_venue",
                                          "execution_venue",
                                          "notional_usd",
                                          "costs"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "client_order_id",
                                      "market_id",
                                      "title",
                                      "outcome",
                                      "source",
                                      "venue",
                                      "ticker",
                                      "side",
                                      "action",
                                      "type",
                                      "time_in_force",
                                      "expires_at",
                                      "quantity",
                                      "filled_quantity",
                                      "remaining_quantity",
                                      "limit_price",
                                      "avg_fill_price",
                                      "notional_usd",
                                      "filled_notional_usd",
                                      "status",
                                      "venue_status",
                                      "venue_order_id",
                                      "status_reason",
                                      "legs",
                                      "post_only",
                                      "replaces_order_id",
                                      "replaced_by_order_id",
                                      "created_at",
                                      "updated_at",
                                      "livemode",
                                      "route"
                                    ],
                                    "description": "The placed or replayed order; null when placement was refused or failed."
                                  },
                                  "error": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "enum": [
                                          "VALIDATION_ERROR",
                                          "NOT_FOUND",
                                          "UNAUTHORIZED",
                                          "FORBIDDEN",
                                          "CONFLICT",
                                          "UPSTREAM_ERROR",
                                          "RATE_LIMITED",
                                          "INTERNAL_ERROR",
                                          "FEATURE_DISABLED",
                                          "CONDITIONAL_SELL_REJECTED",
                                          "CONDITIONAL_SELL_ACTIVE"
                                        ]
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "details": {
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ],
                                    "description": "The error returned when this order was not placed."
                                  }
                                },
                                "required": [
                                  "status",
                                  "order",
                                  "error"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "results",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The body is not a list of 1 to 25 valid order bodies; nothing was placed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The body is not a list of 1 to 25 valid order bodies"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/preview": {
      "post": {
        "operationId": "previewOrder",
        "summary": "Preview an order",
        "description": "Runs the same checks as POST /v1/orders on the same body and returns what it would do: the venue legs, the expected average price, the route a buy would take and whether the order would be refused before reaching a venue. Nothing is placed or reserved.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_order_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Unique per API key. Replaying an id returns the original order."
                  },
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead. An order named by a venue symbol trades only that listing, so it is refused when `venues` leaves out the symbol's venue. A buy routed automatically still buys that listing, paid from the other venue. The order is stored under the market id."
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ]
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Shares, in 0.01 steps. Send exactly one of quantity or notional. A sell of the whole position, as held or written to two decimals, sells what each venue's increment allows and keeps the rest."
                  },
                  "notional": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d{1,2})?$",
                    "description": "Dollars to spend on an ioc or fok buy, in place of quantity, at most two decimals. The buy walks the books from the best price and never spends more than this before fees; Lean works out the shares. Sells and resting orders are sized with quantity."
                  },
                  "limit_price": {
                    "type": "string",
                    "description": "Worst price per share you accept, in dollars. Required with quantity on a limit order. With notional or on a market order it defaults to 0.99 for a buy and 0.01 for a sell; a market order is then placed 1 cent past the worst price its quantity reaches in the book, tightened by max_slippage_bps when set."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "limit",
                      "market"
                    ],
                    "default": "limit",
                    "description": "limit trades at limit_price or better. market trades at once at the best prices: it needs time_in_force ioc or fok, and each venue order is placed 1 cent past the worst price its quantity reaches in the book of that venue. limit_price and max_slippage_bps are optional extra caps on the worst price it accepts."
                  },
                  "time_in_force": {
                    "type": "string",
                    "enum": [
                      "gtc",
                      "ioc",
                      "fok",
                      "gtd"
                    ],
                    "default": "gtc",
                    "description": "gtc rests until filled or canceled. ioc fills what it can at once and cancels the rest. fok fills the whole order at once or cancels all of it, and is placed whole on one venue: Polymarket, else Kalshi, since Hyperliquid has no fill or kill and Polymarket US can fill one in part. gtd rests like gtc until expires_at, on every venue. Hyperliquid has no order expiry, so there Lean places the order as gtc and cancels what is left at expires_at. Polymarket takes an ioc or fok buy only by dollar amount: one sized with notional can fill there, while one sized with quantity goes only to the other venues, and when Polymarket is the only one it is refused with 400 VALIDATION_ERROR, so send it with notional or as gtc. notional needs ioc or fok. A time window market takes only gtd or ioc, and its orders go to Lighter."
                  },
                  "expires_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "string",
                        "enum": [
                          "game_start"
                        ]
                      }
                    ],
                    "description": "When a gtd order expires, as an ISO 8601 time, or `game_start` to expire it when the event of its market starts. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. `game_start` reads the start Lean holds for the event, and is refused while that start is not known, once the event has started, or on a market Lean has not placed in an event. On a time window market, at least 6 minutes ahead and at or before the window end, and `game_start` is refused. Whatever has not filled by then is canceled, and the order reads expired."
                  },
                  "max_slippage_bps": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000,
                    "description": "Optional extra cap: the furthest each venue order may trade from that venue's own best price, in basis points; overrides the account's max_slippage_bps. Each venue is measured against its own book, not the best price across venues, so venues quoting different prices can each fill. Never looser than limit_price. Without one, a limit order trades to its limit and a market order to 1 cent past the worst price its quantity reaches in the book, as the Lean trading terminal places it."
                  },
                  "all_or_none": {
                    "type": "boolean",
                    "default": false,
                    "description": "Refuse the order unless the books, as read, fill the whole quantity within the slippage bound. Needs time_in_force ioc or fok. Best effort: venue orders are placed separately and books can move between the read and the fill, so a partial fill is still possible."
                  },
                  "post_only": {
                    "type": "boolean",
                    "default": false,
                    "description": "Only rest on the book, never take. Needs time_in_force gtc, cannot take best_price, and is placed on Kalshi, Polymarket US and Hyperliquid. On a time window market it needs gtd instead and rests on Lighter. An order that would trade at once against the books, as read, is refused with reason POST_ONLY_WOULD_CROSS, and the venue rejects one that would trade by the time it arrives."
                  },
                  "venues": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "kalshi",
                        "polymarket",
                        "polymarket_us",
                        "hyperliquid"
                      ]
                    },
                    "minItems": 1,
                    "description": "Only these venues may fill or fund the order, within the account's allowed venues. A single venue sends the order only there, and the order is refused if that venue can't fill it. Omit to use every allowed venue."
                  },
                  "best_price": {
                    "type": "boolean",
                    "default": false,
                    "description": "Buy at the best price across venues: when a route across venues that moves cash from another venue would cost less in all than buying where the account's cash is, the buy goes through that route. Needs the route scope. A test key prices a route at the order's limit, so there it wins only when the direct buy's fees cost more. Sells already sell across every venue that holds shares, so this does not change them."
                  }
                },
                "required": [
                  "client_order_id",
                  "market_id",
                  "action"
                ],
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "bot-0001",
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "action": "buy",
                "type": "limit",
                "quantity": "10",
                "limit_price": "0.55",
                "time_in_force": "gtc",
                "all_or_none": false,
                "post_only": false,
                "best_price": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What POST /v1/orders would do with this body and the best route across venues; places and reserves nothing",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "execution": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "kalshi",
                                    "polymarket",
                                    "polymarket_us",
                                    "hyperliquid",
                                    "lighter"
                                  ]
                                },
                                "ticker": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "side": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "yes",
                                    "no"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "max_slippage_bps": {
                                  "type": "integer",
                                  "nullable": true,
                                  "minimum": 0,
                                  "maximum": 10000
                                },
                                "executable_quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "expected_average_price": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "legs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "expected_fill_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "expected_average_price": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "expected_fee_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "expected_resting_fee_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "reward": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "eligible": {
                                            "type": "boolean",
                                            "nullable": true,
                                            "description": "Whether the resting remainder would score at this price and size if the book holds. Null when the book could not be read."
                                          },
                                          "daily_reward_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$",
                                            "description": "What the venue market’s active reward programs pay all makers per day."
                                          },
                                          "reasons": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "code": {
                                                  "type": "string",
                                                  "enum": [
                                                    "NOT_RESTING",
                                                    "NO_LIQUIDITY_PROGRAM",
                                                    "NO_MIDPOINT",
                                                    "OUTSIDE_MAX_SPREAD",
                                                    "BELOW_MIN_SIZE",
                                                    "BOOK_BELOW_TARGET",
                                                    "OUTSIDE_TARGET_DEPTH",
                                                    "BOOK_UNAVAILABLE"
                                                  ],
                                                  "description": "`NOT_RESTING`: nothing of the leg rests (a market, ioc or fok order, or one that fills at once). `NO_LIQUIDITY_PROGRAM`: the market’s programs pay for volume, not resting orders. `NO_MIDPOINT`: the book has no bid or no ask to take a midpoint from. `OUTSIDE_MAX_SPREAD`: the price is further from the midpoint than the program’s max spread. `BELOW_MIN_SIZE`: the resting size is below the program’s min size. `BOOK_BELOW_TARGET`: the book is shallower than every program’s target size. `OUTSIDE_TARGET_DEPTH`: better-priced orders already fill the target size. `BOOK_UNAVAILABLE`: the book could not be read."
                                                },
                                                "message": {
                                                  "type": "string",
                                                  "minLength": 1
                                                }
                                              },
                                              "required": [
                                                "code",
                                                "message"
                                              ]
                                            },
                                            "description": "Why the remainder would not score; empty when it would."
                                          }
                                        },
                                        "required": [
                                          "eligible",
                                          "daily_reward_usd",
                                          "reasons"
                                        ],
                                        "description": "Liquidity reward eligibility of what this leg rests. Null when the venue market has no active reward program; GET /v1/rewards/programs lists those that do."
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "quantity",
                                      "limit_price",
                                      "notional_usd",
                                      "expected_fill_quantity",
                                      "expected_average_price",
                                      "expected_fee_usd",
                                      "expected_resting_fee_usd",
                                      "reward"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "venue",
                                "ticker",
                                "side",
                                "notional_usd",
                                "max_slippage_bps",
                                "executable_quantity",
                                "expected_average_price",
                                "legs"
                              ]
                            },
                            "would_submit": {
                              "type": "boolean"
                            },
                            "route_plan": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "market_id": {
                                  "type": "string",
                                  "minLength": 1,
                                  "description": "The market id from GET /markets, however the request named the market."
                                },
                                "action": {
                                  "type": "string",
                                  "enum": [
                                    "buy",
                                    "sell"
                                  ]
                                },
                                "quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "executable_quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "average_price": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "legs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "average_price": {
                                        "type": "string"
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "fee_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "executable": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "quantity",
                                      "average_price",
                                      "limit_price",
                                      "fee_usd",
                                      "executable"
                                    ]
                                  }
                                },
                                "expected_total_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "max_total_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "network_cost_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "limited_by": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "quoted_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "expires_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "market_id",
                                "action",
                                "quantity",
                                "executable_quantity",
                                "average_price",
                                "legs",
                                "expected_total_usd",
                                "max_total_usd",
                                "network_cost_usd",
                                "limited_by",
                                "quoted_at",
                                "expires_at",
                                "livemode"
                              ]
                            },
                            "route": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "funding_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "execution_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "costs": {
                                  "type": "object",
                                  "properties": {
                                    "rebalance_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "gas_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "activation_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "network_cost_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "rebalance_fee_usd",
                                    "gas_usd",
                                    "activation_fee_usd",
                                    "network_cost_usd"
                                  ]
                                }
                              },
                              "required": [
                                "funding_venue",
                                "execution_venue",
                                "notional_usd",
                                "costs"
                              ]
                            },
                            "warnings": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "code": {
                                    "type": "string",
                                    "enum": [
                                      "BELOW_VENUE_MINIMUM",
                                      "ORDER_NOTIONAL_LIMIT",
                                      "DAILY_NOTIONAL_LIMIT",
                                      "NO_EXECUTABLE_VENUE",
                                      "VENUE_NOT_ALLOWED",
                                      "INSUFFICIENT_FUNDS",
                                      "INSUFFICIENT_HOLDINGS",
                                      "INSUFFICIENT_DEPTH",
                                      "POST_ONLY_WOULD_CROSS",
                                      "CLIENT_ORDER_ID_USED",
                                      "TRADING_UNAVAILABLE",
                                      "ROUTE_LIMITED",
                                      "ROUTE_UNAVAILABLE"
                                    ]
                                  },
                                  "message": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "code",
                                  "message"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_id",
                            "action",
                            "quantity",
                            "limit_price",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "execution",
                            "would_submit",
                            "route_plan",
                            "route",
                            "warnings",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Would submit": {
                    "summary": "POST /v1/orders would place this",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "5",
                        "limit_price": "0.50",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "execution": {
                          "venue": "hyperliquid",
                          "ticker": "<venue ticker>",
                          "side": "yes",
                          "notional_usd": "2.5",
                          "max_slippage_bps": 700,
                          "executable_quantity": "5",
                          "expected_average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "limit_price": "0.50",
                              "notional_usd": "2.5",
                              "expected_fill_quantity": "5",
                              "expected_average_price": "0.47",
                              "expected_fee_usd": "0",
                              "expected_resting_fee_usd": "0"
                            }
                          ]
                        },
                        "would_submit": true,
                        "route_plan": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "5",
                          "executable_quantity": "5",
                          "average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "average_price": "0.47",
                              "limit_price": "0.50",
                              "fee_usd": "0",
                              "executable": true
                            }
                          ],
                          "expected_total_usd": "2.35",
                          "max_total_usd": "2.5",
                          "network_cost_usd": "0",
                          "limited_by": null,
                          "quoted_at": "2026-10-11T18:00:00.000Z",
                          "expires_at": "2026-10-11T18:00:15.000Z",
                          "livemode": true
                        },
                        "route": null,
                        "warnings": [],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  },
                  "Would be refused": {
                    "summary": "Above the key limit; would_submit is false",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "50",
                        "limit_price": "0.50",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "execution": null,
                        "would_submit": false,
                        "route_plan": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "50",
                          "executable_quantity": "50",
                          "average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "50",
                              "average_price": "0.47",
                              "limit_price": "0.50",
                              "fee_usd": "0",
                              "executable": true
                            }
                          ],
                          "expected_total_usd": "23.5",
                          "max_total_usd": "25",
                          "network_cost_usd": "0",
                          "limited_by": null,
                          "quoted_at": "2026-10-11T18:00:00.000Z",
                          "expires_at": "2026-10-11T18:00:15.000Z",
                          "livemode": true
                        },
                        "route": null,
                        "warnings": [
                          {
                            "code": "ORDER_NOTIONAL_LIMIT",
                            "message": "Order notional exceeds this key's per-order limit"
                          }
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  },
                  "Insufficient funds": {
                    "summary": "No venue that could place it has the cash",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "5",
                        "limit_price": "0.50",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "execution": null,
                        "would_submit": false,
                        "route_plan": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "5",
                          "executable_quantity": "5",
                          "average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "average_price": "0.47",
                              "limit_price": "0.50",
                              "fee_usd": "0",
                              "executable": true
                            }
                          ],
                          "expected_total_usd": "2.35",
                          "max_total_usd": "2.5",
                          "network_cost_usd": "0",
                          "limited_by": null,
                          "quoted_at": "2026-10-11T18:00:00.000Z",
                          "expires_at": "2026-10-11T18:00:15.000Z",
                          "livemode": true
                        },
                        "route": null,
                        "warnings": [
                          {
                            "code": "INSUFFICIENT_FUNDS",
                            "message": "The trading account cannot pay for this order on the venues that could place it"
                          }
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  },
                  "Test key": {
                    "summary": "A test key's plan is simulated over the public order books",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "5",
                        "limit_price": "0.50",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "execution": {
                          "venue": "hyperliquid",
                          "ticker": "<venue ticker>",
                          "side": "yes",
                          "notional_usd": "2.5",
                          "max_slippage_bps": 700,
                          "executable_quantity": "5",
                          "expected_average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "limit_price": "0.50",
                              "notional_usd": "2.5",
                              "expected_fill_quantity": "5",
                              "expected_average_price": "0.47",
                              "expected_fee_usd": "0",
                              "expected_resting_fee_usd": "0"
                            }
                          ]
                        },
                        "would_submit": true,
                        "route_plan": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "5",
                          "executable_quantity": "5",
                          "average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "average_price": "0.47",
                              "limit_price": "0.50",
                              "fee_usd": "0",
                              "executable": true
                            }
                          ],
                          "expected_total_usd": "2.35",
                          "max_total_usd": "2.5",
                          "network_cost_usd": "0",
                          "limited_by": null,
                          "quoted_at": "2026-10-11T18:00:00.000Z",
                          "expires_at": "2026-10-11T18:00:15.000Z",
                          "livemode": false
                        },
                        "route": null,
                        "warnings": [],
                        "livemode": false
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  },
                  "Live trading off": {
                    "summary": "A live key on an account where live trading is not enabled yet",
                    "value": {
                      "success": true,
                      "data": {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "action": "buy",
                        "quantity": "5",
                        "limit_price": "0.50",
                        "type": "limit",
                        "time_in_force": "ioc",
                        "expires_at": null,
                        "execution": {
                          "venue": "hyperliquid",
                          "ticker": "<venue ticker>",
                          "side": "yes",
                          "notional_usd": "2.5",
                          "max_slippage_bps": 700,
                          "executable_quantity": "5",
                          "expected_average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "limit_price": "0.50",
                              "notional_usd": "2.5",
                              "expected_fill_quantity": "5",
                              "expected_average_price": "0.47",
                              "expected_fee_usd": "0",
                              "expected_resting_fee_usd": "0"
                            }
                          ]
                        },
                        "would_submit": false,
                        "route_plan": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "5",
                          "executable_quantity": "5",
                          "average_price": "0.47",
                          "legs": [
                            {
                              "venue": "hyperliquid",
                              "ticker": "<venue ticker>",
                              "side": "yes",
                              "quantity": "5",
                              "average_price": "0.47",
                              "limit_price": "0.50",
                              "fee_usd": "0",
                              "executable": true
                            }
                          ],
                          "expected_total_usd": "2.35",
                          "max_total_usd": "2.5",
                          "network_cost_usd": "0",
                          "limited_by": null,
                          "quoted_at": "2026-10-11T18:00:00.000Z",
                          "expires_at": "2026-10-11T18:00:15.000Z",
                          "livemode": true
                        },
                        "route": null,
                        "warnings": [
                          {
                            "code": "TRADING_UNAVAILABLE",
                            "message": "Live order placement is switched off. Test keys can still place simulated orders."
                          }
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The order terms are invalid or no venue takes them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "market_gtc": {
                    "summary": "A market order that would rest",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "market orders need time_in_force ioc or fok"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "gtd_without_expiry": {
                    "summary": "gtd without expires_at",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "gtd orders need expires_at"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "Bad limit price": {
                    "summary": "limit_price outside (0, 1)",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "limit_price must be strictly between 0 and 1"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "Market not found",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Market not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A venue has stopped trading the market, so there is nothing to quote or fill against; details.reason is MARKET_NOT_TRADABLE. Its book still reads with 200.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "market_not_tradable": {
                    "summary": "The venue stopped trading the market",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "Polymarket has stopped trading this market",
                        "details": {
                          "reason": "MARKET_NOT_TRADABLE"
                        }
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The body is sized wrong; nothing was checked further",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "quantity_and_notional": {
                    "summary": "Both or neither of quantity and notional",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Send exactly one of quantity or notional"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "notional_gtc": {
                    "summary": "notional on a resting order",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "notional needs time_in_force ioc or fok; size a resting order with quantity"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  },
                  "notional_sell": {
                    "summary": "notional on a sell",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "notional sizes buys only; size a sell with quantity"
                      },
                      "meta": {
                        "timestampMs": 1792771200000,
                        "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "A venue failed or did not answer, or routing is paused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Venue error": {
                    "summary": "The venue failed or did not answer",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "A required service is temporarily unavailable."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "0e7a3c91-5f2b-4d84-9c16-a8b4e2d7f031"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/preview-batch": {
      "post": {
        "operationId": "previewOrdersBatch",
        "summary": "Preview several orders",
        "description": "Previews up to 25 order bodies in one call, each exactly as POST /v1/orders/preview previews it, and runs them at once, so a batch takes about as long as its slowest preview. Each body is previewed on its own: the batch does not add the notional of one body to another's limit checks. One body that cannot be previewed does not stop the rest; its result carries the status and error the single preview answers with. Results are in the order the bodies were sent. Nothing is placed or reserved, and the call counts once against the key's rate limit.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orders": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "client_order_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,64}$",
                          "description": "Unique per API key. Replaying an id returns the original order."
                        },
                        "market_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead. An order named by a venue symbol trades only that listing, so it is refused when `venues` leaves out the symbol's venue. A buy routed automatically still buys that listing, paid from the other venue. The order is stored under the market id."
                        },
                        "action": {
                          "type": "string",
                          "enum": [
                            "buy",
                            "sell"
                          ]
                        },
                        "quantity": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d+)?$",
                          "description": "Shares, in 0.01 steps. Send exactly one of quantity or notional. A sell of the whole position, as held or written to two decimals, sells what each venue's increment allows and keeps the rest."
                        },
                        "notional": {
                          "type": "string",
                          "pattern": "^\\d+(?:\\.\\d{1,2})?$",
                          "description": "Dollars to spend on an ioc or fok buy, in place of quantity, at most two decimals. The buy walks the books from the best price and never spends more than this before fees; Lean works out the shares. Sells and resting orders are sized with quantity."
                        },
                        "limit_price": {
                          "type": "string",
                          "description": "Worst price per share you accept, in dollars. Required with quantity on a limit order. With notional or on a market order it defaults to 0.99 for a buy and 0.01 for a sell; a market order is then placed 1 cent past the worst price its quantity reaches in the book, tightened by max_slippage_bps when set."
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "limit",
                            "market"
                          ],
                          "default": "limit",
                          "description": "limit trades at limit_price or better. market trades at once at the best prices: it needs time_in_force ioc or fok, and each venue order is placed 1 cent past the worst price its quantity reaches in the book of that venue. limit_price and max_slippage_bps are optional extra caps on the worst price it accepts."
                        },
                        "time_in_force": {
                          "type": "string",
                          "enum": [
                            "gtc",
                            "ioc",
                            "fok",
                            "gtd"
                          ],
                          "default": "gtc",
                          "description": "gtc rests until filled or canceled. ioc fills what it can at once and cancels the rest. fok fills the whole order at once or cancels all of it, and is placed whole on one venue: Polymarket, else Kalshi, since Hyperliquid has no fill or kill and Polymarket US can fill one in part. gtd rests like gtc until expires_at, on every venue. Hyperliquid has no order expiry, so there Lean places the order as gtc and cancels what is left at expires_at. Polymarket takes an ioc or fok buy only by dollar amount: one sized with notional can fill there, while one sized with quantity goes only to the other venues, and when Polymarket is the only one it is refused with 400 VALIDATION_ERROR, so send it with notional or as gtc. notional needs ioc or fok. A time window market takes only gtd or ioc, and its orders go to Lighter."
                        },
                        "expires_at": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "string",
                              "enum": [
                                "game_start"
                              ]
                            }
                          ],
                          "description": "When a gtd order expires, as an ISO 8601 time, or `game_start` to expire it when the event of its market starts. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. `game_start` reads the start Lean holds for the event, and is refused while that start is not known, once the event has started, or on a market Lean has not placed in an event. On a time window market, at least 6 minutes ahead and at or before the window end, and `game_start` is refused. Whatever has not filled by then is canceled, and the order reads expired."
                        },
                        "max_slippage_bps": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 10000,
                          "description": "Optional extra cap: the furthest each venue order may trade from that venue's own best price, in basis points; overrides the account's max_slippage_bps. Each venue is measured against its own book, not the best price across venues, so venues quoting different prices can each fill. Never looser than limit_price. Without one, a limit order trades to its limit and a market order to 1 cent past the worst price its quantity reaches in the book, as the Lean trading terminal places it."
                        },
                        "all_or_none": {
                          "type": "boolean",
                          "default": false,
                          "description": "Refuse the order unless the books, as read, fill the whole quantity within the slippage bound. Needs time_in_force ioc or fok. Best effort: venue orders are placed separately and books can move between the read and the fill, so a partial fill is still possible."
                        },
                        "post_only": {
                          "type": "boolean",
                          "default": false,
                          "description": "Only rest on the book, never take. Needs time_in_force gtc, cannot take best_price, and is placed on Kalshi, Polymarket US and Hyperliquid. On a time window market it needs gtd instead and rests on Lighter. An order that would trade at once against the books, as read, is refused with reason POST_ONLY_WOULD_CROSS, and the venue rejects one that would trade by the time it arrives."
                        },
                        "venues": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "kalshi",
                              "polymarket",
                              "polymarket_us",
                              "hyperliquid"
                            ]
                          },
                          "minItems": 1,
                          "description": "Only these venues may fill or fund the order, within the account's allowed venues. A single venue sends the order only there, and the order is refused if that venue can't fill it. Omit to use every allowed venue."
                        },
                        "best_price": {
                          "type": "boolean",
                          "default": false,
                          "description": "Buy at the best price across venues: when a route across venues that moves cash from another venue would cost less in all than buying where the account's cash is, the buy goes through that route. Needs the route scope. A test key prices a route at the order's limit, so there it wins only when the direct buy's fees cost more. Sells already sell across every venue that holds shares, so this does not change them."
                        }
                      },
                      "required": [
                        "client_order_id",
                        "market_id",
                        "action"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 25,
                    "description": "Between 1 and 25 bodies of POST /v1/orders, each previewed as POST /v1/orders/preview previews it. A body that fails validation refuses the whole batch with 400."
                  }
                },
                "required": [
                  "orders"
                ],
                "additionalProperties": false
              },
              "example": {
                "orders": [
                  {
                    "client_order_id": "bot-0001",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "action": "buy",
                    "type": "limit",
                    "quantity": "10",
                    "limit_price": "0.55",
                    "time_in_force": "gtc",
                    "all_or_none": false,
                    "post_only": false,
                    "best_price": false
                  },
                  {
                    "client_order_id": "bot-0002",
                    "market_id": "mkt_unknown",
                    "action": "buy",
                    "type": "limit",
                    "quantity": "10",
                    "limit_price": "0.55",
                    "time_in_force": "gtc",
                    "all_or_none": false,
                    "post_only": false,
                    "best_price": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One result per body, in the order sent; places and reserves nothing",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "integer",
                                    "description": "The HTTP status POST /v1/orders/preview answers this body with: 200 with `preview`, otherwise the status of `error`."
                                  },
                                  "preview": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "market_id": {
                                        "type": "string",
                                        "minLength": 1,
                                        "description": "The market id from GET /markets, however the request named the market."
                                      },
                                      "action": {
                                        "type": "string",
                                        "enum": [
                                          "buy",
                                          "sell"
                                        ]
                                      },
                                      "quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "limit_price": {
                                        "type": "string"
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "market"
                                        ]
                                      },
                                      "time_in_force": {
                                        "type": "string",
                                        "enum": [
                                          "gtc",
                                          "ioc",
                                          "fok",
                                          "gtd"
                                        ]
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "execution": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "venue": {
                                            "type": "string",
                                            "nullable": true,
                                            "enum": [
                                              "kalshi",
                                              "polymarket",
                                              "polymarket_us",
                                              "hyperliquid",
                                              "lighter"
                                            ]
                                          },
                                          "ticker": {
                                            "type": "string",
                                            "nullable": true,
                                            "minLength": 1
                                          },
                                          "side": {
                                            "type": "string",
                                            "nullable": true,
                                            "enum": [
                                              "yes",
                                              "no"
                                            ]
                                          },
                                          "notional_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "max_slippage_bps": {
                                            "type": "integer",
                                            "nullable": true,
                                            "minimum": 0,
                                            "maximum": 10000
                                          },
                                          "executable_quantity": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "expected_average_price": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "legs": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "venue": {
                                                  "type": "string",
                                                  "enum": [
                                                    "kalshi",
                                                    "polymarket",
                                                    "polymarket_us",
                                                    "hyperliquid",
                                                    "lighter"
                                                  ]
                                                },
                                                "ticker": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "side": {
                                                  "type": "string",
                                                  "enum": [
                                                    "yes",
                                                    "no"
                                                  ]
                                                },
                                                "quantity": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "limit_price": {
                                                  "type": "string"
                                                },
                                                "notional_usd": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "expected_fill_quantity": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "expected_average_price": {
                                                  "type": "string",
                                                  "nullable": true
                                                },
                                                "expected_fee_usd": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "expected_resting_fee_usd": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "reward": {
                                                  "type": "object",
                                                  "nullable": true,
                                                  "properties": {
                                                    "eligible": {
                                                      "type": "boolean",
                                                      "nullable": true,
                                                      "description": "Whether the resting remainder would score at this price and size if the book holds. Null when the book could not be read."
                                                    },
                                                    "daily_reward_usd": {
                                                      "type": "string",
                                                      "pattern": "^\\d+(?:\\.\\d+)?$",
                                                      "description": "What the venue market’s active reward programs pay all makers per day."
                                                    },
                                                    "reasons": {
                                                      "type": "array",
                                                      "items": {
                                                        "type": "object",
                                                        "properties": {
                                                          "code": {
                                                            "type": "string",
                                                            "enum": [
                                                              "NOT_RESTING",
                                                              "NO_LIQUIDITY_PROGRAM",
                                                              "NO_MIDPOINT",
                                                              "OUTSIDE_MAX_SPREAD",
                                                              "BELOW_MIN_SIZE",
                                                              "BOOK_BELOW_TARGET",
                                                              "OUTSIDE_TARGET_DEPTH",
                                                              "BOOK_UNAVAILABLE"
                                                            ],
                                                            "description": "`NOT_RESTING`: nothing of the leg rests (a market, ioc or fok order, or one that fills at once). `NO_LIQUIDITY_PROGRAM`: the market’s programs pay for volume, not resting orders. `NO_MIDPOINT`: the book has no bid or no ask to take a midpoint from. `OUTSIDE_MAX_SPREAD`: the price is further from the midpoint than the program’s max spread. `BELOW_MIN_SIZE`: the resting size is below the program’s min size. `BOOK_BELOW_TARGET`: the book is shallower than every program’s target size. `OUTSIDE_TARGET_DEPTH`: better-priced orders already fill the target size. `BOOK_UNAVAILABLE`: the book could not be read."
                                                          },
                                                          "message": {
                                                            "type": "string",
                                                            "minLength": 1
                                                          }
                                                        },
                                                        "required": [
                                                          "code",
                                                          "message"
                                                        ]
                                                      },
                                                      "description": "Why the remainder would not score; empty when it would."
                                                    }
                                                  },
                                                  "required": [
                                                    "eligible",
                                                    "daily_reward_usd",
                                                    "reasons"
                                                  ],
                                                  "description": "Liquidity reward eligibility of what this leg rests. Null when the venue market has no active reward program; GET /v1/rewards/programs lists those that do."
                                                }
                                              },
                                              "required": [
                                                "venue",
                                                "ticker",
                                                "side",
                                                "quantity",
                                                "limit_price",
                                                "notional_usd",
                                                "expected_fill_quantity",
                                                "expected_average_price",
                                                "expected_fee_usd",
                                                "expected_resting_fee_usd",
                                                "reward"
                                              ]
                                            }
                                          }
                                        },
                                        "required": [
                                          "venue",
                                          "ticker",
                                          "side",
                                          "notional_usd",
                                          "max_slippage_bps",
                                          "executable_quantity",
                                          "expected_average_price",
                                          "legs"
                                        ]
                                      },
                                      "would_submit": {
                                        "type": "boolean"
                                      },
                                      "route_plan": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "market_id": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "The market id from GET /markets, however the request named the market."
                                          },
                                          "action": {
                                            "type": "string",
                                            "enum": [
                                              "buy",
                                              "sell"
                                            ]
                                          },
                                          "quantity": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "executable_quantity": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "average_price": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "legs": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "venue": {
                                                  "type": "string",
                                                  "enum": [
                                                    "kalshi",
                                                    "polymarket",
                                                    "polymarket_us",
                                                    "hyperliquid"
                                                  ]
                                                },
                                                "ticker": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "side": {
                                                  "type": "string",
                                                  "enum": [
                                                    "yes",
                                                    "no"
                                                  ]
                                                },
                                                "quantity": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "average_price": {
                                                  "type": "string"
                                                },
                                                "limit_price": {
                                                  "type": "string"
                                                },
                                                "fee_usd": {
                                                  "type": "string",
                                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                                },
                                                "executable": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "venue",
                                                "ticker",
                                                "side",
                                                "quantity",
                                                "average_price",
                                                "limit_price",
                                                "fee_usd",
                                                "executable"
                                              ]
                                            }
                                          },
                                          "expected_total_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "max_total_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "network_cost_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "limited_by": {
                                            "type": "string",
                                            "nullable": true
                                          },
                                          "quoted_at": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "expires_at": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "livemode": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": [
                                          "market_id",
                                          "action",
                                          "quantity",
                                          "executable_quantity",
                                          "average_price",
                                          "legs",
                                          "expected_total_usd",
                                          "max_total_usd",
                                          "network_cost_usd",
                                          "limited_by",
                                          "quoted_at",
                                          "expires_at",
                                          "livemode"
                                        ]
                                      },
                                      "route": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "funding_venue": {
                                            "type": "string",
                                            "enum": [
                                              "polymarket",
                                              "hyperliquid"
                                            ]
                                          },
                                          "execution_venue": {
                                            "type": "string",
                                            "enum": [
                                              "polymarket",
                                              "hyperliquid"
                                            ]
                                          },
                                          "notional_usd": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "costs": {
                                            "type": "object",
                                            "properties": {
                                              "rebalance_fee_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "gas_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "activation_fee_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              },
                                              "network_cost_usd": {
                                                "type": "string",
                                                "pattern": "^\\d+(?:\\.\\d+)?$"
                                              }
                                            },
                                            "required": [
                                              "rebalance_fee_usd",
                                              "gas_usd",
                                              "activation_fee_usd",
                                              "network_cost_usd"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "funding_venue",
                                          "execution_venue",
                                          "notional_usd",
                                          "costs"
                                        ]
                                      },
                                      "warnings": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "code": {
                                              "type": "string",
                                              "enum": [
                                                "BELOW_VENUE_MINIMUM",
                                                "ORDER_NOTIONAL_LIMIT",
                                                "DAILY_NOTIONAL_LIMIT",
                                                "NO_EXECUTABLE_VENUE",
                                                "VENUE_NOT_ALLOWED",
                                                "INSUFFICIENT_FUNDS",
                                                "INSUFFICIENT_HOLDINGS",
                                                "INSUFFICIENT_DEPTH",
                                                "POST_ONLY_WOULD_CROSS",
                                                "CLIENT_ORDER_ID_USED",
                                                "TRADING_UNAVAILABLE",
                                                "ROUTE_LIMITED",
                                                "ROUTE_UNAVAILABLE"
                                              ]
                                            },
                                            "message": {
                                              "type": "string",
                                              "minLength": 1
                                            }
                                          },
                                          "required": [
                                            "code",
                                            "message"
                                          ]
                                        }
                                      },
                                      "livemode": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "market_id",
                                      "action",
                                      "quantity",
                                      "limit_price",
                                      "type",
                                      "time_in_force",
                                      "expires_at",
                                      "execution",
                                      "would_submit",
                                      "route_plan",
                                      "route",
                                      "warnings",
                                      "livemode"
                                    ],
                                    "description": "What POST /v1/orders/preview answers for this body; null when it answers with an error."
                                  },
                                  "error": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "enum": [
                                          "VALIDATION_ERROR",
                                          "NOT_FOUND",
                                          "UNAUTHORIZED",
                                          "FORBIDDEN",
                                          "CONFLICT",
                                          "UPSTREAM_ERROR",
                                          "RATE_LIMITED",
                                          "INTERNAL_ERROR",
                                          "FEATURE_DISABLED",
                                          "CONDITIONAL_SELL_REJECTED",
                                          "CONDITIONAL_SELL_ACTIVE"
                                        ]
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "details": {
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ],
                                    "description": "The error POST /v1/orders/preview answers this body with, with the same code, message and details; null when it previews."
                                  }
                                },
                                "required": [
                                  "status",
                                  "preview",
                                  "error"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "results",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "results": [
                      {
                        "status": 200,
                        "preview": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "action": "buy",
                          "quantity": "10",
                          "limit_price": "0.55",
                          "type": "limit",
                          "time_in_force": "gtc",
                          "expires_at": null,
                          "execution": {
                            "venue": "hyperliquid",
                            "ticker": "hl:9999",
                            "side": "yes",
                            "notional_usd": "5.5",
                            "max_slippage_bps": 100,
                            "executable_quantity": "10",
                            "expected_average_price": "0.53",
                            "legs": [
                              {
                                "venue": "hyperliquid",
                                "ticker": "hl:9999",
                                "side": "yes",
                                "quantity": "10",
                                "limit_price": "0.55",
                                "notional_usd": "5.5",
                                "expected_fill_quantity": "10",
                                "expected_average_price": "0.53",
                                "expected_fee_usd": "0",
                                "expected_resting_fee_usd": "0",
                                "reward": null
                              }
                            ]
                          },
                          "would_submit": true,
                          "route_plan": null,
                          "route": null,
                          "warnings": [],
                          "livemode": false
                        },
                        "error": null
                      },
                      {
                        "status": 404,
                        "preview": null,
                        "error": {
                          "code": "NOT_FOUND",
                          "message": "Market not found"
                        }
                      }
                    ],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not a list of 1 to 25 valid order bodies; nothing was previewed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The body is not a list of 1 to 25 valid order bodies"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/cancel": {
      "post": {
        "operationId": "cancelOrder",
        "summary": "Cancel an order",
        "description": "Cancels what is still resting of an open order on every venue it was placed on and returns the order once the venues answer. Shares already filled stay filled.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Order after the venue processed the cancel",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Canceled": {
                    "summary": "A resting gtc order, canceled",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                        "client_order_id": "bot-2026-10-29-0002",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "source": "api",
                        "venue": "hyperliquid",
                        "ticker": "<venue ticker>",
                        "side": "yes",
                        "action": "buy",
                        "type": "limit",
                        "time_in_force": "gtc",
                        "expires_at": null,
                        "quantity": "10",
                        "filled_quantity": "0",
                        "remaining_quantity": "0",
                        "limit_price": "0.45",
                        "avg_fill_price": null,
                        "notional_usd": "4.5",
                        "filled_notional_usd": "0",
                        "status": "canceled",
                        "venue_status": "canceled",
                        "venue_order_id": "91234567388",
                        "status_reason": null,
                        "post_only": false,
                        "replaces_order_id": null,
                        "replaced_by_order_id": null,
                        "legs": [
                          {
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "10",
                            "filled_quantity": "0",
                            "limit_price": "0.45",
                            "avg_fill_price": null,
                            "status": "canceled",
                            "venue_status": "canceled",
                            "venue_order_id": "91234567388",
                            "cancel_requested_at": null,
                            "status_reason": null
                          }
                        ],
                        "created_at": "2026-10-11T18:04:40.902Z",
                        "updated_at": "2026-10-11T18:09:12.050Z",
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791742152061,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Bad id": {
                    "summary": "id is not a UUID",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "id",
                            "message": "Invalid uuid"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the trade scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the trade scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No API order has this id. When GET /v1/orders listed the id for an order placed in the Lean app, `details.reason` is APP_ORDER_NOT_ADDRESSABLE: cancel app orders in the Lean app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "Order not found",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Order not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  },
                  "App order": {
                    "summary": "An order GET /v1/orders listed with source app",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "This order was placed in the Lean app. App orders are listed by GET /v1/orders but cannot be read by id, amended or canceled through the API; manage it in the Lean app.",
                        "details": {
                          "reason": "APP_ORDER_NOT_ADDRESSABLE"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The order is not open, the venue has not acknowledged it, or its route payment is already under way",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Already final": {
                    "summary": "The order already finished, as every test order has",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "Order is already filled"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  },
                  "Not acknowledged": {
                    "summary": "The venue has not confirmed the order",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "The venue has not acknowledged this order yet. Read it back first."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 10 cancels a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "A venue was unreachable, so its leg was not canceled; read the order again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Venue unavailable": {
                    "summary": "That venue's leg was not canceled; read the order again",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UPSTREAM_ERROR",
                        "message": "Hyperliquid upstream request failed",
                        "details": {
                          "order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
                        }
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "2c9e7f04-6a1d-4b58-9e3c-b7f05d2a8c16"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/fills": {
      "get": {
        "operationId": "listFills",
        "summary": "List fills",
        "description": "Executions on this key’s trading account, newest first, with price, quantity, fee and whether each fill made or took liquidity. Each fill names its `market_id`, `title` and `outcome`, or null when no market is listed for it. Filter by order, venue, market, time or text in the market title, and pass `next_cursor` back as `cursor` for the next page. A live key also sees fills of orders placed outside the API; a test key sees its simulated fills, including those of its limit chases. A limit chase’s fills have `order_id` `null`. Kalshi and Polymarket US fills belong to the user rather than one trading account, so every trading account of the user lists them. Reading a filled order with `GET /v1/orders/{id}` brings its fills into this list. A Polymarket fill whose trade Polygon has not confirmed yet, or a fill of an order you have not read, can be listed a few seconds after its order reads `filled`.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Only fills of this API order."
            },
            "required": false,
            "description": "Only fills of this API order.",
            "name": "order_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only fills on this venue."
            },
            "required": false,
            "description": "Only fills on this venue.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Only fills on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
            },
            "required": false,
            "description": "Only fills on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "market_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Text, in any letter case, found in the title or outcome of the market the fill trades."
            },
            "required": false,
            "description": "Text, in any letter case, found in the title or outcome of the market the fill trades.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only fills at or after this time."
            },
            "required": false,
            "description": "Only fills at or after this time.",
            "name": "filled_after",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only fills before this time."
            },
            "required": false,
            "description": "Only fills before this time.",
            "name": "filled_before",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Fills on this key's trading account, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "fills": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "order_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uuid"
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  },
                                  "action": {
                                    "type": "string",
                                    "enum": [
                                      "buy",
                                      "sell"
                                    ]
                                  },
                                  "price": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "fee_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "liquidity": {
                                    "type": "string",
                                    "enum": [
                                      "maker",
                                      "taker"
                                    ]
                                  },
                                  "filled_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "order_id",
                                  "market_id",
                                  "title",
                                  "outcome",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "lean_url",
                                  "venue_url",
                                  "action",
                                  "price",
                                  "quantity",
                                  "fee_usd",
                                  "liquidity",
                                  "filled_at"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "fills",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "fills": [
                      {
                        "id": "fill_2c7e0a95d4b1",
                        "order_id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "outcome": "DEN",
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "lean_url": "https://lean.xyz/trade?ticker=hl%3A9999",
                        "venue_url": "https://app.hyperliquid.xyz/trade",
                        "action": "buy",
                        "price": "0.55",
                        "quantity": "10",
                        "fee_usd": "0.0022",
                        "liquidity": "taker",
                        "filled_at": "2026-10-29T18:00:00.000Z"
                      }
                    ],
                    "next_cursor": null,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/routed-orders": {
      "post": {
        "operationId": "createRoutedOrder",
        "summary": "Place a routed order",
        "description": "The advanced flow for signing route payments yourself: this books the order and returns the payment, which POST /v1/routed-orders/{id}/execute then authorizes. To buy across venues in one call, use POST /v1/orders.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_order_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Unique per API key. Replaying an id returns the original order."
                  },
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead. A venue symbol must name the listing on the execution venue, which the route buys."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$"
                  },
                  "limit_price": {
                    "type": "string",
                    "description": "Worst price per share you accept on the execution venue, in dollars."
                  },
                  "funding_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "description": "The venue whose cash pays for the order. It is bought on the other venue."
                  }
                },
                "required": [
                  "client_order_id",
                  "market_id",
                  "quantity",
                  "limit_price",
                  "funding_venue"
                ],
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "bot-0001",
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "quantity": "10",
                "limit_price": "0.55",
                "funding_venue": "hyperliquid"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The order, pending until its payment is signed, with the payment to sign; the original without a payment on replay",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "route": {
                              "type": "object",
                              "properties": {
                                "funding_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "execution_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "costs": {
                                  "type": "object",
                                  "properties": {
                                    "rebalance_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "gas_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "activation_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "network_cost_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "rebalance_fee_usd",
                                    "gas_usd",
                                    "activation_fee_usd",
                                    "network_cost_usd"
                                  ]
                                }
                              },
                              "required": [
                                "funding_venue",
                                "execution_venue",
                                "notional_usd",
                                "costs"
                              ]
                            },
                            "payment": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "hyperliquid_send_asset"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "HyperliquidSignTransaction"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            },
                                            "chainId": {
                                              "type": "number",
                                              "enum": [
                                                421614
                                              ]
                                            },
                                            "verifyingContract": {
                                              "type": "string",
                                              "enum": [
                                                "0x0000000000000000000000000000000000000000"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version",
                                            "chainId",
                                            "verifyingContract"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "properties": {
                                            "HyperliquidTransaction:SendAsset": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "hyperliquidChain"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "destination"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "sourceDex"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "destinationDex"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "token"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "amount"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "fromSubAccount"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "nonce"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint64"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 8,
                                              "maxItems": 8
                                            }
                                          },
                                          "required": [
                                            "HyperliquidTransaction:SendAsset"
                                          ]
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "HyperliquidTransaction:SendAsset"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "hyperliquidChain": {
                                              "type": "string",
                                              "enum": [
                                                "Mainnet"
                                              ]
                                            },
                                            "destination": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "sourceDex": {
                                              "type": "string"
                                            },
                                            "destinationDex": {
                                              "type": "string"
                                            },
                                            "token": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "amount": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "fromSubAccount": {
                                              "type": "string"
                                            },
                                            "nonce": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            }
                                          },
                                          "required": [
                                            "hyperliquidChain",
                                            "destination",
                                            "sourceDex",
                                            "destinationDex",
                                            "token",
                                            "amount",
                                            "fromSubAccount",
                                            "nonce"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "polymarket_deposit_wallet_batch"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "DepositWallet"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            },
                                            "chainId": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "exclusiveMinimum": true
                                            },
                                            "verifyingContract": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version",
                                            "chainId",
                                            "verifyingContract"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "properties": {
                                            "Call": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "target"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "address"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "value"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "data"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "bytes"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 3,
                                              "maxItems": 3
                                            },
                                            "Batch": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "wallet"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "address"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "nonce"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "deadline"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "calls"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "Call[]"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 4,
                                              "maxItems": 4
                                            }
                                          },
                                          "required": [
                                            "Call",
                                            "Batch"
                                          ]
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "Batch"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "wallet": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "nonce": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "deadline": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "calls": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "target": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]{40}$"
                                                  },
                                                  "value": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  },
                                                  "data": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]+$"
                                                  }
                                                },
                                                "required": [
                                                  "target",
                                                  "value",
                                                  "data"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "wallet",
                                            "nonce",
                                            "deadline",
                                            "calls"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    },
                                    "agent_approval": {
                                      "type": "object",
                                      "nullable": true,
                                      "properties": {
                                        "masterAddress": {
                                          "type": "string",
                                          "pattern": "^0x[a-fA-F0-9]{40}$"
                                        },
                                        "agentAddress": {
                                          "type": "string",
                                          "pattern": "^0x[a-fA-F0-9]{40}$"
                                        },
                                        "action": {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "approveAgent"
                                              ]
                                            },
                                            "hyperliquidChain": {
                                              "type": "string",
                                              "enum": [
                                                "Mainnet"
                                              ]
                                            },
                                            "signatureChainId": {
                                              "type": "string",
                                              "enum": [
                                                "0x66eee"
                                              ]
                                            },
                                            "agentAddress": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "agentName": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "nonce": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "hyperliquidChain",
                                            "signatureChainId",
                                            "agentAddress",
                                            "agentName",
                                            "nonce"
                                          ]
                                        },
                                        "typedData": {
                                          "type": "object",
                                          "properties": {
                                            "domain": {
                                              "type": "object",
                                              "properties": {
                                                "name": {
                                                  "type": "string",
                                                  "enum": [
                                                    "HyperliquidSignTransaction"
                                                  ]
                                                },
                                                "version": {
                                                  "type": "string",
                                                  "enum": [
                                                    "1"
                                                  ]
                                                },
                                                "chainId": {
                                                  "type": "number",
                                                  "enum": [
                                                    421614
                                                  ]
                                                },
                                                "verifyingContract": {
                                                  "type": "string",
                                                  "enum": [
                                                    "0x0000000000000000000000000000000000000000"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "name",
                                                "version",
                                                "chainId",
                                                "verifyingContract"
                                              ]
                                            },
                                            "types": {
                                              "type": "object",
                                              "properties": {
                                                "HyperliquidTransaction:ApproveAgent": {
                                                  "type": "array",
                                                  "items": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "hyperliquidChain"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "string"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "agentAddress"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "address"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "agentName"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "string"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "nonce"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "uint64"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      }
                                                    ]
                                                  },
                                                  "minItems": 4,
                                                  "maxItems": 4
                                                }
                                              },
                                              "required": [
                                                "HyperliquidTransaction:ApproveAgent"
                                              ]
                                            },
                                            "primaryType": {
                                              "type": "string",
                                              "enum": [
                                                "HyperliquidTransaction:ApproveAgent"
                                              ]
                                            },
                                            "message": {
                                              "type": "object",
                                              "properties": {
                                                "hyperliquidChain": {
                                                  "type": "string",
                                                  "enum": [
                                                    "Mainnet"
                                                  ]
                                                },
                                                "agentAddress": {
                                                  "type": "string",
                                                  "pattern": "^0x[a-fA-F0-9]{40}$"
                                                },
                                                "agentName": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "nonce": {
                                                  "type": "integer",
                                                  "minimum": 0,
                                                  "maximum": 9007199254740991
                                                }
                                              },
                                              "required": [
                                                "hyperliquidChain",
                                                "agentAddress",
                                                "agentName",
                                                "nonce"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "domain",
                                            "types",
                                            "primaryType",
                                            "message"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "masterAddress",
                                        "agentAddress",
                                        "action",
                                        "typedData"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data",
                                    "agent_approval"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "lean_test_payment"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "Lean API test routed payment"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "name": {
                                                  "type": "string"
                                                },
                                                "type": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "name",
                                                "type"
                                              ]
                                            }
                                          }
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "RoutedPayment"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "orderId": {
                                              "type": "string",
                                              "format": "uuid"
                                            },
                                            "nonce": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{64}$"
                                            },
                                            "fundingVenue": {
                                              "type": "string",
                                              "enum": [
                                                "polymarket",
                                                "hyperliquid"
                                              ]
                                            },
                                            "executionVenue": {
                                              "type": "string",
                                              "enum": [
                                                "polymarket",
                                                "hyperliquid"
                                              ]
                                            },
                                            "paymentMicros": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "expiresAt": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            }
                                          },
                                          "required": [
                                            "orderId",
                                            "nonce",
                                            "fundingVenue",
                                            "executionVenue",
                                            "paymentMicros",
                                            "expiresAt"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data"
                                  ]
                                },
                                {
                                  "nullable": true
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode",
                            "route",
                            "payment"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                    "client_order_id": "bot-0001",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                    "outcome": "DEN",
                    "source": "api",
                    "venue": null,
                    "ticker": null,
                    "side": null,
                    "action": "buy",
                    "type": "limit",
                    "time_in_force": "gtc",
                    "expires_at": null,
                    "quantity": "10",
                    "filled_quantity": "0",
                    "remaining_quantity": "10",
                    "limit_price": "0.55",
                    "avg_fill_price": null,
                    "notional_usd": "5.511",
                    "filled_notional_usd": "0",
                    "status": "pending",
                    "venue_status": null,
                    "venue_order_id": null,
                    "status_reason": null,
                    "legs": [],
                    "post_only": false,
                    "replaces_order_id": null,
                    "replaced_by_order_id": null,
                    "created_at": "2026-10-29T18:00:00.000Z",
                    "updated_at": "2026-10-29T18:00:00.000Z",
                    "livemode": false,
                    "route": {
                      "funding_venue": "hyperliquid",
                      "execution_venue": "polymarket",
                      "notional_usd": "5.511",
                      "costs": {
                        "rebalance_fee_usd": "0.011",
                        "gas_usd": "0",
                        "activation_fee_usd": "0",
                        "network_cost_usd": "0.011"
                      }
                    },
                    "payment": {
                      "scheme": "lean_test_payment",
                      "signer_address": "0x1111111111111111111111111111111111111111",
                      "typed_data": {
                        "domain": {
                          "name": "Lean API test routed payment",
                          "version": "1"
                        },
                        "types": {
                          "RoutedPayment": [
                            {
                              "name": "orderId",
                              "type": "string"
                            },
                            {
                              "name": "nonce",
                              "type": "bytes32"
                            },
                            {
                              "name": "fundingVenue",
                              "type": "string"
                            },
                            {
                              "name": "executionVenue",
                              "type": "string"
                            },
                            {
                              "name": "paymentMicros",
                              "type": "uint256"
                            },
                            {
                              "name": "expiresAt",
                              "type": "uint256"
                            }
                          ]
                        },
                        "primaryType": "RoutedPayment",
                        "message": {
                          "orderId": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                          "nonce": "0x3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c",
                          "fundingVenue": "hyperliquid",
                          "executionVenue": "polymarket",
                          "paymentMicros": "5511000",
                          "expiresAt": "1793296860"
                        }
                      }
                    }
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_order_id was already used with a different request, or the route moved while it was quoted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "client_order_id was already used with a different request, or the route moved while it was quoted"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Rejected by a key limit, VENUE_NOT_ALLOWED when the account does not allow the funding or the buying venue, or ROUTE_NOT_EXECUTABLE or LIMIT_BELOW_ROUTE_PRICE when no route can fill the whole quantity within the limit or the market is not listed on the venue Lean buys on. There is no fallback venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Routing is unavailable. FEATURE_DISABLED with details.reason ROUTING_DISABLED, LIVE_TRADING_DISABLED (live keys only), or TRADING_PAUSED with details.scope api_key or trading_account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "Routing is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/routed-orders/{id}/execute": {
      "post": {
        "operationId": "executeRoutedOrder",
        "summary": "Execute a routed order",
        "description": "Authorizes the payment of an order from POST /v1/routed-orders, with your signature over its `typed_data` or with Lean’s delegated signer, and starts the route. Call it before the payment expires.",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "authorization": {
                        "type": "string",
                        "enum": [
                          "signature"
                        ]
                      },
                      "payment_signature": {
                        "type": "string",
                        "pattern": "^0x[a-fA-F0-9]{130}$",
                        "description": "EIP-712 signature over `payment.typed_data`, by `payment.signer_address`."
                      },
                      "agent_approval_signature": {
                        "type": "string",
                        "pattern": "^0x[a-fA-F0-9]{130}$",
                        "description": "Signature over `payment.agent_approval`, when the payment carries one."
                      }
                    },
                    "required": [
                      "authorization",
                      "payment_signature"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "authorization": {
                        "type": "string",
                        "enum": [
                          "delegated"
                        ]
                      }
                    },
                    "required": [
                      "authorization"
                    ]
                  }
                ]
              },
              "example": {
                "authorization": "signature",
                "payment_signature": "0xababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The order once its payment is accepted, with payment null. A test order is filled; a live order stays pending while the router moves the payment. Sending the same authorization again returns the current order",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_order_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "title": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "outcome": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "api",
                                "app"
                              ]
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "limit",
                                "market"
                              ]
                            },
                            "time_in_force": {
                              "type": "string",
                              "enum": [
                                "gtc",
                                "ioc",
                                "fok",
                                "gtd"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "remaining_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Shares still working on the venues: the unfilled size of each live venue order. Zero once the order is final, since a canceled, expired or rejected remainder no longer works."
                            },
                            "limit_price": {
                              "type": "string"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Average price per share filled, size-weighted across the venue orders that filled, excluding fees. Null until every filled venue order has a price."
                            },
                            "notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "filled_notional_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "open",
                                "partially_filled",
                                "filled",
                                "canceled",
                                "rejected",
                                "expired",
                                "unconfirmed",
                                "needs_attention",
                                "cancel_requested"
                              ]
                            },
                            "venue_status": {
                              "type": "string",
                              "nullable": true
                            },
                            "venue_order_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "status_reason": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "message": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "code",
                                "message"
                              ]
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "limit_price": {
                                    "type": "string"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "open",
                                      "partially_filled",
                                      "filled",
                                      "canceled",
                                      "rejected",
                                      "expired",
                                      "unconfirmed",
                                      "needs_attention",
                                      "cancel_requested"
                                    ]
                                  },
                                  "venue_status": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "venue_order_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "status_reason": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "message": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "code",
                                      "message"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "filled_quantity",
                                  "limit_price",
                                  "avg_fill_price",
                                  "status",
                                  "venue_status",
                                  "venue_order_id",
                                  "cancel_requested_at",
                                  "status_reason"
                                ]
                              }
                            },
                            "post_only": {
                              "type": "boolean"
                            },
                            "replaces_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "replaced_by_order_id": {
                              "type": "string",
                              "nullable": true,
                              "format": "uuid"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "route": {
                              "type": "object",
                              "properties": {
                                "funding_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "execution_venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ]
                                },
                                "notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "costs": {
                                  "type": "object",
                                  "properties": {
                                    "rebalance_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "gas_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "activation_fee_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "network_cost_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "rebalance_fee_usd",
                                    "gas_usd",
                                    "activation_fee_usd",
                                    "network_cost_usd"
                                  ]
                                }
                              },
                              "required": [
                                "funding_venue",
                                "execution_venue",
                                "notional_usd",
                                "costs"
                              ]
                            },
                            "payment": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "hyperliquid_send_asset"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "HyperliquidSignTransaction"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            },
                                            "chainId": {
                                              "type": "number",
                                              "enum": [
                                                421614
                                              ]
                                            },
                                            "verifyingContract": {
                                              "type": "string",
                                              "enum": [
                                                "0x0000000000000000000000000000000000000000"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version",
                                            "chainId",
                                            "verifyingContract"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "properties": {
                                            "HyperliquidTransaction:SendAsset": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "hyperliquidChain"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "destination"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "sourceDex"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "destinationDex"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "token"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "amount"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "fromSubAccount"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "string"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "nonce"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint64"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 8,
                                              "maxItems": 8
                                            }
                                          },
                                          "required": [
                                            "HyperliquidTransaction:SendAsset"
                                          ]
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "HyperliquidTransaction:SendAsset"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "hyperliquidChain": {
                                              "type": "string",
                                              "enum": [
                                                "Mainnet"
                                              ]
                                            },
                                            "destination": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "sourceDex": {
                                              "type": "string"
                                            },
                                            "destinationDex": {
                                              "type": "string"
                                            },
                                            "token": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "amount": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$"
                                            },
                                            "fromSubAccount": {
                                              "type": "string"
                                            },
                                            "nonce": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            }
                                          },
                                          "required": [
                                            "hyperliquidChain",
                                            "destination",
                                            "sourceDex",
                                            "destinationDex",
                                            "token",
                                            "amount",
                                            "fromSubAccount",
                                            "nonce"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "polymarket_deposit_wallet_batch"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "DepositWallet"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            },
                                            "chainId": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "exclusiveMinimum": true
                                            },
                                            "verifyingContract": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version",
                                            "chainId",
                                            "verifyingContract"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "properties": {
                                            "Call": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "target"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "address"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "value"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "data"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "bytes"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 3,
                                              "maxItems": 3
                                            },
                                            "Batch": {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "wallet"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "address"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "nonce"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "deadline"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "uint256"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string",
                                                        "enum": [
                                                          "calls"
                                                        ]
                                                      },
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "Call[]"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                ]
                                              },
                                              "minItems": 4,
                                              "maxItems": 4
                                            }
                                          },
                                          "required": [
                                            "Call",
                                            "Batch"
                                          ]
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "Batch"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "wallet": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "nonce": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "deadline": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "calls": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "target": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]{40}$"
                                                  },
                                                  "value": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  },
                                                  "data": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]+$"
                                                  }
                                                },
                                                "required": [
                                                  "target",
                                                  "value",
                                                  "data"
                                                ]
                                              }
                                            }
                                          },
                                          "required": [
                                            "wallet",
                                            "nonce",
                                            "deadline",
                                            "calls"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    },
                                    "agent_approval": {
                                      "type": "object",
                                      "nullable": true,
                                      "properties": {
                                        "masterAddress": {
                                          "type": "string",
                                          "pattern": "^0x[a-fA-F0-9]{40}$"
                                        },
                                        "agentAddress": {
                                          "type": "string",
                                          "pattern": "^0x[a-fA-F0-9]{40}$"
                                        },
                                        "action": {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "approveAgent"
                                              ]
                                            },
                                            "hyperliquidChain": {
                                              "type": "string",
                                              "enum": [
                                                "Mainnet"
                                              ]
                                            },
                                            "signatureChainId": {
                                              "type": "string",
                                              "enum": [
                                                "0x66eee"
                                              ]
                                            },
                                            "agentAddress": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{40}$"
                                            },
                                            "agentName": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "nonce": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "maximum": 9007199254740991
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "hyperliquidChain",
                                            "signatureChainId",
                                            "agentAddress",
                                            "agentName",
                                            "nonce"
                                          ]
                                        },
                                        "typedData": {
                                          "type": "object",
                                          "properties": {
                                            "domain": {
                                              "type": "object",
                                              "properties": {
                                                "name": {
                                                  "type": "string",
                                                  "enum": [
                                                    "HyperliquidSignTransaction"
                                                  ]
                                                },
                                                "version": {
                                                  "type": "string",
                                                  "enum": [
                                                    "1"
                                                  ]
                                                },
                                                "chainId": {
                                                  "type": "number",
                                                  "enum": [
                                                    421614
                                                  ]
                                                },
                                                "verifyingContract": {
                                                  "type": "string",
                                                  "enum": [
                                                    "0x0000000000000000000000000000000000000000"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "name",
                                                "version",
                                                "chainId",
                                                "verifyingContract"
                                              ]
                                            },
                                            "types": {
                                              "type": "object",
                                              "properties": {
                                                "HyperliquidTransaction:ApproveAgent": {
                                                  "type": "array",
                                                  "items": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "hyperliquidChain"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "string"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "agentAddress"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "address"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "agentName"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "string"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "name": {
                                                            "type": "string",
                                                            "enum": [
                                                              "nonce"
                                                            ]
                                                          },
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "uint64"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "name",
                                                          "type"
                                                        ]
                                                      }
                                                    ]
                                                  },
                                                  "minItems": 4,
                                                  "maxItems": 4
                                                }
                                              },
                                              "required": [
                                                "HyperliquidTransaction:ApproveAgent"
                                              ]
                                            },
                                            "primaryType": {
                                              "type": "string",
                                              "enum": [
                                                "HyperliquidTransaction:ApproveAgent"
                                              ]
                                            },
                                            "message": {
                                              "type": "object",
                                              "properties": {
                                                "hyperliquidChain": {
                                                  "type": "string",
                                                  "enum": [
                                                    "Mainnet"
                                                  ]
                                                },
                                                "agentAddress": {
                                                  "type": "string",
                                                  "pattern": "^0x[a-fA-F0-9]{40}$"
                                                },
                                                "agentName": {
                                                  "type": "string",
                                                  "minLength": 1
                                                },
                                                "nonce": {
                                                  "type": "integer",
                                                  "minimum": 0,
                                                  "maximum": 9007199254740991
                                                }
                                              },
                                              "required": [
                                                "hyperliquidChain",
                                                "agentAddress",
                                                "agentName",
                                                "nonce"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "domain",
                                            "types",
                                            "primaryType",
                                            "message"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "masterAddress",
                                        "agentAddress",
                                        "action",
                                        "typedData"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data",
                                    "agent_approval"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "scheme": {
                                      "type": "string",
                                      "enum": [
                                        "lean_test_payment"
                                      ]
                                    },
                                    "signer_address": {
                                      "type": "string",
                                      "pattern": "^0x[a-fA-F0-9]{40}$"
                                    },
                                    "typed_data": {
                                      "type": "object",
                                      "properties": {
                                        "domain": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "Lean API test routed payment"
                                              ]
                                            },
                                            "version": {
                                              "type": "string",
                                              "enum": [
                                                "1"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "name",
                                            "version"
                                          ]
                                        },
                                        "types": {
                                          "type": "object",
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "name": {
                                                  "type": "string"
                                                },
                                                "type": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "name",
                                                "type"
                                              ]
                                            }
                                          }
                                        },
                                        "primaryType": {
                                          "type": "string",
                                          "enum": [
                                            "RoutedPayment"
                                          ]
                                        },
                                        "message": {
                                          "type": "object",
                                          "properties": {
                                            "orderId": {
                                              "type": "string",
                                              "format": "uuid"
                                            },
                                            "nonce": {
                                              "type": "string",
                                              "pattern": "^0x[a-fA-F0-9]{64}$"
                                            },
                                            "fundingVenue": {
                                              "type": "string",
                                              "enum": [
                                                "polymarket",
                                                "hyperliquid"
                                              ]
                                            },
                                            "executionVenue": {
                                              "type": "string",
                                              "enum": [
                                                "polymarket",
                                                "hyperliquid"
                                              ]
                                            },
                                            "paymentMicros": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            },
                                            "expiresAt": {
                                              "type": "string",
                                              "pattern": "^\\d+$"
                                            }
                                          },
                                          "required": [
                                            "orderId",
                                            "nonce",
                                            "fundingVenue",
                                            "executionVenue",
                                            "paymentMicros",
                                            "expiresAt"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "domain",
                                        "types",
                                        "primaryType",
                                        "message"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "scheme",
                                    "signer_address",
                                    "typed_data"
                                  ]
                                },
                                {
                                  "nullable": true
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "client_order_id",
                            "market_id",
                            "title",
                            "outcome",
                            "source",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "type",
                            "time_in_force",
                            "expires_at",
                            "quantity",
                            "filled_quantity",
                            "remaining_quantity",
                            "limit_price",
                            "avg_fill_price",
                            "notional_usd",
                            "filled_notional_usd",
                            "status",
                            "venue_status",
                            "venue_order_id",
                            "status_reason",
                            "legs",
                            "post_only",
                            "replaces_order_id",
                            "replaced_by_order_id",
                            "created_at",
                            "updated_at",
                            "livemode",
                            "route",
                            "payment"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1",
                    "client_order_id": "bot-0001",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                    "outcome": "DEN",
                    "source": "api",
                    "venue": null,
                    "ticker": null,
                    "side": null,
                    "action": "buy",
                    "type": "limit",
                    "time_in_force": "gtc",
                    "expires_at": null,
                    "quantity": "10",
                    "filled_quantity": "10",
                    "remaining_quantity": "0",
                    "limit_price": "0.55",
                    "avg_fill_price": "0.55",
                    "notional_usd": "5.511",
                    "filled_notional_usd": "5.5",
                    "status": "filled",
                    "venue_status": null,
                    "venue_order_id": null,
                    "status_reason": null,
                    "legs": [],
                    "post_only": false,
                    "replaces_order_id": null,
                    "replaced_by_order_id": null,
                    "created_at": "2026-10-29T18:00:00.000Z",
                    "updated_at": "2026-10-29T18:00:00.000Z",
                    "livemode": false,
                    "route": {
                      "funding_venue": "hyperliquid",
                      "execution_venue": "polymarket",
                      "notional_usd": "5.511",
                      "costs": {
                        "rebalance_fee_usd": "0.011",
                        "gas_usd": "0",
                        "activation_fee_usd": "0",
                        "network_cost_usd": "0.011"
                      }
                    },
                    "payment": null
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The payment signature is invalid (INVALID_SIGNATURE) or not by the signer (SIGNER_MISMATCH)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the route scope, or delegated authorization on an account that has not enabled trading in the Lean app (ACCOUNT_NOT_DELEGATED)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No routed order with this id for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No routed order with this id for this key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "QUOTE_EXPIRED, ROUTE_MOVED, ORDER_NOT_PENDING, PAYMENT_ALREADY_AUTHORIZED when the order was already authorized differently, PAYMENT_MISMATCH when delegated authorization finds a stored payment that differs from the route, or AGENT_APPROVAL_REQUIRED when a delegated instant bridge still needs the Hyperliquid agent approved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Rejected by a key or account limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Rejected by a key or account limit"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "FEATURE_DISABLED with details.reason ROUTING_DISABLED, TRADING_PAUSED, LIVE_TRADING_DISABLED, or DELEGATED_ROUTE_SIGNING_DISABLED when server signing is switched off; UPSTREAM_ERROR when the payment could not be signed, in which case nothing was paid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rfqs": {
      "post": {
        "operationId": "createComboRfq",
        "summary": "Create and quote a multi-leg combo RFQ",
        "description": "Create a multi-leg combo on Kalshi or Polymarket US and request maker quotes for any 2 to 10 legs (elections, macro, sports, or cross-category). Waits up to `wait_seconds` for initial quotes. Set `quote_only: true` to automatically delete/cancel the RFQ on the venue after capturing quotes.",
        "tags": [
          "RFQs"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_request_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Unique per API key. Replaying returns the original RFQ."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket_us"
                    ],
                    "description": "Combo RFQ venue: kalshi or polymarket_us."
                  },
                  "legs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "ticker": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "Venue market ticker (e.g. a Kalshi ticker or pmus:... slug)."
                        },
                        "event_ticker": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "Optional event ticker; looked up from Lean metadata when omitted."
                        },
                        "side": {
                          "type": "string",
                          "enum": [
                            "yes",
                            "no"
                          ],
                          "description": "Outcome side for this leg: yes or no."
                        }
                      },
                      "required": [
                        "ticker",
                        "side"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 2,
                    "maxItems": 10,
                    "description": "Between 2 and 10 combo legs (works for sports, elections, macro, and cross-category combos)."
                  },
                  "budget_usd": {
                    "type": "string",
                    "pattern": "^\\d{1,4}(\\.\\d{1,2})?$",
                    "description": "Target combo spend in USD between $1 and $1,000 (up to 2 decimal places, e.g. \"250\")."
                  },
                  "collection_ticker": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Optional Kalshi MVE collection ticker (e.g. KXMVECROSSCATEGORY-R or KXMVESPORTSMULTIGAMEEXTENDED-R). Auto-inferred when omitted."
                  },
                  "wait_seconds": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10,
                    "default": 3,
                    "description": "Seconds to wait for initial maker quotes before returning (0 to 10, default 3)."
                  },
                  "quote_only": {
                    "type": "boolean",
                    "default": false,
                    "description": "When true, cancels/deletes the RFQ on the venue immediately after collecting initial quotes so quote-only research never leaves open RFQs."
                  }
                },
                "required": [
                  "client_request_id",
                  "venue",
                  "legs",
                  "budget_usd"
                ],
                "additionalProperties": false
              },
              "example": "Combo legs, venue, budget, and quote options"
            }
          }
        },
        "responses": {
          "200": {
            "description": "RFQ status, combo ticker, and any initial maker quotes",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_request_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket_us"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "resolving",
                                "pending",
                                "quoted",
                                "no_quote",
                                "canceled",
                                "unsupported_combo",
                                "credentials_required",
                                "error",
                                "failed"
                              ]
                            },
                            "venue_request_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_ticker": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_lean_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "combo_venue_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  }
                                },
                                "required": [
                                  "ticker",
                                  "event_ticker",
                                  "side"
                                ]
                              }
                            },
                            "budget_usd": {
                              "type": "string",
                              "pattern": "^\\d{1,4}(\\.\\d{1,2})?$"
                            },
                            "quote_only": {
                              "type": "boolean"
                            },
                            "quotes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "price_usd": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "received_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "side",
                                  "price_usd",
                                  "quantity",
                                  "payout_usd",
                                  "received_at"
                                ]
                              }
                            },
                            "acceptance": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "order_submitted",
                                    "accepted",
                                    "acceptance_unconfirmed",
                                    "rejected"
                                  ]
                                },
                                "quote_id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "order_id": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "reason": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "status",
                                "quote_id",
                                "order_id",
                                "reason"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_request_id",
                            "venue",
                            "status",
                            "venue_request_id",
                            "combo_ticker",
                            "combo_lean_url",
                            "combo_venue_url",
                            "legs",
                            "budget_usd",
                            "quote_only",
                            "quotes",
                            "acceptance",
                            "reason",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_request_id already used with different parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "client_request_id already used with different parameters"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Real RFQs require a live API key or valid legs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Real RFQs require a live API key or valid legs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rfqs/{id}": {
      "get": {
        "operationId": "getComboRfq",
        "summary": "Refresh a combo RFQ and its quotes",
        "description": "Read fresh maker quotes or acceptance status for an existing combo RFQ.",
        "tags": [
          "RFQs"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Lean RFQ id returned by POST /v1/rfqs."
            },
            "required": true,
            "description": "Lean RFQ id returned by POST /v1/rfqs.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Current RFQ quotes or acceptance status",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_request_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket_us"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "resolving",
                                "pending",
                                "quoted",
                                "no_quote",
                                "canceled",
                                "unsupported_combo",
                                "credentials_required",
                                "error",
                                "failed"
                              ]
                            },
                            "venue_request_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_ticker": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_lean_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "combo_venue_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  }
                                },
                                "required": [
                                  "ticker",
                                  "event_ticker",
                                  "side"
                                ]
                              }
                            },
                            "budget_usd": {
                              "type": "string",
                              "pattern": "^\\d{1,4}(\\.\\d{1,2})?$"
                            },
                            "quote_only": {
                              "type": "boolean"
                            },
                            "quotes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "price_usd": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "received_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "side",
                                  "price_usd",
                                  "quantity",
                                  "payout_usd",
                                  "received_at"
                                ]
                              }
                            },
                            "acceptance": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "order_submitted",
                                    "accepted",
                                    "acceptance_unconfirmed",
                                    "rejected"
                                  ]
                                },
                                "quote_id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "order_id": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "reason": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "status",
                                "quote_id",
                                "order_id",
                                "reason"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_request_id",
                            "venue",
                            "status",
                            "venue_request_id",
                            "combo_ticker",
                            "combo_lean_url",
                            "combo_venue_url",
                            "legs",
                            "budget_usd",
                            "quote_only",
                            "quotes",
                            "acceptance",
                            "reason",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "RFQ not found or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "RFQ not found or expired"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "cancelComboRfq",
        "summary": "Cancel an open combo RFQ",
        "description": "Cancel/delete an open combo RFQ on Kalshi or Polymarket US.",
        "tags": [
          "RFQs"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Lean RFQ id returned by POST /v1/rfqs."
            },
            "required": true,
            "description": "Lean RFQ id returned by POST /v1/rfqs.",
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Canceled RFQ status",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_request_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket_us"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "resolving",
                                "pending",
                                "quoted",
                                "no_quote",
                                "canceled",
                                "unsupported_combo",
                                "credentials_required",
                                "error",
                                "failed"
                              ]
                            },
                            "venue_request_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_ticker": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_lean_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "combo_venue_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  }
                                },
                                "required": [
                                  "ticker",
                                  "event_ticker",
                                  "side"
                                ]
                              }
                            },
                            "budget_usd": {
                              "type": "string",
                              "pattern": "^\\d{1,4}(\\.\\d{1,2})?$"
                            },
                            "quote_only": {
                              "type": "boolean"
                            },
                            "quotes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "price_usd": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "received_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "side",
                                  "price_usd",
                                  "quantity",
                                  "payout_usd",
                                  "received_at"
                                ]
                              }
                            },
                            "acceptance": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "order_submitted",
                                    "accepted",
                                    "acceptance_unconfirmed",
                                    "rejected"
                                  ]
                                },
                                "quote_id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "order_id": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "reason": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "status",
                                "quote_id",
                                "order_id",
                                "reason"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_request_id",
                            "venue",
                            "status",
                            "venue_request_id",
                            "combo_ticker",
                            "combo_lean_url",
                            "combo_venue_url",
                            "legs",
                            "budget_usd",
                            "quote_only",
                            "quotes",
                            "acceptance",
                            "reason",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "RFQ not found or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "RFQ not found or expired"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rfqs/{id}/accept": {
      "post": {
        "operationId": "acceptComboRfq",
        "summary": "Accept a combo RFQ quote",
        "description": "Accept a specific maker quote on an open combo RFQ by quote_id and exact price_usd. Places a real combo order on a live key.",
        "tags": [
          "RFQs"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Lean RFQ id returned by POST /v1/rfqs."
            },
            "required": true,
            "description": "Lean RFQ id returned by POST /v1/rfqs.",
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "The quote id from the RFQ quotes array."
                  },
                  "price_usd": {
                    "type": "string",
                    "description": "The exact price_usd of the quote being accepted; refused if the maker moved the price."
                  }
                },
                "required": [
                  "quote_id",
                  "price_usd"
                ],
                "additionalProperties": false
              },
              "example": "Quote id and exact price_usd to accept"
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acceptance result with order id or rejection reason",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_request_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket_us"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "resolving",
                                "pending",
                                "quoted",
                                "no_quote",
                                "canceled",
                                "unsupported_combo",
                                "credentials_required",
                                "error",
                                "failed"
                              ]
                            },
                            "venue_request_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_ticker": {
                              "type": "string",
                              "nullable": true
                            },
                            "combo_lean_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "combo_venue_url": {
                              "type": "string",
                              "nullable": true,
                              "format": "uri"
                            },
                            "legs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  }
                                },
                                "required": [
                                  "ticker",
                                  "event_ticker",
                                  "side"
                                ]
                              }
                            },
                            "budget_usd": {
                              "type": "string",
                              "pattern": "^\\d{1,4}(\\.\\d{1,2})?$"
                            },
                            "quote_only": {
                              "type": "boolean"
                            },
                            "quotes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "price_usd": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "received_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "id",
                                  "side",
                                  "price_usd",
                                  "quantity",
                                  "payout_usd",
                                  "received_at"
                                ]
                              }
                            },
                            "acceptance": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "order_submitted",
                                    "accepted",
                                    "acceptance_unconfirmed",
                                    "rejected"
                                  ]
                                },
                                "quote_id": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "order_id": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "reason": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "status",
                                "quote_id",
                                "order_id",
                                "reason"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_request_id",
                            "venue",
                            "status",
                            "venue_request_id",
                            "combo_ticker",
                            "combo_lean_url",
                            "combo_venue_url",
                            "legs",
                            "budget_usd",
                            "quote_only",
                            "quotes",
                            "acceptance",
                            "reason",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "RFQ not found or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "RFQ not found or expired"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Accepting combo quotes requires a live API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Accepting combo quotes requires a live API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/balances": {
      "get": {
        "operationId": "getBalances",
        "summary": "Get balances",
        "description": "Cash held by this key’s trading account on each venue, in the collateral the venue trades in. Kalshi and Polymarket US cash belongs to the user, so every trading account of the user reads the same balance there. A venue that could not be read is listed in `unavailable`.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Cash balances of the key’s trading account per venue",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "balances": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "currency": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "total_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "available_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "polymarket_us_details": {
                                    "type": "object",
                                    "properties": {
                                      "buying_power_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "asset_available_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "open_orders_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "unsettled_funds_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      }
                                    },
                                    "required": [
                                      "buying_power_usd",
                                      "asset_available_usd",
                                      "open_orders_usd",
                                      "unsettled_funds_usd"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "currency",
                                  "total_usd",
                                  "available_usd"
                                ]
                              }
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "balances",
                            "unavailable",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Balances": {
                    "summary": "Cash per venue",
                    "value": {
                      "success": true,
                      "data": {
                        "balances": [
                          {
                            "venue": "hyperliquid",
                            "currency": "USDC",
                            "total_usd": "250",
                            "available_usd": "245.5"
                          },
                          {
                            "venue": "polymarket",
                            "currency": "USDC",
                            "total_usd": "100",
                            "available_usd": "100"
                          }
                        ],
                        "unavailable": [],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  },
                  "Test key": {
                    "summary": "Simulated cash: each venue starts at 10,000",
                    "value": {
                      "success": true,
                      "data": {
                        "balances": [
                          {
                            "venue": "polymarket",
                            "currency": "pUSD",
                            "total_usd": "10000",
                            "available_usd": "10000"
                          },
                          {
                            "venue": "hyperliquid",
                            "currency": "USDC",
                            "total_usd": "10000",
                            "available_usd": "10000"
                          }
                        ],
                        "unavailable": [],
                        "livemode": false
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  },
                  "Venue unavailable": {
                    "summary": "One venue could not be read; do not treat it as zero",
                    "value": {
                      "success": true,
                      "data": {
                        "balances": [
                          {
                            "venue": "hyperliquid",
                            "currency": "USDC",
                            "total_usd": "250",
                            "available_usd": "245.5"
                          }
                        ],
                        "unavailable": [
                          "polymarket"
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "f6d3a0b9-4e2c-4718-a5f9-0c8e1b7d3a54"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/positions": {
      "get": {
        "operationId": "getPositions",
        "summary": "List positions",
        "description": "Shares held by this key’s trading account on each venue, with average price, mark price and unrealized profit and loss. Each holding names its `market_id`, `title` and `outcome`, or null when no market is listed for it. Filter by venue, market or text in the market title. Kalshi and Polymarket US accounts belong to the user rather than one trading account, so every trading account of the user lists the same holdings there. A venue that could not be read is listed in `unavailable`.",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only holdings on this venue. Other venues are not read, so only this one can be `unavailable`."
            },
            "required": false,
            "description": "Only holdings on this venue. Other venues are not read, so only this one can be `unavailable`.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Only holdings on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead."
            },
            "required": false,
            "description": "Only holdings on this market. A market id from GET /markets, or a venue symbol that names one market: a Polymarket token id, a Hyperliquid book coin (`#…`, written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`, `pmus:…` or a Kalshi market ticker) that lists only this outcome. A symbol that names more than one market, such as a Polymarket condition id, is refused with 400; use the token id or the market id instead.",
            "name": "market_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Text, in any letter case, found in the title or outcome of the market the holding trades. A holding with no title never matches."
            },
            "required": false,
            "description": "Text, in any letter case, found in the title or outcome of the market the holding trades. A holding with no title never matches.",
            "name": "search",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Open positions of the key’s trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "positions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "average_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Cost basis per share, fees included, so it can exceed 1; null when the venue reports no cost."
                                  },
                                  "cost_basis_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "What the held shares cost, fees included, as the Lean portfolio records it; for a holding Lean has no record of, the venue’s own entry value. Null when neither is known."
                                  },
                                  "mark_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Price per share the holding is valued at: its settlement payout once its market resolves, else the average a sell of the whole quantity would fill at in the current book, else the book’s size-weighted midpoint when the spread is tight, else the last price the venue or Lean reported. Null when none is known, and the holding is then valued at cost; test-mode positions without a mark read null."
                                  },
                                  "unrealized_pnl_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Value at the mark price, or at cost without one, less the cost basis; null when the cost is unknown, and test-mode positions without a mark read null."
                                  },
                                  "redeemable": {
                                    "type": "boolean",
                                    "description": "Its market has resolved to a payout and the venue pays the holding out only once it is redeemed, with POST /v1/positions/redeem. A losing holding pays nothing and is never redeemable. Only Polymarket holdings are ever redeemable; Kalshi, Polymarket US, Hyperliquid and Lighter pay resolved holdings out on their own."
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "What the whole holding pays once its market resolves: 1 per share on the winning side, 0 on the losing side, 0.5 when the market is void. Null while the market is open."
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri",
                                    "description": "Direct Lean web trade link for this held position."
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri",
                                    "description": "External venue page URL for this held position, when known."
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Event ticker of the held market, when known."
                                  },
                                  "end_date": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time",
                                    "description": "Scheduled close time of the held market, when known."
                                  },
                                  "settled": {
                                    "type": "boolean",
                                    "description": "true when the market has resolved; the row’s unrealized amount is its settlement payout minus cost and is excluded from account unrealized totals"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "average_price",
                                  "cost_basis_usd",
                                  "mark_price",
                                  "unrealized_pnl_usd",
                                  "redeemable",
                                  "payout_usd",
                                  "market_id",
                                  "title",
                                  "outcome",
                                  "lean_url",
                                  "venue_url",
                                  "event_ticker",
                                  "end_date",
                                  "settled"
                                ]
                              }
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "positions",
                            "unavailable",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Positions": {
                    "summary": "Open positions",
                    "value": {
                      "success": true,
                      "data": {
                        "positions": [
                          {
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "average_price": "0.47",
                            "mark_price": "0.52",
                            "unrealized_pnl_usd": "0.25",
                            "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                            "outcome": "DEN"
                          }
                        ],
                        "unavailable": [],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  },
                  "Test key": {
                    "summary": "Simulated shares, marked at the venue's best bid",
                    "value": {
                      "success": true,
                      "data": {
                        "positions": [
                          {
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "venue": "hyperliquid",
                            "ticker": "<venue ticker>",
                            "side": "yes",
                            "quantity": "5",
                            "average_price": "0.5",
                            "mark_price": "0.52",
                            "unrealized_pnl_usd": "0.1",
                            "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                            "outcome": "DEN"
                          }
                        ],
                        "unavailable": [],
                        "livemode": false
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  },
                  "Venue unavailable": {
                    "summary": "One venue could not be read; do not treat it as empty",
                    "value": {
                      "success": true,
                      "data": {
                        "positions": [],
                        "unavailable": [
                          "hyperliquid"
                        ],
                        "livemode": true
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Unknown key": {
                    "summary": "Unknown, expired or revoked key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid, expired or revoked API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  },
                  "Missing key": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing scope": {
                    "summary": "The key lacks the read scope",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "This API key lacks the read scope"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Rate limited": {
                    "summary": "Over 5 requests a second; wait for Retry-After",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "RATE_LIMITED",
                        "message": "Too many requests for this API key"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "a3f8c2e7-0d4b-4691-8b6a-5e1c9f07d2b8"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/kalshi/subaccounts": {
      "get": {
        "operationId": "listKalshiSubaccountsV1",
        "summary": "List Kalshi subaccounts and balances",
        "description": "Requires read scope. The Kalshi connection belongs to the key’s user and is shared across their trading accounts. Lists the primary and numbered subaccounts, including hidden ones. Basic-tier accounts return eligible=false and an empty list. Test keys return an empty list with no active subaccount.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Kalshi subaccount balances and linked trading accounts",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "livemode": {
                              "type": "boolean"
                            },
                            "eligible": {
                              "type": "boolean",
                              "description": "Whether the connected Kalshi account has access to subaccounts."
                            },
                            "active_subaccount": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 63,
                              "description": "The selected Kalshi subaccount. Null in test mode."
                            },
                            "subaccounts": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "subaccount": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 63
                                  },
                                  "label": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "balance_cents": {
                                    "type": "integer"
                                  },
                                  "balance_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "hidden": {
                                    "type": "boolean"
                                  },
                                  "trading_account_id": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time",
                                    "description": "Latest balance update across the subaccount’s exchange balances. Null when Kalshi provides no timestamp."
                                  }
                                },
                                "required": [
                                  "subaccount",
                                  "label",
                                  "balance_cents",
                                  "balance_usd",
                                  "hidden",
                                  "trading_account_id",
                                  "updated_at"
                                ]
                              }
                            }
                          },
                          "required": [
                            "livemode",
                            "eligible",
                            "active_subaccount",
                            "subaccounts"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No connected Kalshi account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No connected Kalshi account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Kalshi is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Kalshi is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/analytics": {
      "get": {
        "operationId": "getAccountAnalytics",
        "summary": "Get account performance, Brier score, Sharpe, volume and fees",
        "description": "Comprehensive trading analytics across connected venues: contract & notional volume, taker vs maker split, fees paid, monthly/daily history, entry-price Brier score across resolved markets, annualized Sharpe ratio, max drawdown, win rate, and biggest wins and losses with Lean trade links.",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only include fills, positions, and snapshots on this venue."
            },
            "required": false,
            "description": "Only include fills, positions, and snapshots on this venue.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Include records at or after this ISO 8601 time."
            },
            "required": false,
            "description": "Include records at or after this ISO 8601 time.",
            "name": "start",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Include records before this ISO 8601 time."
            },
            "required": false,
            "description": "Include records before this ISO 8601 time.",
            "name": "end",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "day",
                "month"
              ],
              "default": "month",
              "description": "Time bucket for volume/fee history: day or month (default month)."
            },
            "required": false,
            "description": "Time bucket for volume/fee history: day or month (default month).",
            "name": "bucket",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Trading performance, Brier score, Sharpe, volume and fee breakdown",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "fill_count": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "total_contracts": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "total_notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "taker_notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "maker_notional_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "taker_share": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^-?\\d+(?:\\.\\d+)?$"
                            },
                            "total_fees_usd": {
                              "type": "string",
                              "pattern": "^-?\\d+(?:\\.\\d+)?$",
                              "description": "Known fees paid in USD across fills with reported venue fees (lower bound when fees_complete is false)."
                            },
                            "unknown_fee_fill_count": {
                              "type": "integer",
                              "minimum": 0,
                              "description": "Count of fills across all venues whose venue fee was not reported (NULL)."
                            },
                            "fees_complete": {
                              "type": "boolean",
                              "description": "True when every fill in the selected window has a reported fee (unknown_fee_fill_count === 0)."
                            },
                            "by_venue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "fill_count": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "taker_fill_count": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "maker_fill_count": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "contracts": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "taker_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "maker_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "taker_share": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "fees_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Known fees paid in USD across fills with reported venue fees (lower bound when fees_complete is false)."
                                  },
                                  "unknown_fee_fill_count": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Count of fills in this venue bucket whose venue fee was not reported (NULL)."
                                  },
                                  "fees_complete": {
                                    "type": "boolean",
                                    "description": "True when every fill in this venue bucket has a reported fee (unknown_fee_fill_count === 0)."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "fill_count",
                                  "taker_fill_count",
                                  "maker_fill_count",
                                  "contracts",
                                  "notional_usd",
                                  "taker_notional_usd",
                                  "maker_notional_usd",
                                  "taker_share",
                                  "fees_usd",
                                  "unknown_fee_fill_count",
                                  "fees_complete"
                                ]
                              }
                            },
                            "by_period": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "period": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "fill_count": {
                                    "type": "integer",
                                    "minimum": 0
                                  },
                                  "contracts": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "taker_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "maker_notional_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "fees_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Known fees paid in USD across fills with reported venue fees in this period."
                                  },
                                  "unknown_fee_fill_count": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Count of fills in this period whose venue fee was not reported (NULL)."
                                  },
                                  "fees_complete": {
                                    "type": "boolean",
                                    "description": "True when every fill in this period has a reported fee (unknown_fee_fill_count === 0)."
                                  }
                                },
                                "required": [
                                  "period",
                                  "fill_count",
                                  "contracts",
                                  "notional_usd",
                                  "taker_notional_usd",
                                  "maker_notional_usd",
                                  "fees_usd",
                                  "unknown_fee_fill_count",
                                  "fees_complete"
                                ]
                              }
                            },
                            "performance": {
                              "type": "object",
                              "properties": {
                                "settled_markets": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "settled_events": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "win_rate": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                },
                                "entry_price_brier": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Entry-price Brier proxy across resolved positions (mean squared difference between average entry price and outcome). Lower is better."
                                },
                                "entry_price_brier_by_event": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Equal-weighted event-level entry-price Brier proxy across resolved event groups."
                                },
                                "sharpe_annualized": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                  "description": "Annualized Sharpe ratio computed across every UTC calendar day from the first to last snapshot day (0 delta on quiet days, scaled by sqrt(365)) when at least 5 active days exist."
                                },
                                "max_drawdown_usd": {
                                  "type": "string",
                                  "nullable": true,
                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                  "description": "Peak-to-trough maximum drawdown in USD across daily cumulative PnL snapshots."
                                },
                                "active_days": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "settled_markets",
                                "settled_events",
                                "win_rate",
                                "entry_price_brier",
                                "entry_price_brier_by_event",
                                "sharpe_annualized",
                                "max_drawdown_usd",
                                "active_days"
                              ]
                            },
                            "biggest_wins": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "realized_pnl_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "entry_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "result": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "event_ticker",
                                  "title",
                                  "side",
                                  "realized_pnl_usd",
                                  "entry_price",
                                  "result",
                                  "lean_url",
                                  "venue_url"
                                ]
                              },
                              "description": "Top winning resolved positions closed in [start, end), reporting whole-position realized PnL (not per-exit lot attribution)."
                            },
                            "biggest_losses": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "event_ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "realized_pnl_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "entry_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "result": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "event_ticker",
                                  "title",
                                  "side",
                                  "realized_pnl_usd",
                                  "entry_price",
                                  "result",
                                  "lean_url",
                                  "venue_url"
                                ]
                              },
                              "description": "Top losing resolved positions closed in [start, end), reporting whole-position realized PnL (not per-exit lot attribution)."
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "fill_count",
                            "total_contracts",
                            "total_notional_usd",
                            "taker_notional_usd",
                            "maker_notional_usd",
                            "taker_share",
                            "total_fees_usd",
                            "unknown_fee_fill_count",
                            "fees_complete",
                            "by_venue",
                            "by_period",
                            "performance",
                            "biggest_wins",
                            "biggest_losses",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rewards": {
      "get": {
        "operationId": "getRewards",
        "summary": "Get liquidity reward programs and account earnings",
        "description": "Read active market liquidity reward programs (Kalshi, Polymarket, Polymarket US) for requested tickers, plus pending and paid Polymarket US account liquidity reward earnings.",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only market reward programs on this venue."
            },
            "required": false,
            "description": "Only market reward programs on this venue.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Comma-separated venue tickers to look up active liquidity reward programs for (up to 50)."
            },
            "required": false,
            "description": "Comma-separated venue tickers to look up active liquidity reward programs for (up to 50).",
            "name": "tickers",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "When `\"true\"` (default) on a live key, also fetch the account’s pending and paid Polymarket US liquidity reward earnings. Pass `\"false\"` to skip."
            },
            "required": false,
            "description": "When `\"true\"` (default) on a live key, also fetch the account’s pending and paid Polymarket US liquidity reward earnings. Pass `\"false\"` to skip.",
            "name": "include_earnings",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Market liquidity reward programs and account pending/paid reward earnings",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "market_programs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "lean_url": {
                                    "type": "string",
                                    "format": "uri"
                                  },
                                  "venue_url": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "uri"
                                  },
                                  "daily_rate_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "max_spread": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "min_size": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "end_date": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "lean_url",
                                  "venue_url",
                                  "daily_rate_usd",
                                  "max_spread",
                                  "min_size",
                                  "end_date"
                                ]
                              }
                            },
                            "account_earnings": {
                              "type": "object",
                              "properties": {
                                "pending_total_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "paid_total_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "items": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid",
                                          "lighter"
                                        ]
                                      },
                                      "market_slug": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "lean_url": {
                                        "type": "string",
                                        "format": "uri"
                                      },
                                      "venue_url": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "uri"
                                      },
                                      "date": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "reward_usd": {
                                        "type": "string",
                                        "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                      },
                                      "program_type": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "status": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "market_slug",
                                      "ticker",
                                      "lean_url",
                                      "venue_url",
                                      "date",
                                      "reward_usd",
                                      "program_type",
                                      "status"
                                    ]
                                  }
                                },
                                "unavailable_reason": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "pending_total_usd",
                                "paid_total_usd",
                                "items",
                                "unavailable_reason"
                              ]
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_programs",
                            "account_earnings",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/positions/redeem": {
      "post": {
        "operationId": "redeemPositions",
        "summary": "Redeem resolved positions",
        "description": "Pays out every holding GET /positions marks redeemable, or only those on market_id, as cash on the venue. A Polymarket holding of a resolved market stays a token until it is redeemed; Kalshi, Polymarket US and Hyperliquid pay resolved holdings out on their own and never need this. The response lists each holding redeemed with its payout, and is empty when nothing was redeemable. A live redeem needs trading enabled for the account in the Lean app and is submitted once, in one transaction for every holding: it is settled once the venue confirms it, submitted while it is on its way, or failed with failure_reason when the venue refused it. A test redeem moves nothing, settles at once, removes the holdings from the simulated positions and adds their payout to the simulated cash until test mode is reset.",
        "tags": [
          "Positions"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "Only redeem holdings on this market. A Polymarket token id or condition id redeems that one listing; a Lean market id redeems every Polymarket listing of the market. Without it, every redeemable holding of the account is redeemed."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The holdings redeemed",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "redeemed": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "The shares redeemed."
                                  },
                                  "payout_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "What the shares pay: 1 per share on the winning side, 0 on the losing side, 0.5 when the market is void. 0 when status is failed."
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "settled",
                                      "submitted",
                                      "failed"
                                    ],
                                    "description": "settled once the venue has paid out, submitted while the payout is on its way and may still fail, failed when the venue refused it and nothing was paid."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "market_id",
                                  "title",
                                  "outcome",
                                  "quantity",
                                  "payout_usd",
                                  "status"
                                ]
                              },
                              "description": "Every holding redeemed, with its payout. Empty when nothing was redeemable."
                            },
                            "transaction_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "description": "The venue’s id for the transaction that pays out. Null in test mode, for a Hyperliquid merge, and when the venue never accepted it."
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why a failed payout paid nothing. Null unless status is failed."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "redeemed",
                            "transaction_id",
                            "failure_reason",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "redeemed": [
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "outcome": "DEN",
                        "quantity": "40",
                        "payout_usd": "40",
                        "status": "settled"
                      }
                    ],
                    "transaction_id": "0198f0d2-7c4e-7a51-9b3d-2e6f8a1c4d70",
                    "failure_reason": null,
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid, or market_id names a listing on a venue other than Polymarket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The request is invalid, or market_id names a listing on a venue other than Polymarket"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or details.reason is ACCOUNT_NOT_DELEGATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "market_id names no market",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "market_id names no market"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket wallet is not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The Polymarket wallet is not set up"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is VENUE_NOT_ALLOWED: the account may not trade Polymarket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or the venue is unavailable and nothing was submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/positions/merge": {
      "post": {
        "operationId": "mergePositions",
        "summary": "Merge YES and NO shares",
        "description": "Turns every pair of one YES share and one NO share the account holds on market_id at venue back into 1 of cash per pair, without trading. Only Polymarket and Hyperliquid merge. An account without both sides is refused with details.reason NOTHING_TO_MERGE. A live merge needs trading enabled for the account in the Lean app and is submitted once: it is settled once the venue confirms it, submitted while it is on its way, or failed with failure_reason when the venue refused it. A test merge leaves shares held for a resting sell alone, moves nothing, settles at once, removes the pairs from the simulated positions and adds their proceeds to the simulated cash until test mode is reset.",
        "tags": [
          "Positions"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "The market whose YES and NO shares are merged. A venue symbol, such as a Polymarket token id or a Hyperliquid book coin, merges that one listing. A Lean market id works when the market has one listing on venue."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "description": "The venue whose shares are merged. Kalshi and Polymarket US have no merge."
                  }
                },
                "required": [
                  "market_id",
                  "venue"
                ],
                "additionalProperties": false
              },
              "example": {
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "venue": "polymarket"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The merge",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The market id from GET /markets, however the request named the market."
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The pairs merged: this many YES shares and this many NO shares."
                            },
                            "proceeds_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The cash the pairs pay back: 1 per pair. 0 when status is failed."
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "settled",
                                "submitted",
                                "failed"
                              ],
                              "description": "settled once the venue has paid out, submitted while the payout is on its way and may still fail, failed when the venue refused it and nothing was paid."
                            },
                            "transaction_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "description": "The venue’s id for the transaction that pays out. Null in test mode, for a Hyperliquid merge, and when the venue never accepted it."
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why a failed payout paid nothing. Null unless status is failed."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "venue",
                            "ticker",
                            "market_id",
                            "quantity",
                            "proceeds_usd",
                            "status",
                            "transaction_id",
                            "failure_reason",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "quantity": "25",
                    "proceeds_usd": "25",
                    "status": "submitted",
                    "transaction_id": "0198f0d2-7c4e-7a51-9b3d-2e6f8a1c4d70",
                    "failure_reason": null,
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid, market_id names a listing on another venue, or market_id is a Lean market id listed more than once on venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, trading on the venue is unavailable in this region, or details.reason is ACCOUNT_NOT_DELEGATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "market_id names no market",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "market_id names no market"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The venue wallet is not set up, or details.reason is SETTLEMENT_IN_PROGRESS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is NOTHING_TO_MERGE, VENUE_NOT_SUPPORTED when the market does not trade on venue, or VENUE_NOT_ALLOWED when the account may not trade venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or the venue is unavailable and nothing was submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/conversions": {
      "get": {
        "operationId": "getConvertibleBalances",
        "summary": "Get convertible balances",
        "description": "The USDC and USDC.e in the account’s Polymarket wallet. Polymarket trades only with pUSD, so these do not count toward the account’s cash until POST /conversions turns them into pUSD. They usually come from a transfer sent straight to the wallet instead of through a deposit address. A test key answers zero for both, because test cash is always pUSD.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "The convertible balances",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "usdc": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Native Polygon USDC in the account’s Polymarket wallet."
                            },
                            "usdc_e": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Bridged USDC.e in the account’s Polymarket wallet."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "usdc",
                            "usdc_e",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "usdc": "0",
                    "usdc_e": "125.5",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket wallet is not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The Polymarket wallet is not set up"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "The venue is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "The venue is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "convertToPusd",
        "summary": "Convert USDC to pUSD",
        "description": "Turns the whole balance of source_asset in the account’s Polymarket wallet into the same amount of pUSD, the cash Polymarket trades with. GET /conversions shows what can be converted. usdc_e is converted in one transaction: settled once it confirms, submitted while it is on its way. usdc is sent through Polymarket’s bridge, so it is submitted and its pUSD arrives a few minutes later; a balance under the bridge’s minimum is refused with details.reason BELOW_MINIMUM. One conversion runs at a time per account; another while one is settling is refused with details.reason CONVERSION_IN_PROGRESS. A live conversion needs trading enabled for the account in the Lean app and is submitted once. A test key holds nothing to convert, so it is refused with details.reason NOTHING_TO_CONVERT and nothing changes.",
        "tags": [
          "Account"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_asset": {
                    "type": "string",
                    "enum": [
                      "usdc",
                      "usdc_e"
                    ],
                    "description": "The asset to convert. Its whole balance in the account’s Polymarket wallet becomes pUSD."
                  }
                },
                "required": [
                  "source_asset"
                ],
                "additionalProperties": false
              },
              "example": {
                "source_asset": "usdc_e"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The conversion",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "venue": {
                              "type": "string",
                              "enum": [
                                "polymarket"
                              ]
                            },
                            "source_asset": {
                              "type": "string",
                              "enum": [
                                "usdc",
                                "usdc_e"
                              ],
                              "description": "usdc is native Polygon USDC, usdc_e is bridged USDC.e."
                            },
                            "amount_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The amount converted, which arrives as the same amount of pUSD."
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "settled",
                                "submitted",
                                "failed"
                              ],
                              "description": "settled once the pUSD has arrived, submitted while it is on its way and may still fail, failed when the conversion was refused and nothing moved. A usdc conversion is always submitted at first, because its pUSD arrives a few minutes later."
                            },
                            "transaction_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "description": "The venue’s id for the conversion transaction. Null when the venue never accepted it."
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why a failed conversion moved nothing. Null unless status is failed."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "venue",
                            "source_asset",
                            "amount_usd",
                            "status",
                            "transaction_id",
                            "failure_reason",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "venue": "polymarket",
                    "source_asset": "usdc_e",
                    "amount_usd": "125.5",
                    "status": "settled",
                    "transaction_id": "0198f0d2-7c4e-7a51-9b3d-2e6f8a1c4d70",
                    "failure_reason": null,
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The request is invalid"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or details.reason is ACCOUNT_NOT_DELEGATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket wallet is not set up, or details.reason is CONVERSION_IN_PROGRESS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is NOTHING_TO_CONVERT, BELOW_MINIMUM, or VENUE_NOT_ALLOWED when the account may not trade Polymarket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or the venue is unavailable and nothing was submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/pnl": {
      "get": {
        "operationId": "getPnl",
        "summary": "Get profit and loss",
        "description": "Realized, unrealized and total profit and loss of this key’s trading account, overall and per venue. Filter by `venue` or `market_id`. A live key reads its account’s profit and loss ledger, or for one market its positions there. A test key replays its simulated fills for realized profit and loss, and totals unrealized profit and loss exactly as a live key does over its simulated positions, which are marked as the Lean portfolio marks live ones: Polymarket at the last trade, Hyperliquid at the venue’s mid. A position on a resolved market counts no unrealized profit and loss; unrealized and total are null while any other position has no mark.",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only profit and loss on this venue."
            },
            "required": false,
            "description": "Only profit and loss on this venue.",
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "Only profit and loss on this market: realized from its closed and reduced positions, unrealized from its open ones."
            },
            "required": false,
            "description": "Only profit and loss on this market: realized from its closed and reduced positions, unrealized from its open ones.",
            "name": "market_id",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Profit and loss of the key’s trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "realized_pnl_usd": {
                              "type": "string",
                              "pattern": "^-?\\d+(?:\\.\\d+)?$"
                            },
                            "unrealized_pnl_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^-?\\d+(?:\\.\\d+)?$",
                              "description": "What open positions are worth at their mark prices, or at cost without one, less their cost basis. A position on a resolved market has settled into realized and counts none. Null when a position has no known cost or a venue could not be read."
                            },
                            "total_pnl_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^-?\\d+(?:\\.\\d+)?$"
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "realized_pnl_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "unrealized_pnl_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "total_pnl_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time",
                                    "description": "When these amounts were read, the same as `as_of`. They are worked out when read, with open positions marked live."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "realized_pnl_usd",
                                  "unrealized_pnl_usd",
                                  "total_pnl_usd",
                                  "updated_at"
                                ]
                              }
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "realized_pnl_usd",
                            "unrealized_pnl_usd",
                            "total_pnl_usd",
                            "venues",
                            "market_id",
                            "unavailable",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "realized_pnl_usd": "27.5",
                    "unrealized_pnl_usd": "7.5",
                    "total_pnl_usd": "35",
                    "venues": [
                      {
                        "venue": "polymarket",
                        "realized_pnl_usd": "15",
                        "unrealized_pnl_usd": "5",
                        "total_pnl_usd": "20",
                        "updated_at": "2026-11-10T17:00:00.000Z"
                      },
                      {
                        "venue": "hyperliquid",
                        "realized_pnl_usd": "12.5",
                        "unrealized_pnl_usd": "2.5",
                        "total_pnl_usd": "15",
                        "updated_at": "2026-11-10T17:00:00.000Z"
                      }
                    ],
                    "market_id": null,
                    "unavailable": [],
                    "as_of": "2026-11-10T17:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No market has this id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No market has this id"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/pnl/history": {
      "get": {
        "operationId": "getPnlHistory",
        "summary": "Get profit and loss history",
        "description": "Cumulative profit and loss of this key’s trading account at evenly spaced times from `start` to `end`, each point as of its time. The range is at most 365 days and 1000 points. A test key’s points have realized profit and loss only.",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "1h",
                "1d"
              ],
              "default": "1d",
              "description": "Spacing between points."
            },
            "required": false,
            "description": "Spacing between points.",
            "name": "interval",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Start of the range. Defaults to 30 days before end."
            },
            "required": false,
            "description": "Start of the range. Defaults to 30 days before end.",
            "name": "start",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "End of the range. Defaults to now, and an end after now is read as now."
            },
            "required": false,
            "description": "End of the range. Defaults to now, and an end after now is read as now.",
            "name": "end",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid",
                "lighter"
              ],
              "description": "Only profit and loss on this venue."
            },
            "required": false,
            "description": "Only profit and loss on this venue.",
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Profit and loss of the key’s trading account over time",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "interval": {
                              "type": "string",
                              "enum": [
                                "1h",
                                "1d"
                              ]
                            },
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "points": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "ts": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "realized_pnl_usd": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "unrealized_pnl_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  },
                                  "total_pnl_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$"
                                  }
                                },
                                "required": [
                                  "ts",
                                  "realized_pnl_usd",
                                  "unrealized_pnl_usd",
                                  "total_pnl_usd"
                                ]
                              },
                              "description": "Cumulative profit and loss as the account’s profit and loss record held it at each time, with unrealized at the marks the record captured. GET /v1/pnl marks open positions live, so the latest point can trail it until the next capture."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "interval",
                            "start",
                            "end",
                            "venue",
                            "points",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "interval": "1d",
                    "start": "2026-11-08T00:00:00.000Z",
                    "end": "2026-11-10T00:00:00.000Z",
                    "venue": null,
                    "points": [
                      {
                        "ts": "2026-11-08T00:00:00.000Z",
                        "realized_pnl_usd": "20",
                        "unrealized_pnl_usd": "4",
                        "total_pnl_usd": "24"
                      },
                      {
                        "ts": "2026-11-09T00:00:00.000Z",
                        "realized_pnl_usd": "22.5",
                        "unrealized_pnl_usd": "6",
                        "total_pnl_usd": "28.5"
                      },
                      {
                        "ts": "2026-11-10T00:00:00.000Z",
                        "realized_pnl_usd": "27.5",
                        "unrealized_pnl_usd": "7.5",
                        "total_pnl_usd": "35"
                      }
                    ],
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The interval or range is invalid or too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The interval or range is invalid or too large"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rewards/earnings": {
      "get": {
        "operationId": "getRewardEarnings",
        "summary": "Get reward earnings today",
        "description": "Read today’s earnings across connected venues, or filter by venue. Polymarket reports live pool shares and a projected total for its UTC day. Polymarket US reports paid and pending rewards for its America/New_York day, with pmus:<slug> tickers, zero share and pace, and estimated earnings equal to earned USD. Each venue reports its own status. Requires read scope. Test keys return zero earnings.",
        "tags": [
          "Rewards"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "polymarket",
                "polymarket_us"
              ]
            },
            "required": false,
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Reward earnings today",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "epoch_date": {
                              "type": "string",
                              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                              "description": "UTC date of the response. Polymarket uses a UTC reward day and Polymarket US uses America/New_York."
                            },
                            "earned_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Total earned during each ok venue’s current reward day."
                            },
                            "estimated_today_usd": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Polymarket projects earnings through the end of its UTC day at current shares. Polymarket US contributes its earned_usd."
                            },
                            "pace_usd_per_day": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "Daily earning pace at current Polymarket pool shares. Polymarket US contributes 0."
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "polymarket",
                                      "polymarket_us"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "ok",
                                      "not_connected",
                                      "unavailable"
                                    ],
                                    "description": "`ok`: read live from the venue. `not_connected`: the trading account has no account on the venue. `unavailable`: the venue could not be read just now; try again shortly."
                                  },
                                  "earned_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Null unless `status` is `ok`."
                                  },
                                  "estimated_today_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Null unless `status` is `ok`."
                                  },
                                  "pace_usd_per_day": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Null unless `status` is `ok`."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "status",
                                  "earned_usd",
                                  "estimated_today_usd",
                                  "pace_usd_per_day"
                                ]
                              }
                            },
                            "markets": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "polymarket",
                                      "polymarket_us"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "The venue market ticker. Polymarket uses pm:<condition_id> and Polymarket US uses pmus:<slug>."
                                  },
                                  "market_ids": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The market id from GET /markets, however the request named the market."
                                    },
                                    "description": "The markets GET /markets lists on this venue market. Empty when the API lists none of them."
                                  },
                                  "earned_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Earned during the current venue day (UTC for Polymarket, America/New_York for Polymarket US)."
                                  },
                                  "share_percent": {
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 100,
                                    "description": "Current Polymarket pool share from 0 to 100. Polymarket US reports 0 because live share is unavailable."
                                  },
                                  "pool_daily_reward_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "What this market’s share of the maker liquidity reward pool pays all makers per day; 0 when a covered market has no active maker pool, or null when a shared pool’s market count or market snapshot coverage is unavailable."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "market_ids",
                                  "earned_usd",
                                  "share_percent",
                                  "pool_daily_reward_usd"
                                ]
                              },
                              "description": "Markets with earnings or a pool share today, the most earned first."
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "epoch_date",
                            "earned_usd",
                            "estimated_today_usd",
                            "pace_usd_per_day",
                            "venues",
                            "markets",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "epoch_date": "2026-11-10",
                    "earned_usd": "4.12",
                    "estimated_today_usd": "7.62",
                    "pace_usd_per_day": "8.4",
                    "venues": [
                      {
                        "venue": "polymarket",
                        "status": "ok",
                        "earned_usd": "4.12",
                        "estimated_today_usd": "7.62",
                        "pace_usd_per_day": "8.4"
                      }
                    ],
                    "markets": [
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x5f65177b394277fd294cd75650044e32ba009a95022d88a0c1d565897d72f8f1",
                        "market_ids": [
                          "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4"
                        ],
                        "earned_usd": "4.12",
                        "share_percent": 3.36,
                        "pool_daily_reward_usd": "250"
                      }
                    ],
                    "as_of": "2026-11-10T14:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid reward earnings query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid reward earnings query"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rewards/programs": {
      "get": {
        "operationId": "listRewardsPrograms",
        "summary": "List active market reward programs",
        "description": "Lists active rewards in ticker order across Kalshi, Polymarket US and Polymarket. Requires read scope. Filter by venue, literal ticker_prefix and min_daily_reward in USD per day across a ticker’s active programs. Each page defaults to 100 tickers with a maximum of 200. Pass next_cursor as cursor with the same filters until next_cursor is null. Each ticker includes all its active programs. Kalshi lists open markets and includes event_ticker, series_ticker, title, market_status, price_level_structure, price_ranges and tick_rule, and each Kalshi program carries the stored period_reward_centicents, exact target_size_fp, last_rest_update, created_at and updated_at. last_rest_update and updated_at move only when a Kalshi refresh inserts or changes the program, not on every refresh. Polymarket US includes event_start_time, category, reward_pool, max_spread and pool_market_count. Polymarket end_date is null because its feed has no end date. Test keys read the same programs with livemode false.",
        "tags": [
          "Rewards"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket_us",
                "polymarket"
              ]
            },
            "required": false,
            "name": "venue",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "name": "ticker_prefix",
            "in": "query"
          },
          {
            "schema": {
              "type": "number",
              "nullable": true,
              "minimum": 0
            },
            "required": false,
            "name": "min_daily_reward",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 100
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512,
              "description": "The next_cursor from the previous page. Refused if used with different venue, ticker_prefix, or min_daily_reward filters."
            },
            "required": false,
            "description": "The next_cursor from the previous page. Refused if used with different venue, ticker_prefix, or min_daily_reward filters.",
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Active market reward programs",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "programs": {
                              "type": "array",
                              "items": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "ticker": {
                                        "type": "string"
                                      },
                                      "daily_rate": {
                                        "type": "number"
                                      },
                                      "end_date": {
                                        "type": "string"
                                      },
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi"
                                        ]
                                      },
                                      "event_ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "series_ticker": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "title": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "market_status": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "unopened",
                                          "open",
                                          "closed",
                                          "resolving",
                                          "resolved"
                                        ]
                                      },
                                      "price_level_structure": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "price_ranges": {
                                        "type": "array",
                                        "nullable": true,
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "start": {
                                              "type": "string",
                                              "pattern": "^(?:0(?:\\.\\d{1,4})?|1(?:\\.0{1,4})?)$"
                                            },
                                            "end": {
                                              "type": "string",
                                              "pattern": "^(?:0(?:\\.\\d{1,4})?|1(?:\\.0{1,4})?)$"
                                            },
                                            "step": {
                                              "type": "string",
                                              "pattern": "^(?:0(?:\\.\\d{1,4})?|1(?:\\.0{1,4})?)$"
                                            }
                                          },
                                          "required": [
                                            "start",
                                            "end",
                                            "step"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "tick_rule": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "cent",
                                          "tenth",
                                          "hundredth",
                                          "tapered",
                                          "half_cent"
                                        ]
                                      },
                                      "programs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "incentive_type": {
                                              "type": "string",
                                              "enum": [
                                                "liquidity",
                                                "volume"
                                              ]
                                            },
                                            "daily_rate": {
                                              "type": "number"
                                            },
                                            "start_date": {
                                              "type": "string"
                                            },
                                            "target_size": {
                                              "type": "number",
                                              "nullable": true
                                            },
                                            "end_date": {
                                              "type": "string"
                                            },
                                            "period_reward_dollars": {
                                              "type": "number"
                                            },
                                            "discount_factor_bps": {
                                              "type": "integer",
                                              "nullable": true
                                            },
                                            "period_reward_centicents": {
                                              "type": "integer",
                                              "minimum": 0,
                                              "description": "Program reward pool in centicents, ten thousand per dollar."
                                            },
                                            "target_size_fp": {
                                              "type": "string",
                                              "nullable": true,
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "Exact target size in contracts as stored by Kalshi."
                                            },
                                            "last_rest_update": {
                                              "type": "string",
                                              "description": "When a Kalshi refresh last inserted or changed the stored program. A refresh that returns an unchanged program keeps this time, so it does not show when Lean last checked Kalshi."
                                            },
                                            "created_at": {
                                              "type": "string",
                                              "description": "When a Kalshi refresh first stored the program."
                                            },
                                            "updated_at": {
                                              "type": "string",
                                              "description": "When a Kalshi refresh last inserted or changed the stored program."
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "incentive_type",
                                            "daily_rate",
                                            "start_date",
                                            "target_size",
                                            "end_date",
                                            "period_reward_dollars",
                                            "discount_factor_bps",
                                            "period_reward_centicents",
                                            "target_size_fp",
                                            "last_rest_update",
                                            "created_at",
                                            "updated_at"
                                          ]
                                        },
                                        "minItems": 1
                                      }
                                    },
                                    "required": [
                                      "ticker",
                                      "daily_rate",
                                      "end_date",
                                      "venue",
                                      "event_ticker",
                                      "series_ticker",
                                      "title",
                                      "market_status",
                                      "price_level_structure",
                                      "price_ranges",
                                      "tick_rule",
                                      "programs"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "ticker": {
                                        "type": "string"
                                      },
                                      "daily_rate": {
                                        "type": "number"
                                      },
                                      "end_date": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_us"
                                        ]
                                      },
                                      "event_start_time": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "category": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "expires_at": {
                                        "type": "string"
                                      },
                                      "programs": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "incentive_type": {
                                              "type": "string",
                                              "enum": [
                                                "liquidity",
                                                "volume"
                                              ]
                                            },
                                            "daily_rate": {
                                              "type": "number"
                                            },
                                            "start_date": {
                                              "type": "string"
                                            },
                                            "target_size": {
                                              "type": "number",
                                              "nullable": true
                                            },
                                            "end_date": {
                                              "type": "string",
                                              "nullable": true
                                            },
                                            "discount_factor": {
                                              "type": "number",
                                              "nullable": true
                                            },
                                            "reward_pool": {
                                              "type": "number",
                                              "description": "Full reward pool in USD for this program period."
                                            },
                                            "max_spread": {
                                              "type": "number",
                                              "nullable": true
                                            },
                                            "pool_market_count": {
                                              "type": "integer",
                                              "nullable": true,
                                              "minimum": 1,
                                              "description": "Markets sharing the pool in this snapshot. daily counts the whole program period, daily_event counts its markets in this event, and single-market periods count 1. Null when unknown."
                                            },
                                            "period": {
                                              "type": "string",
                                              "nullable": true
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "incentive_type",
                                            "daily_rate",
                                            "start_date",
                                            "target_size",
                                            "end_date",
                                            "discount_factor",
                                            "reward_pool",
                                            "max_spread",
                                            "pool_market_count",
                                            "period"
                                          ]
                                        },
                                        "minItems": 1
                                      }
                                    },
                                    "required": [
                                      "ticker",
                                      "daily_rate",
                                      "end_date",
                                      "venue",
                                      "event_start_time",
                                      "category",
                                      "expires_at",
                                      "programs"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "ticker": {
                                        "type": "string"
                                      },
                                      "daily_rate": {
                                        "type": "number"
                                      },
                                      "end_date": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket"
                                        ]
                                      },
                                      "max_spread": {
                                        "type": "number",
                                        "nullable": true
                                      },
                                      "min_size": {
                                        "type": "number",
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "ticker",
                                      "daily_rate",
                                      "end_date",
                                      "venue",
                                      "max_spread",
                                      "min_size"
                                    ]
                                  }
                                ]
                              },
                              "maxItems": 200
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "programs",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid reward filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid reward filters"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Reward data is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Reward data is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/risk": {
      "get": {
        "operationId": "getRisk",
        "summary": "Get risk",
        "description": "Exposure of this key’s trading account, per venue and in total: the cost basis and mark value of its positions, its cash, and the unfilled notional of its open orders. Also its largest positions and how its cost basis splits across markets and categories. Built from the same reads as positions, balances and orders; a venue that cannot be read is listed in `unavailable` and its values are null, never zero. A test key’s positions are marked as the Lean portfolio marks live ones: Polymarket at the last trade, Hyperliquid at the venue’s mid; a position with no mark makes the mark values it counts toward null.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Exposure of the key’s trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "cost_basis_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "mark_value_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "cash_usd": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "open_orders": {
                              "type": "object",
                              "properties": {
                                "count": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "buy_notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                  "description": "What the unfilled part of open buys costs at their limit prices."
                                },
                                "sell_notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$",
                                  "description": "What the unfilled part of open sells pays at their limit prices."
                                }
                              },
                              "required": [
                                "count",
                                "buy_notional_usd",
                                "sell_notional_usd"
                              ],
                              "description": "Every open order: API orders, including routed orders whose venue order is not placed yet, which no venue lists, and, for a live key, orders placed in the Lean app that rest on a venue."
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "position_count": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Positions on this venue, not counting remainders too small to trade that the venue cannot redeem yet. Their cost and value still count."
                                  },
                                  "cost_basis_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Sum of `cost_basis_usd` over this venue’s positions; null when its positions could not be read or one has no known cost."
                                  },
                                  "mark_value_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "What this venue’s positions are worth: each at quantity times its mark price, or at cost without one. Null when its positions could not be read or one has no known cost."
                                  },
                                  "cash_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Cash balance on this venue; null when it could not be read."
                                  },
                                  "available_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Cash free to trade on this venue; null when it could not be read."
                                  },
                                  "open_orders": {
                                    "type": "object",
                                    "properties": {
                                      "count": {
                                        "type": "integer",
                                        "minimum": 0
                                      },
                                      "buy_notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "What the unfilled part of open buys costs at their limit prices."
                                      },
                                      "sell_notional_usd": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "What the unfilled part of open sells pays at their limit prices."
                                      }
                                    },
                                    "required": [
                                      "count",
                                      "buy_notional_usd",
                                      "sell_notional_usd"
                                    ]
                                  }
                                },
                                "required": [
                                  "venue",
                                  "position_count",
                                  "cost_basis_usd",
                                  "mark_value_usd",
                                  "cash_usd",
                                  "available_usd",
                                  "open_orders"
                                ]
                              }
                            },
                            "largest_positions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "The market id from GET /markets, however the request named the market."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "outcome": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "cost_basis_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "mark_value_usd": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "share": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Fraction of the cost basis of every position whose cost is known, from 0 to 1."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "market_id",
                                  "title",
                                  "outcome",
                                  "quantity",
                                  "cost_basis_usd",
                                  "mark_value_usd",
                                  "share"
                                ]
                              },
                              "description": "At most 10 positions, largest cost basis first; positions with no known cost come last."
                            },
                            "by_market": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1,
                                    "description": "Null groups the holdings the API lists no market for."
                                  },
                                  "title": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "cost_basis_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "share": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Fraction of the cost basis of every position whose cost is known, from 0 to 1."
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "title",
                                  "cost_basis_usd",
                                  "share"
                                ]
                              },
                              "description": "Largest cost basis first."
                            },
                            "by_category": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "category": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "sports",
                                      "crypto",
                                      "politics",
                                      "economy",
                                      "business",
                                      "entertainment",
                                      "science",
                                      "society",
                                      "climate",
                                      "commodities",
                                      "transportation",
                                      "gaming",
                                      "health",
                                      "law",
                                      "uncategorized"
                                    ],
                                    "description": "The market category. Null groups the holdings the API lists no market for."
                                  },
                                  "sport": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "cost_basis_usd": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "share": {
                                    "type": "string",
                                    "pattern": "^-?\\d+(?:\\.\\d+)?$",
                                    "description": "Fraction of the cost basis of every position whose cost is known, from 0 to 1."
                                  }
                                },
                                "required": [
                                  "category",
                                  "sport",
                                  "cost_basis_usd",
                                  "share"
                                ]
                              },
                              "description": "By market category and sport, largest cost basis first."
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid"
                                ]
                              },
                              "description": "Venues whose positions, balance or open app orders could not be read. A venue whose open app orders could not be read leaves them out of `open_orders`."
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "cost_basis_usd",
                            "mark_value_usd",
                            "cash_usd",
                            "open_orders",
                            "venues",
                            "largest_positions",
                            "by_market",
                            "by_category",
                            "unavailable",
                            "as_of",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "cost_basis_usd": "8.1",
                    "mark_value_usd": "9.3",
                    "cash_usd": "250",
                    "open_orders": {
                      "count": 1,
                      "buy_notional_usd": "2",
                      "sell_notional_usd": "0"
                    },
                    "venues": [
                      {
                        "venue": "polymarket",
                        "position_count": 1,
                        "cost_basis_usd": "3.6",
                        "mark_value_usd": "4",
                        "cash_usd": "150",
                        "available_usd": "148",
                        "open_orders": {
                          "count": 1,
                          "buy_notional_usd": "2",
                          "sell_notional_usd": "0"
                        }
                      },
                      {
                        "venue": "hyperliquid",
                        "position_count": 1,
                        "cost_basis_usd": "4.5",
                        "mark_value_usd": "5.3",
                        "cash_usd": "100",
                        "available_usd": "100",
                        "open_orders": {
                          "count": 0,
                          "buy_notional_usd": "0",
                          "sell_notional_usd": "0"
                        }
                      }
                    ],
                    "largest_positions": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "outcome": "DEN",
                        "quantity": "15",
                        "cost_basis_usd": "4.5",
                        "mark_value_usd": "5.3",
                        "share": "0.5556"
                      },
                      {
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "outcome": "DEN",
                        "quantity": "8",
                        "cost_basis_usd": "3.6",
                        "mark_value_usd": "4",
                        "share": "0.4444"
                      }
                    ],
                    "by_market": [
                      {
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "title": "Denver Broncos at Los Angeles Chargers: DEN -3.5, Denver Broncos -3.5",
                        "cost_basis_usd": "8.1",
                        "share": "1"
                      }
                    ],
                    "by_category": [
                      {
                        "category": "sports",
                        "sport": "football",
                        "cost_basis_usd": "8.1",
                        "share": "1"
                      }
                    ],
                    "unavailable": [],
                    "as_of": "2026-11-10T17:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/deposits/addresses": {
      "get": {
        "operationId": "getDepositAddresses",
        "summary": "Get deposit addresses",
        "description": "Addresses that fund the key’s trading account on one venue, as already created; this never creates one. An address created in the Lean app is returned here too. Each address not created yet is listed in `missing` with a `message` naming POST /deposits/addresses. Send only an asset GET /deposits/assets lists for the same venue, provider and address type. Hyperliquid addresses come only from Relay and credit Hyperliquid spot USDC. Do not use Hyperliquid’s own bridge: sending to Hyperliquid’s own bridge lands in perps, not in the spot balance these addresses fund. A test key gets placeholders that are not addresses on any chain.",
        "tags": [
          "Deposits"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "polymarket",
                "hyperliquid"
              ]
            },
            "required": true,
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Deposit addresses of the key’s trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "hyperliquid"
                                  ]
                                },
                                "addresses": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "address": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "address_type",
                                      "address"
                                    ]
                                  }
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "hyperliquid"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type"
                                    ]
                                  }
                                },
                                "message": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "venue",
                                "addresses",
                                "missing",
                                "message",
                                "livemode"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket"
                                  ]
                                },
                                "addresses": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "address": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "address_type",
                                      "address"
                                    ]
                                  }
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type"
                                    ]
                                  }
                                },
                                "message": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "venue",
                                "addresses",
                                "missing",
                                "message",
                                "livemode"
                              ]
                            }
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "venue": "hyperliquid",
                    "addresses": [
                      {
                        "provider": "relay",
                        "address_type": "evm",
                        "address": "lean_test_not_a_deposit_address"
                      },
                      {
                        "provider": "relay",
                        "address_type": "svm",
                        "address": "lean_test_not_a_deposit_address"
                      }
                    ],
                    "missing": [],
                    "message": null,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid venue, or the trading account is not set up on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid venue, or the trading account is not set up on it"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "The deposit provider is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "The deposit provider is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDepositAddresses",
        "summary": "Create deposit addresses",
        "description": "Only needed if you haven’t already created a deposit address in the Lean app. Creates every deposit address the key’s trading account is missing on one venue and returns all of them. An address the provider cannot open right now is listed in missing while the others are still created and returned; call again later for it. Repeating it returns the same addresses and creates no others. It moves no money. Send only an asset GET /deposits/assets lists for the same venue, provider and address type. Hyperliquid addresses come only from Relay and credit Hyperliquid spot USDC. Do not use Hyperliquid’s own bridge: sending to Hyperliquid’s own bridge lands in perps, not in the spot balance these addresses fund. A test key gets placeholders that are not addresses on any chain.",
        "tags": [
          "Deposits"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid"
                    ]
                  }
                },
                "required": [
                  "venue"
                ]
              },
              "example": {
                "venue": "hyperliquid"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Every deposit address of the key’s trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "hyperliquid"
                                  ]
                                },
                                "addresses": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "address": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "address_type",
                                      "address"
                                    ]
                                  }
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "hyperliquid"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type"
                                    ]
                                  }
                                },
                                "message": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "venue",
                                "addresses",
                                "missing",
                                "message",
                                "livemode"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket"
                                  ]
                                },
                                "addresses": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "address": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "address_type",
                                      "address"
                                    ]
                                  }
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type"
                                    ]
                                  }
                                },
                                "message": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "livemode": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "venue",
                                "addresses",
                                "missing",
                                "message",
                                "livemode"
                              ]
                            }
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "venue": "hyperliquid",
                    "addresses": [
                      {
                        "provider": "relay",
                        "address_type": "evm",
                        "address": "lean_test_not_a_deposit_address"
                      },
                      {
                        "provider": "relay",
                        "address_type": "svm",
                        "address": "lean_test_not_a_deposit_address"
                      }
                    ],
                    "missing": [],
                    "message": null,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid venue, or the trading account is not set up on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid venue, or the trading account is not set up on it"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "The deposit provider is unavailable or returned no usable address; nothing was created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "The deposit provider is unavailable or returned no usable address"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/deposits/assets": {
      "get": {
        "operationId": "getDepositAssets",
        "summary": "List deposit assets",
        "description": "Chains and tokens each venue accepts as deposits, with the provider’s minimum. Hyperliquid deposits arrive through Relay as spot USDC; sending to Hyperliquid’s own bridge lands in perps. The first instant bridge order that funds a Hyperliquid account never used before pays Hyperliquid’s one time 1 USDC activation fee; an account already in use pays none. Arrival time depends on the source chain’s confirmations and the provider, and is not quoted here.",
        "tags": [
          "Deposits"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "polymarket",
                "hyperliquid"
              ]
            },
            "required": false,
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Accepted deposit assets per venue",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "assets": {
                              "type": "array",
                              "items": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "hyperliquid"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "chain_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "chain_name": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "token": {
                                        "type": "object",
                                        "properties": {
                                          "symbol": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "name": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "address": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "decimals": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 255
                                          }
                                        },
                                        "required": [
                                          "symbol",
                                          "name",
                                          "address",
                                          "decimals"
                                        ]
                                      },
                                      "min_deposit_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type",
                                      "chain_id",
                                      "chain_name",
                                      "token",
                                      "min_deposit_usd"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "chain_id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "chain_name": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "token": {
                                        "type": "object",
                                        "properties": {
                                          "symbol": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "name": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "address": {
                                            "type": "string",
                                            "minLength": 1
                                          },
                                          "decimals": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 255
                                          }
                                        },
                                        "required": [
                                          "symbol",
                                          "name",
                                          "address",
                                          "decimals"
                                        ]
                                      },
                                      "min_deposit_usd": {
                                        "type": "string",
                                        "nullable": true,
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "address_type",
                                      "chain_id",
                                      "chain_name",
                                      "token",
                                      "min_deposit_usd"
                                    ]
                                  }
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "assets",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "assets": [
                      {
                        "venue": "hyperliquid",
                        "provider": "relay",
                        "address_type": "evm",
                        "chain_id": "42161",
                        "chain_name": "Arbitrum",
                        "token": {
                          "symbol": "USDC",
                          "name": "USD Coin",
                          "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
                          "decimals": 6
                        },
                        "min_deposit_usd": null
                      },
                      {
                        "venue": "polymarket",
                        "provider": "polymarket_bridge",
                        "address_type": "evm",
                        "chain_id": "1",
                        "chain_name": "Ethereum",
                        "token": {
                          "symbol": "USDC",
                          "name": "USD Coin",
                          "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
                          "decimals": 6
                        },
                        "min_deposit_usd": "10"
                      }
                    ],
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "A deposit provider is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "A deposit provider is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/deposits": {
      "get": {
        "operationId": "listDeposits",
        "summary": "List deposits",
        "description": "Recent deposits into the key’s trading account on one venue, newest first, at most 50, each with its status. Only deposits sent to the addresses from GET /deposits/addresses through a provider are listed: Relay for Hyperliquid and the Polymarket bridge for Polymarket. Sending pUSD straight to the Polymarket wallet credits it at once and is not listed. A test key gets an empty list.",
        "tags": [
          "Deposits"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": [
                "polymarket",
                "hyperliquid"
              ]
            },
            "required": true,
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Recent deposits with their status",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "deposits": {
                              "type": "array",
                              "items": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "hyperliquid"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "relay"
                                        ]
                                      },
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "detected",
                                          "processing",
                                          "completed",
                                          "failed",
                                          "refunded"
                                        ],
                                        "description": "detected once funds reach the deposit address, processing while the provider moves them, then completed when the venue is credited, failed, or refunded to the sender."
                                      },
                                      "credited_amount": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "amount": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "asset": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "amount",
                                          "asset"
                                        ],
                                        "description": "What the venue was credited. Null until the deposit completes."
                                      },
                                      "source_amount": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "amount": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "symbol": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "amount",
                                          "symbol"
                                        ],
                                        "description": "What was sent, when the provider reports it but not the amount credited. Null otherwise."
                                      },
                                      "transactions": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "deposit",
                                                "completion"
                                              ],
                                              "description": "deposit is the transfer into the deposit address; completion is the transfer that credited the venue."
                                            },
                                            "hash": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "chain_id": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "timestamp": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            }
                                          },
                                          "required": [
                                            "kind",
                                            "hash",
                                            "chain_id",
                                            "timestamp"
                                          ]
                                        }
                                      },
                                      "started_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "completed_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "id",
                                      "address_type",
                                      "status",
                                      "credited_amount",
                                      "source_amount",
                                      "transactions",
                                      "started_at",
                                      "completed_at"
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket"
                                        ]
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket_wallet",
                                          "polymarket_bridge"
                                        ]
                                      },
                                      "id": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "address_type": {
                                        "type": "string",
                                        "enum": [
                                          "evm",
                                          "svm"
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "detected",
                                          "processing",
                                          "completed",
                                          "failed",
                                          "refunded"
                                        ],
                                        "description": "detected once funds reach the deposit address, processing while the provider moves them, then completed when the venue is credited, failed, or refunded to the sender."
                                      },
                                      "credited_amount": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "amount": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "asset": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "amount",
                                          "asset"
                                        ],
                                        "description": "What the venue was credited. Null until the deposit completes."
                                      },
                                      "source_amount": {
                                        "type": "object",
                                        "nullable": true,
                                        "properties": {
                                          "amount": {
                                            "type": "string",
                                            "pattern": "^\\d+(?:\\.\\d+)?$"
                                          },
                                          "symbol": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "amount",
                                          "symbol"
                                        ],
                                        "description": "What was sent, when the provider reports it but not the amount credited. Null otherwise."
                                      },
                                      "transactions": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "deposit",
                                                "completion"
                                              ],
                                              "description": "deposit is the transfer into the deposit address; completion is the transfer that credited the venue."
                                            },
                                            "hash": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "chain_id": {
                                              "type": "string",
                                              "minLength": 1
                                            },
                                            "timestamp": {
                                              "type": "string",
                                              "nullable": true,
                                              "format": "date-time"
                                            }
                                          },
                                          "required": [
                                            "kind",
                                            "hash",
                                            "chain_id",
                                            "timestamp"
                                          ]
                                        }
                                      },
                                      "started_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      },
                                      "completed_at": {
                                        "type": "string",
                                        "nullable": true,
                                        "format": "date-time"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "provider",
                                      "id",
                                      "address_type",
                                      "status",
                                      "credited_amount",
                                      "source_amount",
                                      "transactions",
                                      "started_at",
                                      "completed_at"
                                    ]
                                  }
                                ]
                              },
                              "maxItems": 50
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "deposits",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "deposits": [
                      {
                        "venue": "hyperliquid",
                        "provider": "relay",
                        "address_type": "evm",
                        "id": "0x4c1f0e6a9b0d2e7f3a8c5d1b6e9f2a7c4d0b3e8f1a6c9d2e5b8f1a4c7d0e3b6f",
                        "status": "completed",
                        "credited_amount": {
                          "amount": "250",
                          "asset": "USDC"
                        },
                        "source_amount": null,
                        "transactions": [
                          {
                            "kind": "deposit",
                            "hash": "0x9e2d4f6a8c0b1e3d5f7a9c2b4e6d8f0a1c3e5b7d9f2a4c6e8b0d1f3a5c7e9b2d",
                            "chain_id": "42161",
                            "timestamp": "2026-11-17T02:14:05.000Z"
                          }
                        ],
                        "started_at": "2026-11-17T02:14:05.000Z",
                        "completed_at": "2026-11-17T02:14:41.000Z"
                      }
                    ],
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid venue, or the trading account is not set up on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid venue, or the trading account is not set up on it"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "The deposit provider is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "The deposit provider is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transfers/quote": {
      "post": {
        "operationId": "quoteTransfer",
        "summary": "Quote a transfer",
        "description": "What moving cash from one venue of this key’s trading account to another would cost and deliver, the smallest amount the route accepts and what the sending venue holds. Live keys move cash between polymarket, hyperliquid and lighter through Relay, and the fee is Relay’s live quote. Test keys simulate polymarket and hyperliquid. It needs only the read scope and creates nothing.",
        "tags": [
          "Transfers"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue the cash leaves."
                  },
                  "to_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue the cash arrives on, credited to this trading account’s own balance there."
                  },
                  "amount_usd": {
                    "type": "string",
                    "description": "How much leaves from_venue, in dollars, with at most 6 decimal places."
                  }
                },
                "required": [
                  "from_venue",
                  "to_venue",
                  "amount_usd"
                ],
                "additionalProperties": false
              },
              "example": {
                "from_venue": "polymarket",
                "to_venue": "hyperliquid",
                "amount_usd": "25"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The quote",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "from_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "amount_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fee_usd": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the move costs, taken out of amount_usd. Live transfers include the Relay fee and any venue fee."
                            },
                            "receive_usd": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What arrives on to_venue."
                            },
                            "minimum_usd": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The smallest amount_usd this route accepts."
                            },
                            "available_usd": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What from_venue can send right now."
                            },
                            "estimated_seconds": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "expires_at": {
                              "type": "string",
                              "format": "date-time",
                              "description": "Until when a transfer created now can be authorized."
                            },
                            "warnings": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "code": {
                                    "type": "string",
                                    "enum": [
                                      "BELOW_VENUE_MINIMUM",
                                      "INSUFFICIENT_FUNDS"
                                    ]
                                  },
                                  "message": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "code",
                                  "message"
                                ]
                              },
                              "description": "Why POST /v1/transfers would refuse this amount on this route: under minimum_usd or over available_usd. Empty means the amount fits the route; creating the transfer can still be refused under the key's notional limits, allowed venues or a placement block."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "from_venue",
                            "to_venue",
                            "amount_usd",
                            "fee_usd",
                            "receive_usd",
                            "minimum_usd",
                            "available_usd",
                            "estimated_seconds",
                            "expires_at",
                            "warnings",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "from_venue": "polymarket",
                    "to_venue": "hyperliquid",
                    "amount_usd": "25",
                    "fee_usd": "0.1",
                    "receive_usd": "24.9",
                    "minimum_usd": "2",
                    "available_usd": "10000",
                    "estimated_seconds": 0,
                    "expires_at": "2026-11-11T15:02:00.000Z",
                    "warnings": [],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Same venue twice, an unknown venue, lighter on a test key, a venue not connected or an invalid amount",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "A venue or Relay is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "A venue or Relay is unavailable"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transfers": {
      "post": {
        "operationId": "createTransfer",
        "summary": "Create a transfer",
        "description": "Creates a transfer of cash from one venue of this key’s trading account to the account’s own balance on another venue. Test keys simulate transfers against test cash. Live keys move real cash through Relay: the route is prepared now, so fee_usd is the fee it pays, and an account sends one live transfer at a time. Nothing moves until the transfer is executed, with the owner’s signatures over `authorization.payloads` for a test key or with the account’s delegated signer. The amount must be at least the route minimum, fit what the sending venue holds and fit the per order and rolling 24 hour limits of the key and the account. Sending the same client_transfer_id again returns the transfer already created.",
        "tags": [
          "Transfers"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue the cash leaves."
                  },
                  "to_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue the cash arrives on, credited to this trading account’s own balance there."
                  },
                  "amount_usd": {
                    "type": "string",
                    "description": "How much leaves from_venue, in dollars, with at most 6 decimal places."
                  },
                  "client_transfer_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Your id for this transfer, unique per key. Sending the same request again returns the transfer already created instead of creating another."
                  }
                },
                "required": [
                  "from_venue",
                  "to_venue",
                  "amount_usd",
                  "client_transfer_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "from_venue": "polymarket",
                "to_venue": "hyperliquid",
                "amount_usd": "25",
                "client_transfer_id": "rebalance-0001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The transfer",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_transfer_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "from_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "amount_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fee_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "receive_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "awaiting_authorization",
                                "pending",
                                "completed",
                                "failed",
                                "expired"
                              ]
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "authorization": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "signer_address": {
                                  "type": "string",
                                  "pattern": "^0x[a-fA-F0-9]{40}$"
                                },
                                "expires_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "payloads": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "scheme": {
                                            "type": "string",
                                            "enum": [
                                              "lean_test_transfer"
                                            ]
                                          },
                                          "typed_data": {
                                            "type": "object",
                                            "properties": {
                                              "domain": {
                                                "type": "object",
                                                "properties": {
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "Lean API test transfer"
                                                    ]
                                                  },
                                                  "version": {
                                                    "type": "string",
                                                    "enum": [
                                                      "1"
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "name",
                                                  "version"
                                                ]
                                              },
                                              "types": {
                                                "type": "object",
                                                "additionalProperties": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string"
                                                      },
                                                      "type": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                }
                                              },
                                              "primaryType": {
                                                "type": "string",
                                                "enum": [
                                                  "Transfer"
                                                ]
                                              },
                                              "message": {
                                                "type": "object",
                                                "properties": {
                                                  "transferId": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                  },
                                                  "nonce": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]{64}$"
                                                  },
                                                  "fromVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "toVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "amountMicros": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  },
                                                  "expiresAt": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  }
                                                },
                                                "required": [
                                                  "transferId",
                                                  "nonce",
                                                  "fromVenue",
                                                  "toVenue",
                                                  "amountMicros",
                                                  "expiresAt"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "domain",
                                              "types",
                                              "primaryType",
                                              "message"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "scheme",
                                          "typed_data"
                                        ]
                                      }
                                    ]
                                  },
                                  "minItems": 1
                                }
                              },
                              "required": [
                                "signer_address",
                                "expires_at",
                                "payloads"
                              ],
                              "description": "What the owner signs while a test transfer waits to be authorized. Always null for a live transfer, which has nothing to sign and is executed with delegated authorization."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_transfer_id",
                            "from_venue",
                            "to_venue",
                            "amount_usd",
                            "fee_usd",
                            "receive_usd",
                            "status",
                            "failure_reason",
                            "authorization",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "client_transfer_id": "rebalance-0001",
                    "from_venue": "polymarket",
                    "to_venue": "hyperliquid",
                    "amount_usd": "25",
                    "fee_usd": "0.1",
                    "receive_usd": "24.9",
                    "status": "awaiting_authorization",
                    "failure_reason": null,
                    "authorization": {
                      "signer_address": "0x00000000000000000000000000000000000000a1",
                      "expires_at": "2026-11-11T15:02:00.000Z",
                      "payloads": [
                        {
                          "scheme": "lean_test_transfer",
                          "typed_data": {
                            "domain": {
                              "name": "Lean API test transfer",
                              "version": "1"
                            },
                            "types": {
                              "Transfer": [
                                {
                                  "name": "transferId",
                                  "type": "string"
                                },
                                {
                                  "name": "nonce",
                                  "type": "bytes32"
                                },
                                {
                                  "name": "fromVenue",
                                  "type": "string"
                                },
                                {
                                  "name": "toVenue",
                                  "type": "string"
                                },
                                {
                                  "name": "amountMicros",
                                  "type": "uint256"
                                },
                                {
                                  "name": "expiresAt",
                                  "type": "uint256"
                                }
                              ]
                            },
                            "primaryType": "Transfer",
                            "message": {
                              "transferId": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b",
                              "nonce": "0x1111111111111111111111111111111111111111111111111111111111111111",
                              "fromVenue": "polymarket",
                              "toVenue": "hyperliquid",
                              "amountMicros": "25000000",
                              "expiresAt": "1794409320"
                            }
                          }
                        }
                      ]
                    },
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Same venue twice, an unknown venue, lighter on a test key, a venue not connected, an unknown field or an invalid amount",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade or route scope, or details.reason is ACCOUNT_NOT_DELEGATED for a live key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_transfer_id was already used with a different request, or another transfer is in progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "client_transfer_id was already used with a different request, or another transfer is in progress"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is BELOW_VENUE_MINIMUM, INSUFFICIENT_FUNDS, VENUE_NOT_ALLOWED, ORDER_NOTIONAL_LIMIT or DAILY_NOTIONAL_LIMIT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "details.reason is TRADING_PAUSED or LIVE_TRADING_DISABLED, or a venue or Relay is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listTransfers",
        "summary": "List transfers",
        "description": "Transfers of this key’s trading account in this key’s mode, newest first.",
        "tags": [
          "Transfers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfers, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "transfers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "client_transfer_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "from_venue": {
                                    "type": "string",
                                    "enum": [
                                      "polymarket",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "to_venue": {
                                    "type": "string",
                                    "enum": [
                                      "polymarket",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "amount_usd": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "fee_usd": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "receive_usd": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "awaiting_authorization",
                                      "pending",
                                      "completed",
                                      "failed",
                                      "expired"
                                    ]
                                  },
                                  "failure_reason": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "authorization": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "signer_address": {
                                        "type": "string",
                                        "pattern": "^0x[a-fA-F0-9]{40}$"
                                      },
                                      "expires_at": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "payloads": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "scheme": {
                                                  "type": "string",
                                                  "enum": [
                                                    "lean_test_transfer"
                                                  ]
                                                },
                                                "typed_data": {
                                                  "type": "object",
                                                  "properties": {
                                                    "domain": {
                                                      "type": "object",
                                                      "properties": {
                                                        "name": {
                                                          "type": "string",
                                                          "enum": [
                                                            "Lean API test transfer"
                                                          ]
                                                        },
                                                        "version": {
                                                          "type": "string",
                                                          "enum": [
                                                            "1"
                                                          ]
                                                        }
                                                      },
                                                      "required": [
                                                        "name",
                                                        "version"
                                                      ]
                                                    },
                                                    "types": {
                                                      "type": "object",
                                                      "additionalProperties": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "name": {
                                                              "type": "string"
                                                            },
                                                            "type": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "name",
                                                            "type"
                                                          ]
                                                        }
                                                      }
                                                    },
                                                    "primaryType": {
                                                      "type": "string",
                                                      "enum": [
                                                        "Transfer"
                                                      ]
                                                    },
                                                    "message": {
                                                      "type": "object",
                                                      "properties": {
                                                        "transferId": {
                                                          "type": "string",
                                                          "format": "uuid"
                                                        },
                                                        "nonce": {
                                                          "type": "string",
                                                          "pattern": "^0x[a-fA-F0-9]{64}$"
                                                        },
                                                        "fromVenue": {
                                                          "type": "string",
                                                          "enum": [
                                                            "polymarket",
                                                            "hyperliquid"
                                                          ]
                                                        },
                                                        "toVenue": {
                                                          "type": "string",
                                                          "enum": [
                                                            "polymarket",
                                                            "hyperliquid"
                                                          ]
                                                        },
                                                        "amountMicros": {
                                                          "type": "string",
                                                          "pattern": "^\\d+$"
                                                        },
                                                        "expiresAt": {
                                                          "type": "string",
                                                          "pattern": "^\\d+$"
                                                        }
                                                      },
                                                      "required": [
                                                        "transferId",
                                                        "nonce",
                                                        "fromVenue",
                                                        "toVenue",
                                                        "amountMicros",
                                                        "expiresAt"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "domain",
                                                    "types",
                                                    "primaryType",
                                                    "message"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "scheme",
                                                "typed_data"
                                              ]
                                            }
                                          ]
                                        },
                                        "minItems": 1
                                      }
                                    },
                                    "required": [
                                      "signer_address",
                                      "expires_at",
                                      "payloads"
                                    ],
                                    "description": "What the owner signs while a test transfer waits to be authorized. Always null for a live transfer, which has nothing to sign and is executed with delegated authorization."
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "client_transfer_id",
                                  "from_venue",
                                  "to_venue",
                                  "amount_usd",
                                  "fee_usd",
                                  "receive_usd",
                                  "status",
                                  "failure_reason",
                                  "authorization",
                                  "created_at",
                                  "updated_at",
                                  "livemode"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "transfers",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "transfers": [
                      {
                        "id": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b",
                        "client_transfer_id": "rebalance-0001",
                        "from_venue": "polymarket",
                        "to_venue": "hyperliquid",
                        "amount_usd": "25",
                        "fee_usd": "0.1",
                        "receive_usd": "24.9",
                        "status": "completed",
                        "failure_reason": null,
                        "authorization": null,
                        "created_at": "2026-11-11T15:00:00.000Z",
                        "updated_at": "2026-11-11T15:01:00.000Z",
                        "livemode": false
                      }
                    ],
                    "next_cursor": null,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transfers/{id}/execute": {
      "post": {
        "operationId": "executeTransfer",
        "summary": "Execute a transfer",
        "description": "Authorizes and submits a transfer waiting for authorization, once. Send the owner’s signatures over `authorization.payloads` in order, or `delegated` to have Lean sign them with the account’s delegated signer. A live transfer has nothing to sign, so it takes `delegated` only, and it answers pending until its venues settle it. A transfer that cannot be sent fails with failure_reason and nothing moved. A transfer is submitted at most once and never retried; sending the same authorization again returns the transfer as it stands.",
        "tags": [
          "Transfers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "authorization": {
                        "type": "string",
                        "enum": [
                          "signature"
                        ]
                      },
                      "signatures": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^0x[a-fA-F0-9]{130}$"
                        },
                        "minItems": 1,
                        "description": "One EIP-712 signature per `authorization.payloads` entry, in the same order."
                      }
                    },
                    "required": [
                      "authorization",
                      "signatures"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "authorization": {
                        "type": "string",
                        "enum": [
                          "delegated"
                        ]
                      }
                    },
                    "required": [
                      "authorization"
                    ],
                    "additionalProperties": false
                  }
                ]
              },
              "example": {
                "authorization": "signature",
                "signatures": [
                  "0xababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The transfer",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_transfer_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "from_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "amount_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fee_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "receive_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "awaiting_authorization",
                                "pending",
                                "completed",
                                "failed",
                                "expired"
                              ]
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "authorization": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "signer_address": {
                                  "type": "string",
                                  "pattern": "^0x[a-fA-F0-9]{40}$"
                                },
                                "expires_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "payloads": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "scheme": {
                                            "type": "string",
                                            "enum": [
                                              "lean_test_transfer"
                                            ]
                                          },
                                          "typed_data": {
                                            "type": "object",
                                            "properties": {
                                              "domain": {
                                                "type": "object",
                                                "properties": {
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "Lean API test transfer"
                                                    ]
                                                  },
                                                  "version": {
                                                    "type": "string",
                                                    "enum": [
                                                      "1"
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "name",
                                                  "version"
                                                ]
                                              },
                                              "types": {
                                                "type": "object",
                                                "additionalProperties": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string"
                                                      },
                                                      "type": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                }
                                              },
                                              "primaryType": {
                                                "type": "string",
                                                "enum": [
                                                  "Transfer"
                                                ]
                                              },
                                              "message": {
                                                "type": "object",
                                                "properties": {
                                                  "transferId": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                  },
                                                  "nonce": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]{64}$"
                                                  },
                                                  "fromVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "toVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "amountMicros": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  },
                                                  "expiresAt": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  }
                                                },
                                                "required": [
                                                  "transferId",
                                                  "nonce",
                                                  "fromVenue",
                                                  "toVenue",
                                                  "amountMicros",
                                                  "expiresAt"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "domain",
                                              "types",
                                              "primaryType",
                                              "message"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "scheme",
                                          "typed_data"
                                        ]
                                      }
                                    ]
                                  },
                                  "minItems": 1
                                }
                              },
                              "required": [
                                "signer_address",
                                "expires_at",
                                "payloads"
                              ],
                              "description": "What the owner signs while a test transfer waits to be authorized. Always null for a live transfer, which has nothing to sign and is executed with delegated authorization."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_transfer_id",
                            "from_venue",
                            "to_venue",
                            "amount_usd",
                            "fee_usd",
                            "receive_usd",
                            "status",
                            "failure_reason",
                            "authorization",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "client_transfer_id": "rebalance-0001",
                    "from_venue": "polymarket",
                    "to_venue": "hyperliquid",
                    "amount_usd": "25",
                    "fee_usd": "0.1",
                    "receive_usd": "24.9",
                    "status": "pending",
                    "failure_reason": null,
                    "authorization": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "details.reason is INVALID_SIGNATURE or SIGNER_MISMATCH",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade or route scope, or details.reason is ACCOUNT_NOT_DELEGATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "details.reason is QUOTE_EXPIRED or PAYMENT_ALREADY_AUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is ORDER_NOTIONAL_LIMIT, DAILY_NOTIONAL_LIMIT or VENUE_NOT_ALLOWED: a limit or allowed venue changed after the transfer was created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "details.reason is TRADING_PAUSED or LIVE_TRADING_DISABLED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transfers/{id}": {
      "get": {
        "operationId": "getTransfer",
        "summary": "Get a transfer",
        "description": "One transfer of this key’s trading account by id, with its current status. A live transfer on its way is read from its venues on each request.",
        "tags": [
          "Transfers"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The transfer",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "client_transfer_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "from_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid",
                                "lighter"
                              ]
                            },
                            "amount_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fee_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "receive_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "awaiting_authorization",
                                "pending",
                                "completed",
                                "failed",
                                "expired"
                              ]
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true
                            },
                            "authorization": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "signer_address": {
                                  "type": "string",
                                  "pattern": "^0x[a-fA-F0-9]{40}$"
                                },
                                "expires_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "payloads": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "scheme": {
                                            "type": "string",
                                            "enum": [
                                              "lean_test_transfer"
                                            ]
                                          },
                                          "typed_data": {
                                            "type": "object",
                                            "properties": {
                                              "domain": {
                                                "type": "object",
                                                "properties": {
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "Lean API test transfer"
                                                    ]
                                                  },
                                                  "version": {
                                                    "type": "string",
                                                    "enum": [
                                                      "1"
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "name",
                                                  "version"
                                                ]
                                              },
                                              "types": {
                                                "type": "object",
                                                "additionalProperties": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "name": {
                                                        "type": "string"
                                                      },
                                                      "type": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "name",
                                                      "type"
                                                    ]
                                                  }
                                                }
                                              },
                                              "primaryType": {
                                                "type": "string",
                                                "enum": [
                                                  "Transfer"
                                                ]
                                              },
                                              "message": {
                                                "type": "object",
                                                "properties": {
                                                  "transferId": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                  },
                                                  "nonce": {
                                                    "type": "string",
                                                    "pattern": "^0x[a-fA-F0-9]{64}$"
                                                  },
                                                  "fromVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "toVenue": {
                                                    "type": "string",
                                                    "enum": [
                                                      "polymarket",
                                                      "hyperliquid"
                                                    ]
                                                  },
                                                  "amountMicros": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  },
                                                  "expiresAt": {
                                                    "type": "string",
                                                    "pattern": "^\\d+$"
                                                  }
                                                },
                                                "required": [
                                                  "transferId",
                                                  "nonce",
                                                  "fromVenue",
                                                  "toVenue",
                                                  "amountMicros",
                                                  "expiresAt"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "domain",
                                              "types",
                                              "primaryType",
                                              "message"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "scheme",
                                          "typed_data"
                                        ]
                                      }
                                    ]
                                  },
                                  "minItems": 1
                                }
                              },
                              "required": [
                                "signer_address",
                                "expires_at",
                                "payloads"
                              ],
                              "description": "What the owner signs while a test transfer waits to be authorized. Always null for a live transfer, which has nothing to sign and is executed with delegated authorization."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "client_transfer_id",
                            "from_venue",
                            "to_venue",
                            "amount_usd",
                            "fee_usd",
                            "receive_usd",
                            "status",
                            "failure_reason",
                            "authorization",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "4b1d2c3e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "client_transfer_id": "rebalance-0001",
                    "from_venue": "polymarket",
                    "to_venue": "hyperliquid",
                    "amount_usd": "25",
                    "fee_usd": "0.1",
                    "receive_usd": "24.9",
                    "status": "completed",
                    "failure_reason": null,
                    "authorization": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:01:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/test/reset": {
      "post": {
        "operationId": "resetTestMode",
        "summary": "Reset test mode",
        "description": "Deletes every simulated order, withdrawal, transfer, stop loss, limit chase, conditional sell, redeem and merge of the test key’s trading account, made by any test key on that account and not only the calling key. It returns the account’s test balances to the starting amount, clears its test positions and resets the test daily limit usage. Live keys are refused.",
        "tags": [
          "Test mode"
        ],
        "responses": {
          "200": {
            "description": "Test state of the key’s trading account after the reset. The reset cleared the simulated orders of every test key on the account.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "deleted_orders": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_withdrawals": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_stop_losses": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_limit_chases": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_conditional_sells": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_transfers": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "deleted_settlements": {
                              "type": "integer",
                              "minimum": 0,
                              "description": "Holdings settled by a redeem or merge, one per side."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "deleted_orders",
                            "deleted_withdrawals",
                            "deleted_stop_losses",
                            "deleted_limit_chases",
                            "deleted_conditional_sells",
                            "deleted_transfers",
                            "deleted_settlements",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "deleted_orders": 3,
                    "deleted_withdrawals": 1,
                    "deleted_stop_losses": 2,
                    "deleted_limit_chases": 1,
                    "deleted_conditional_sells": 1,
                    "deleted_transfers": 1,
                    "deleted_settlements": 1,
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or is a live key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/withdrawals": {
      "post": {
        "operationId": "createWithdrawal",
        "summary": "Withdraw cash",
        "description": "Withdraws cash from one venue of this key’s trading account to the address the request names. The request names the source venue and the asset it holds, the destination chain, asset and address, and the amount of the source asset. Each venue pays out one asset as usdc, on any chain that destination.chain lists: pusd on Polymarket and usdc on Hyperliquid. Any other pair of assets is refused with a 400. The key needs the withdraw scope, and each withdrawal must fit the key’s optional per withdrawal limit, its optional limit across the last 24 hours and the venue’s available cash. The venue’s fee comes out of the amount: the response gives the fee and the net amount the destination is quoted to receive. A live withdrawal needs trading enabled for the account in the Lean app and is submitted once: it starts pending and becomes completed or failed as the venue settles it, with failure_reason saying why a failed one paid nothing. A Polymarket withdrawal is completed once the funds leave the account for Polymarket’s bridge, which then pays the USDC on the destination chain; a Hyperliquid withdrawal is completed once the USDC arrives on the destination chain. A test withdrawal moves nothing, charges no fee, completes at once and lowers the simulated cash on that venue until test mode is reset. Sending the same client_withdrawal_id again returns the withdrawal already made.",
        "tags": [
          "Withdrawals"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "object",
                    "properties": {
                      "venue": {
                        "type": "string",
                        "enum": [
                          "polymarket",
                          "hyperliquid"
                        ],
                        "description": "The venue whose cash is withdrawn."
                      },
                      "asset": {
                        "type": "string",
                        "enum": [
                          "pusd",
                          "usdc"
                        ],
                        "description": "The asset the venue holds the cash in: pusd on Polymarket, usdc on Hyperliquid."
                      }
                    },
                    "required": [
                      "venue",
                      "asset"
                    ],
                    "additionalProperties": false
                  },
                  "destination": {
                    "type": "object",
                    "properties": {
                      "chain": {
                        "type": "string",
                        "enum": [
                          "polygon",
                          "arbitrum",
                          "base",
                          "optimism",
                          "ethereum",
                          "bsc",
                          "solana"
                        ],
                        "description": "The chain the cash is paid out on. Every venue pays out on each of these chains."
                      },
                      "asset": {
                        "type": "string",
                        "enum": [
                          "pusd",
                          "usdc"
                        ],
                        "description": "The asset the destination receives."
                      },
                      "address": {
                        "type": "string",
                        "maxLength": 44,
                        "description": "The address that receives the cash: a Solana address on solana, a 0x address on any other chain."
                      }
                    },
                    "required": [
                      "chain",
                      "asset",
                      "address"
                    ],
                    "additionalProperties": false
                  },
                  "amount": {
                    "type": "string",
                    "description": "How much of the source asset to withdraw, with at most 6 decimal places. The fee comes out of this amount."
                  },
                  "client_withdrawal_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "Your id for this withdrawal, unique per key. Sending the same request again returns the withdrawal already made instead of making another."
                  }
                },
                "required": [
                  "source",
                  "destination",
                  "amount",
                  "client_withdrawal_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "source": {
                  "venue": "polymarket",
                  "asset": "pusd"
                },
                "destination": {
                  "chain": "polygon",
                  "asset": "usdc",
                  "address": "0x00000000000000000000000000000000000000a1"
                },
                "amount": "25",
                "client_withdrawal_id": "payout-0001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "source": {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ],
                                  "description": "The venue whose cash is withdrawn."
                                },
                                "asset": {
                                  "type": "string",
                                  "enum": [
                                    "pusd",
                                    "usdc"
                                  ],
                                  "description": "The asset the venue holds the cash in: pusd on Polymarket, usdc on Hyperliquid."
                                }
                              },
                              "required": [
                                "venue",
                                "asset"
                              ],
                              "additionalProperties": false
                            },
                            "destination": {
                              "type": "object",
                              "properties": {
                                "chain": {
                                  "type": "string",
                                  "enum": [
                                    "polygon",
                                    "arbitrum",
                                    "base",
                                    "optimism",
                                    "ethereum",
                                    "bsc",
                                    "solana"
                                  ],
                                  "description": "The chain the cash is paid out on. Every venue pays out on each of these chains."
                                },
                                "asset": {
                                  "type": "string",
                                  "enum": [
                                    "pusd",
                                    "usdc"
                                  ],
                                  "description": "The asset the destination receives."
                                },
                                "address": {
                                  "type": "string",
                                  "maxLength": 44,
                                  "description": "The address that receives the cash: a Solana address on solana, a 0x address on any other chain."
                                }
                              },
                              "required": [
                                "chain",
                                "asset",
                                "address"
                              ],
                              "additionalProperties": false
                            },
                            "amount": {
                              "type": "string",
                              "minLength": 1,
                              "description": "How much of the source asset was withdrawn."
                            },
                            "fee": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the venue's payout quote took from the amount when the withdrawal was made. Zero for a test withdrawal."
                            },
                            "net_amount": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the destination was quoted to receive: the amount less the fee, in the destination asset."
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "completed",
                                "failed"
                              ],
                              "description": "pending until the venue settles the payment, then completed, or failed when nothing was paid out. A test withdrawal is completed at once."
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why a failed withdrawal did not pay out. Null unless status is failed."
                            },
                            "client_withdrawal_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "source",
                            "destination",
                            "amount",
                            "fee",
                            "net_amount",
                            "status",
                            "failure_reason",
                            "client_withdrawal_id",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "8f14e45f-ceea-4672-a5b0-6f1c9d2b7a31",
                    "source": {
                      "venue": "polymarket",
                      "asset": "pusd"
                    },
                    "destination": {
                      "chain": "polygon",
                      "asset": "usdc",
                      "address": "0x00000000000000000000000000000000000000a1"
                    },
                    "amount": "25",
                    "fee": "0.12",
                    "net_amount": "24.88",
                    "status": "completed",
                    "failure_reason": null,
                    "client_withdrawal_id": "payout-0001",
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request is invalid, names an unsupported source and destination pair, or the venue cannot pay this withdrawal out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the withdraw scope, or details.reason is ACCOUNT_NOT_DELEGATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "client_withdrawal_id was already used with a different request, the venue wallet is not set up, or details.reason is WITHDRAWAL_IN_PROGRESS",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is WITHDRAWAL_LIMIT_EXCEEDED, DAILY_WITHDRAWAL_LIMIT_EXCEEDED or INSUFFICIENT_BALANCE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or the venue is unavailable and nothing was paid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listWithdrawals",
        "summary": "List withdrawals",
        "description": "Withdrawals this key’s trading account made in this key’s mode, newest first.",
        "tags": [
          "Withdrawals"
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "polymarket",
                "hyperliquid"
              ],
              "description": "Only withdrawals from this source venue."
            },
            "required": false,
            "description": "Only withdrawals from this source venue.",
            "name": "venue",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Withdrawals, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "withdrawals": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "source": {
                                    "type": "object",
                                    "properties": {
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "polymarket",
                                          "hyperliquid"
                                        ],
                                        "description": "The venue whose cash is withdrawn."
                                      },
                                      "asset": {
                                        "type": "string",
                                        "enum": [
                                          "pusd",
                                          "usdc"
                                        ],
                                        "description": "The asset the venue holds the cash in: pusd on Polymarket, usdc on Hyperliquid."
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "asset"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "destination": {
                                    "type": "object",
                                    "properties": {
                                      "chain": {
                                        "type": "string",
                                        "enum": [
                                          "polygon",
                                          "arbitrum",
                                          "base",
                                          "optimism",
                                          "ethereum",
                                          "bsc",
                                          "solana"
                                        ],
                                        "description": "The chain the cash is paid out on. Every venue pays out on each of these chains."
                                      },
                                      "asset": {
                                        "type": "string",
                                        "enum": [
                                          "pusd",
                                          "usdc"
                                        ],
                                        "description": "The asset the destination receives."
                                      },
                                      "address": {
                                        "type": "string",
                                        "maxLength": 44,
                                        "description": "The address that receives the cash: a Solana address on solana, a 0x address on any other chain."
                                      }
                                    },
                                    "required": [
                                      "chain",
                                      "asset",
                                      "address"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "amount": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "How much of the source asset was withdrawn."
                                  },
                                  "fee": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "What the venue's payout quote took from the amount when the withdrawal was made. Zero for a test withdrawal."
                                  },
                                  "net_amount": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "What the destination was quoted to receive: the amount less the fee, in the destination asset."
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "completed",
                                      "failed"
                                    ],
                                    "description": "pending until the venue settles the payment, then completed, or failed when nothing was paid out. A test withdrawal is completed at once."
                                  },
                                  "failure_reason": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Why a failed withdrawal did not pay out. Null unless status is failed."
                                  },
                                  "client_withdrawal_id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "source",
                                  "destination",
                                  "amount",
                                  "fee",
                                  "net_amount",
                                  "status",
                                  "failure_reason",
                                  "client_withdrawal_id",
                                  "created_at",
                                  "livemode"
                                ]
                              }
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1,
                              "maxLength": 512
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "withdrawals",
                            "next_cursor",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "withdrawals": [
                      {
                        "id": "8f14e45f-ceea-4672-a5b0-6f1c9d2b7a31",
                        "source": {
                          "venue": "polymarket",
                          "asset": "pusd"
                        },
                        "destination": {
                          "chain": "polygon",
                          "asset": "usdc",
                          "address": "0x00000000000000000000000000000000000000a1"
                        },
                        "amount": "25",
                        "fee": "0.12",
                        "net_amount": "24.88",
                        "status": "completed",
                        "failure_reason": null,
                        "client_withdrawal_id": "payout-0001",
                        "created_at": "2026-11-10T15:00:00.000Z",
                        "livemode": true
                      }
                    ],
                    "next_cursor": null,
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/withdrawals/{id}": {
      "get": {
        "operationId": "getWithdrawal",
        "summary": "Get a withdrawal",
        "description": "One withdrawal of this key’s trading account by id.",
        "tags": [
          "Withdrawals"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "example": "8f14e45f-ceea-4672-a5b0-6f1c9d2b7a31"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "source": {
                              "type": "object",
                              "properties": {
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "polymarket",
                                    "hyperliquid"
                                  ],
                                  "description": "The venue whose cash is withdrawn."
                                },
                                "asset": {
                                  "type": "string",
                                  "enum": [
                                    "pusd",
                                    "usdc"
                                  ],
                                  "description": "The asset the venue holds the cash in: pusd on Polymarket, usdc on Hyperliquid."
                                }
                              },
                              "required": [
                                "venue",
                                "asset"
                              ],
                              "additionalProperties": false
                            },
                            "destination": {
                              "type": "object",
                              "properties": {
                                "chain": {
                                  "type": "string",
                                  "enum": [
                                    "polygon",
                                    "arbitrum",
                                    "base",
                                    "optimism",
                                    "ethereum",
                                    "bsc",
                                    "solana"
                                  ],
                                  "description": "The chain the cash is paid out on. Every venue pays out on each of these chains."
                                },
                                "asset": {
                                  "type": "string",
                                  "enum": [
                                    "pusd",
                                    "usdc"
                                  ],
                                  "description": "The asset the destination receives."
                                },
                                "address": {
                                  "type": "string",
                                  "maxLength": 44,
                                  "description": "The address that receives the cash: a Solana address on solana, a 0x address on any other chain."
                                }
                              },
                              "required": [
                                "chain",
                                "asset",
                                "address"
                              ],
                              "additionalProperties": false
                            },
                            "amount": {
                              "type": "string",
                              "minLength": 1,
                              "description": "How much of the source asset was withdrawn."
                            },
                            "fee": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the venue's payout quote took from the amount when the withdrawal was made. Zero for a test withdrawal."
                            },
                            "net_amount": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the destination was quoted to receive: the amount less the fee, in the destination asset."
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending",
                                "completed",
                                "failed"
                              ],
                              "description": "pending until the venue settles the payment, then completed, or failed when nothing was paid out. A test withdrawal is completed at once."
                            },
                            "failure_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why a failed withdrawal did not pay out. Null unless status is failed."
                            },
                            "client_withdrawal_id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "source",
                            "destination",
                            "amount",
                            "fee",
                            "net_amount",
                            "status",
                            "failure_reason",
                            "client_withdrawal_id",
                            "created_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "8f14e45f-ceea-4672-a5b0-6f1c9d2b7a31",
                    "source": {
                      "venue": "polymarket",
                      "asset": "pusd"
                    },
                    "destination": {
                      "chain": "polygon",
                      "asset": "usdc",
                      "address": "0x00000000000000000000000000000000000000a1"
                    },
                    "amount": "25",
                    "fee": "0.12",
                    "net_amount": "24.88",
                    "status": "completed",
                    "failure_reason": null,
                    "client_withdrawal_id": "payout-0001",
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the read scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/stop-losses": {
      "post": {
        "operationId": "createStopLoss",
        "summary": "Create a stop loss or take profit",
        "description": "Watches the best bid for shares this key’s trading account holds on the request’s venue and sells them once it reaches the trigger price. A stop_loss sells when the bid falls to trigger_price or below; a take_profit sells when it rises to trigger_price or above. The sale fills no lower than trigger_price minus slippage_limit: it sells what it can at once, then rests the rest at that price until it fills, is canceled or expires. The stop losses on the same shares together sell at most what the account holds. The sale is booked as an order at trigger_price would be: it counts toward the rolling day and is held to the account’s venue allow list, but as a sale it only takes risk off, so no notional limit refuses it. On a test key the stop loss is recorded, listed and booked but never sells. Every venue runs stop losses and take profits.",
        "tags": [
          "Stop losses"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "The market whose shares are sold."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue holding the shares to sell. Stop losses and take profits run on every venue but Lighter, which is refused with 422 and reason NO_EXECUTABLE_VENUE."
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "stop_loss",
                      "take_profit"
                    ],
                    "description": "stop_loss sells once the best bid falls to trigger_price or below; take_profit sells once it rises to trigger_price or above."
                  },
                  "trigger_price": {
                    "type": "string",
                    "description": "The best bid, in dollars per share between 0.0001 and 0.9999, that starts the sale. A stop_loss must be below the current best bid and a take_profit above it, or the request is refused, since the sale would start at once. A stop_loss is also refused when the market has no bid."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Shares to sell. Together with the account’s other stop losses on these shares, at most what the account holds."
                  },
                  "slippage_limit": {
                    "type": "string",
                    "description": "How far below trigger_price the sale may fill, in dollars above 0 and at most 0.2, on the market’s price tick and below trigger_price. Defaults to 0.05."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the stop loss lapses, in UTC ending in Z, in the future and at most 30 days ahead. It applies whether or not the sale has started, and a sale still resting then is canceled. Omit to keep it until canceled."
                  }
                },
                "required": [
                  "market_id",
                  "venue",
                  "type",
                  "trigger_price",
                  "quantity"
                ],
                "additionalProperties": false
              },
              "example": {
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "venue": "polymarket",
                "type": "stop_loss",
                "trigger_price": "0.4",
                "quantity": "25",
                "slippage_limit": "0.05"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stop loss, watching the market",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "stop_loss",
                                "take_profit"
                              ]
                            },
                            "trigger_price": {
                              "type": "string"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "slippage_limit": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "triggered",
                                "executing",
                                "filled",
                                "partial",
                                "canceled",
                                "expired",
                                "failed"
                              ]
                            },
                            "triggered_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "triggered_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live stop loss keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "type",
                            "trigger_price",
                            "quantity",
                            "slippage_limit",
                            "status",
                            "triggered_at",
                            "triggered_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "type": "stop_loss",
                    "trigger_price": "0.4",
                    "quantity": "25",
                    "slippage_limit": "0.05",
                    "status": "active",
                    "triggered_at": null,
                    "triggered_price": null,
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "updated_at": "2026-11-10T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The prices, quantity or expiry are invalid for this market, the trigger price is one the best bid already meets (a stop_loss at or above it, or with no bid; a take_profit at or below it), or the quantity is more than the account holds beyond its other stop losses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or a live key’s account cannot trade on the venue: no API key is connected for Kalshi or Polymarket US, or the Polymarket wallet is not set up or its approvals need refreshing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket account setup changed while the stop loss was being created; finish setup in the Lean app and send it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The Polymarket account setup changed while the stop loss was being created"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is NO_EXECUTABLE_VENUE or VENUE_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, Lean has paused stop losses on the venue for a live key, or the market’s book could not be read to check the trigger price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listStopLosses",
        "summary": "List stop losses",
        "description": "Stop losses and take profits of this key’s trading account in this key’s mode, newest first: every one still watching or selling, and those that ended in the last hour. Kalshi and Polymarket US stop losses belong to the user rather than to a trading account, so a live key lists all of the user’s on those venues. A live key also lists the sales that conditional sells run for their followers and stop leaders; those cannot be changed or canceled here.",
        "tags": [
          "Stop losses"
        ],
        "responses": {
          "200": {
            "description": "Stop losses, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "stop_losses": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "stop_loss",
                                      "take_profit"
                                    ]
                                  },
                                  "trigger_price": {
                                    "type": "string"
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "slippage_limit": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "active",
                                      "triggered",
                                      "executing",
                                      "filled",
                                      "partial",
                                      "canceled",
                                      "expired",
                                      "failed"
                                    ]
                                  },
                                  "triggered_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "triggered_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "expires_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time",
                                    "description": "When a cancel was asked for, or null. A live stop loss keeps its status until Lean applies the cancel a moment later, then reads canceled."
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "market_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "type",
                                  "trigger_price",
                                  "quantity",
                                  "slippage_limit",
                                  "status",
                                  "triggered_at",
                                  "triggered_price",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "expires_at",
                                  "cancel_requested_at",
                                  "created_at",
                                  "updated_at",
                                  "livemode"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "stop_losses",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "stop_losses": [
                      {
                        "id": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "type": "stop_loss",
                        "trigger_price": "0.4",
                        "quantity": "25",
                        "slippage_limit": "0.05",
                        "status": "active",
                        "triggered_at": null,
                        "triggered_price": null,
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "expires_at": null,
                        "cancel_requested_at": null,
                        "created_at": "2026-11-10T15:00:00.000Z",
                        "updated_at": "2026-11-10T15:00:00.000Z",
                        "livemode": false
                      }
                    ],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/stop-losses/{id}": {
      "get": {
        "operationId": "getStopLoss",
        "summary": "Get a stop loss",
        "description": "One stop loss or take profit of this key’s trading account by id.",
        "tags": [
          "Stop losses"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The stop loss",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "stop_loss",
                                "take_profit"
                              ]
                            },
                            "trigger_price": {
                              "type": "string"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "slippage_limit": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "triggered",
                                "executing",
                                "filled",
                                "partial",
                                "canceled",
                                "expired",
                                "failed"
                              ]
                            },
                            "triggered_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "triggered_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live stop loss keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "type",
                            "trigger_price",
                            "quantity",
                            "slippage_limit",
                            "status",
                            "triggered_at",
                            "triggered_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "type": "stop_loss",
                    "trigger_price": "0.4",
                    "quantity": "25",
                    "slippage_limit": "0.05",
                    "status": "active",
                    "triggered_at": null,
                    "triggered_price": null,
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "updated_at": "2026-11-10T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateStopLoss",
        "summary": "Update a stop loss",
        "description": "Changes the trigger price, quantity or slippage limit of a stop loss or take profit that is still watching the market, keeping its id. Fields left out keep their values. The new values pass the same checks as at creation, and a larger sale books the added amount toward the rolling day, which never refuses a sale. A stop loss that has started selling, ended or has a cancel pending cannot be changed. A live stop loss answers with the edit applied; Lean moves the strategy to it a moment later. Every venue supports it.",
        "tags": [
          "Stop losses"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "trigger_price": {
                    "type": "string",
                    "description": "The new best bid, in dollars per share between 0.0001 and 0.9999, that starts the sale. As at creation, a stop_loss must stay below the current best bid and a take_profit above it."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "The new total shares to sell, counting any already sold. Together with the account’s other stop losses on these shares, at most what the account holds."
                  },
                  "slippage_limit": {
                    "type": "string",
                    "description": "How far below trigger_price the sale may fill, in dollars above 0 and at most 0.2, on the market’s price tick and below trigger_price."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "trigger_price": "0.38",
                "quantity": "30"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stop loss, with the edit applied",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "stop_loss",
                                "take_profit"
                              ]
                            },
                            "trigger_price": {
                              "type": "string"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "slippage_limit": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "triggered",
                                "executing",
                                "filled",
                                "partial",
                                "canceled",
                                "expired",
                                "failed"
                              ]
                            },
                            "triggered_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "triggered_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live stop loss keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "type",
                            "trigger_price",
                            "quantity",
                            "slippage_limit",
                            "status",
                            "triggered_at",
                            "triggered_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "type": "stop_loss",
                    "trigger_price": "0.38",
                    "quantity": "30",
                    "slippage_limit": "0.05",
                    "status": "active",
                    "triggered_at": null,
                    "triggered_price": null,
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "updated_at": "2026-11-10T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The new values are invalid for this market, the trigger price is one the best bid already meets, the quantity is more than the account holds beyond its other stop losses or less than already sold, or the stop loss is no longer watching",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "A cancel is already pending for the stop loss, another edit changed it while this one was being checked (try again), or the stop loss belongs to a conditional sell, which cannot be changed here",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is VENUE_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, Lean has paused stop losses on the venue, or the market’s book could not be read to check the trigger price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "cancelStopLoss",
        "summary": "Cancel a stop loss",
        "description": "Stops a stop loss or take profit from watching the market, and stops a sale it has started. Canceling works while trading is paused. A live stop loss answers with cancel_requested_at set and its status unchanged; it reads canceled a moment later, once Lean has applied the cancel. A test stop loss reads canceled at once.",
        "tags": [
          "Stop losses"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The stop loss, with its cancel requested",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "stop_loss",
                                "take_profit"
                              ]
                            },
                            "trigger_price": {
                              "type": "string"
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "slippage_limit": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "triggered",
                                "executing",
                                "filled",
                                "partial",
                                "canceled",
                                "expired",
                                "failed"
                              ]
                            },
                            "triggered_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "triggered_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live stop loss keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "type",
                            "trigger_price",
                            "quantity",
                            "slippage_limit",
                            "status",
                            "triggered_at",
                            "triggered_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "3c9d2e71-5a4b-4f08-b6e2-91d7c0a4f5e3",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "type": "stop_loss",
                    "trigger_price": "0.4",
                    "quantity": "25",
                    "slippage_limit": "0.05",
                    "status": "active",
                    "triggered_at": null,
                    "triggered_price": null,
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": "2026-11-10T15:05:00.000Z",
                    "created_at": "2026-11-10T15:00:00.000Z",
                    "updated_at": "2026-11-10T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The stop loss has already ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The stop loss has already ended"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The stop loss belongs to a conditional sell; cancel the conditional sell instead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The stop loss belongs to a conditional sell"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/limit-chases": {
      "post": {
        "operationId": "createLimitChase",
        "summary": "Create a limit chase",
        "description": "Rests a limit order on the request’s venue a set distance behind the best price on its own side, and moves it as that price moves until the order fills, is canceled or expires. A buy follows the best bid and a sell the best ask. The order never crosses the spread, and never rests beyond price_limit when one is given. It is booked against the calling key’s limits at the most it can trade for: a buy as an order of this quantity at price_limit, or at the top price of $1 a share without one, and a sell at that same top price. A buy is held to the per-order cap, the account’s venue allow list and the rolling day; a sell only takes risk off, so it counts toward the rolling day and is held to the venue allow list, but no notional limit refuses it. On a test key the limit chase follows the live book and fills, in simulation, once the opposite best price reaches it. Every venue runs limit chases.",
        "tags": [
          "Limit chases"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "The market to trade."
                  },
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid",
                      "lighter"
                    ],
                    "description": "The venue to rest the order on. Limit chases run on every venue but Lighter, which is refused with 422 and reason NO_EXECUTABLE_VENUE."
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "buy",
                      "sell"
                    ],
                    "description": "buy or sell."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Shares to buy or sell. A sell is at most what the account holds beyond its other resting sells and stop losses."
                  },
                  "offset_ticks": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10,
                    "description": "How many price ticks behind the best price on its own side the order rests, from 0 to 10. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_price": {
                    "type": "string",
                    "description": "How far behind the best price on its own side the order rests, in dollars from 0 to 0.1. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_shares": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "The most shares the order lets rest ahead of it in the queue, from 0 to 10,000,000 in steps of 0.01. The order rests one tick inside the first price level that would put more shares ahead of it. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_beat_best": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "Set to true to rest one tick better than the best price on its own side, so the order is first in the queue. It stops one tick short of the other side, so it never crosses the spread. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "price_limit": {
                    "type": "string",
                    "description": "The worst price the order rests at, in dollars between 0.0001 and 0.9999: a buy never rests above it and a sell never below it. Omit to follow the book wherever it goes."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the limit chase lapses if it has not filled, in UTC ending in Z, in the future and at most 30 days ahead. On Polymarket, and on any venue with a test key, it must be at least 2 minutes ahead. Omit to keep it until canceled."
                  }
                },
                "required": [
                  "market_id",
                  "venue",
                  "action",
                  "quantity"
                ],
                "additionalProperties": false
              },
              "example": {
                "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                "venue": "polymarket",
                "action": "buy",
                "quantity": "25",
                "offset_ticks": 1,
                "price_limit": "0.45"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The limit chase, following the book",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "offset_ticks": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10,
                              "description": "Ticks behind the best price, or null when the chase uses another offset."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the chase uses another offset."
                            },
                            "offset_shares": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most shares the order lets rest ahead of it in the queue, or null when the chase uses another offset."
                            },
                            "offset_beat_best": {
                              "type": "boolean",
                              "description": "True when the order rests one tick better than the best price on its own side."
                            },
                            "offset_midpoint": {
                              "type": "string",
                              "nullable": true,
                              "description": "For a limit chase made in the Lean app that rests as far back as it can within this many dollars of the midpoint, ignoring the best price on its own side. Null when the chase uses another offset. A request cannot set it."
                            },
                            "price_limit": {
                              "type": "string",
                              "nullable": true
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "filled",
                                "canceled",
                                "failed",
                                "expired"
                              ]
                            },
                            "current_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "The price the order rests at now, or null while it waits for a book to follow."
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live limit chase keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "edit_pending": {
                              "type": "boolean",
                              "nullable": true,
                              "description": "True while Lean has accepted an edit but not yet applied it; the other fields show the edited values meanwhile. A list can trail an edit accepted a moment earlier; read the limit chase by id to confirm."
                            },
                            "last_error": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why Lean last refused an edit or could not rest the order, or null. An edit Lean refuses, such as a smaller size that fills overtook, leaves the earlier values in place."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "quantity",
                            "offset_ticks",
                            "offset_price",
                            "offset_shares",
                            "offset_beat_best",
                            "offset_midpoint",
                            "price_limit",
                            "status",
                            "current_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "edit_pending",
                            "last_error",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "action": "buy",
                    "quantity": "25",
                    "offset_ticks": 1,
                    "offset_price": null,
                    "offset_shares": null,
                    "offset_beat_best": false,
                    "offset_midpoint": null,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "edit_pending": false,
                    "last_error": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The offset, price limit, quantity or expiry are invalid for this market, a test key’s buy costs more than its simulated balance, or a sell is more than the account holds beyond its other resting sells and stop losses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or a live key’s account cannot trade on the venue: no API key is connected for Kalshi or Polymarket US, or the Polymarket wallet is not set up or its approvals need refreshing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket account setup changed while the limit chase was being created; finish setup in the Lean app and send it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The Polymarket account setup changed while the limit chase was being created"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is NO_EXECUTABLE_VENUE, VENUE_NOT_ALLOWED, ORDER_NOTIONAL_LIMIT or DAILY_NOTIONAL_LIMIT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or Lean has paused limit chases on the venue for a live key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listLimitChases",
        "summary": "List limit chases",
        "description": "Limit chases of this key’s trading account in this key’s mode, newest first: every one still resting, and those that ended in the last hour.",
        "tags": [
          "Limit chases"
        ],
        "responses": {
          "200": {
            "description": "Limit chases, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "limit_chases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "action": {
                                    "type": "string",
                                    "enum": [
                                      "buy",
                                      "sell"
                                    ]
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "offset_ticks": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "maximum": 10,
                                    "description": "Ticks behind the best price, or null when the chase uses another offset."
                                  },
                                  "offset_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Dollars behind the best price, or null when the chase uses another offset."
                                  },
                                  "offset_shares": {
                                    "type": "string",
                                    "nullable": true,
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "The most shares the order lets rest ahead of it in the queue, or null when the chase uses another offset."
                                  },
                                  "offset_beat_best": {
                                    "type": "boolean",
                                    "description": "True when the order rests one tick better than the best price on its own side."
                                  },
                                  "offset_midpoint": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "For a limit chase made in the Lean app that rests as far back as it can within this many dollars of the midpoint, ignoring the best price on its own side. Null when the chase uses another offset. A request cannot set it."
                                  },
                                  "price_limit": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "active",
                                      "filled",
                                      "canceled",
                                      "failed",
                                      "expired"
                                    ]
                                  },
                                  "current_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "The price the order rests at now, or null while it waits for a book to follow."
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "expires_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "cancel_requested_at": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time",
                                    "description": "When a cancel was asked for, or null. A live limit chase keeps its status until Lean applies the cancel a moment later, then reads canceled."
                                  },
                                  "edit_pending": {
                                    "type": "boolean",
                                    "nullable": true,
                                    "description": "True while Lean has accepted an edit but not yet applied it; the other fields show the edited values meanwhile. A list can trail an edit accepted a moment earlier; read the limit chase by id to confirm."
                                  },
                                  "last_error": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Why Lean last refused an edit or could not rest the order, or null. An edit Lean refuses, such as a smaller size that fills overtook, leaves the earlier values in place."
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "market_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "action",
                                  "quantity",
                                  "offset_ticks",
                                  "offset_price",
                                  "offset_shares",
                                  "offset_beat_best",
                                  "offset_midpoint",
                                  "price_limit",
                                  "status",
                                  "current_price",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "expires_at",
                                  "cancel_requested_at",
                                  "edit_pending",
                                  "last_error",
                                  "created_at",
                                  "updated_at",
                                  "livemode"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "limit_chases",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "limit_chases": [
                      {
                        "id": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                        "venue": "polymarket",
                        "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                        "side": "yes",
                        "action": "buy",
                        "quantity": "25",
                        "offset_ticks": 1,
                        "offset_price": null,
                        "offset_shares": null,
                        "offset_beat_best": false,
                        "offset_midpoint": null,
                        "price_limit": "0.45",
                        "status": "active",
                        "current_price": "0.39",
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "expires_at": null,
                        "cancel_requested_at": null,
                        "edit_pending": false,
                        "last_error": null,
                        "created_at": "2026-11-11T15:00:00.000Z",
                        "updated_at": "2026-11-11T15:00:00.000Z",
                        "livemode": false
                      }
                    ],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/limit-chases/{id}": {
      "get": {
        "operationId": "getLimitChase",
        "summary": "Get a limit chase",
        "description": "One limit chase of this key’s trading account by id.",
        "tags": [
          "Limit chases"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The limit chase",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "offset_ticks": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10,
                              "description": "Ticks behind the best price, or null when the chase uses another offset."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the chase uses another offset."
                            },
                            "offset_shares": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most shares the order lets rest ahead of it in the queue, or null when the chase uses another offset."
                            },
                            "offset_beat_best": {
                              "type": "boolean",
                              "description": "True when the order rests one tick better than the best price on its own side."
                            },
                            "offset_midpoint": {
                              "type": "string",
                              "nullable": true,
                              "description": "For a limit chase made in the Lean app that rests as far back as it can within this many dollars of the midpoint, ignoring the best price on its own side. Null when the chase uses another offset. A request cannot set it."
                            },
                            "price_limit": {
                              "type": "string",
                              "nullable": true
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "filled",
                                "canceled",
                                "failed",
                                "expired"
                              ]
                            },
                            "current_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "The price the order rests at now, or null while it waits for a book to follow."
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live limit chase keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "edit_pending": {
                              "type": "boolean",
                              "nullable": true,
                              "description": "True while Lean has accepted an edit but not yet applied it; the other fields show the edited values meanwhile. A list can trail an edit accepted a moment earlier; read the limit chase by id to confirm."
                            },
                            "last_error": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why Lean last refused an edit or could not rest the order, or null. An edit Lean refuses, such as a smaller size that fills overtook, leaves the earlier values in place."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "quantity",
                            "offset_ticks",
                            "offset_price",
                            "offset_shares",
                            "offset_beat_best",
                            "offset_midpoint",
                            "price_limit",
                            "status",
                            "current_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "edit_pending",
                            "last_error",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "action": "buy",
                    "quantity": "25",
                    "offset_ticks": 1,
                    "offset_price": null,
                    "offset_shares": null,
                    "offset_beat_best": false,
                    "offset_midpoint": null,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "edit_pending": false,
                    "last_error": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateLimitChase",
        "summary": "Update a limit chase",
        "description": "Changes the quantity, offset or price limit of a limit chase that is still resting, keeping its id. Fields left out keep their values, and giving one offset replaces the current one. quantity is the new total, counting what has already filled. The new values pass the same checks as at creation, with one difference: shares that can still fill on either the current or the edited values, or on the chase’s resting order at the size it still rests at, up to the new quantity, are counted at the highest of the old price limit, the new price limit and the price that order is resting at, because that order can fill before Lean moves or resizes it. Shares that have filled count at what they cost. A buy is checked as a whole on that basis against the per-order cap, and whatever the edit adds to the most the chase can trade for counts toward the rolling day: a larger size, a higher or removed price limit on a buy, or any edit while the order still rests above a lowered price limit. On Kalshi, the order is amended in place rather than canceled and placed again, so a smaller size at the same price keeps its place in the queue. A limit chase that has ended or has a cancel pending cannot be changed. A live limit chase answers with the edited values and edit_pending true; Lean moves the resting order a moment later. Read it by id to confirm: edit_pending turns false once Lean applies the edit, and another edit is refused until then. If Lean refuses it, for example because fills overtook a smaller size, the earlier values stay and last_error says why. Every venue supports it.",
        "tags": [
          "Limit chases"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "The new total shares, counting what has already filled. It cannot be less than the filled quantity."
                  },
                  "offset_ticks": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10,
                    "description": "How many price ticks behind the best price on its own side the order rests, from 0 to 10. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_price": {
                    "type": "string",
                    "description": "How far behind the best price on its own side the order rests, in dollars from 0 to 0.1. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_shares": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "The most shares the order lets rest ahead of it in the queue, from 0 to 10,000,000 in steps of 0.01. The order rests one tick inside the first price level that would put more shares ahead of it. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "offset_beat_best": {
                    "type": "boolean",
                    "enum": [
                      true
                    ],
                    "description": "Set to true to rest one tick better than the best price on its own side, so the order is first in the queue. It stops one tick short of the other side, so it never crosses the spread. Give at most one of offset_ticks, offset_price, offset_shares and offset_beat_best."
                  },
                  "price_limit": {
                    "type": "string",
                    "nullable": true,
                    "description": "The new worst price the order rests at, in dollars between 0.0001 and 0.9999. Send null to remove the limit and follow the book wherever it goes."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "quantity": "40",
                "offset_beat_best": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The limit chase, with the edit accepted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "offset_ticks": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10,
                              "description": "Ticks behind the best price, or null when the chase uses another offset."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the chase uses another offset."
                            },
                            "offset_shares": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most shares the order lets rest ahead of it in the queue, or null when the chase uses another offset."
                            },
                            "offset_beat_best": {
                              "type": "boolean",
                              "description": "True when the order rests one tick better than the best price on its own side."
                            },
                            "offset_midpoint": {
                              "type": "string",
                              "nullable": true,
                              "description": "For a limit chase made in the Lean app that rests as far back as it can within this many dollars of the midpoint, ignoring the best price on its own side. Null when the chase uses another offset. A request cannot set it."
                            },
                            "price_limit": {
                              "type": "string",
                              "nullable": true
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "filled",
                                "canceled",
                                "failed",
                                "expired"
                              ]
                            },
                            "current_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "The price the order rests at now, or null while it waits for a book to follow."
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live limit chase keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "edit_pending": {
                              "type": "boolean",
                              "nullable": true,
                              "description": "True while Lean has accepted an edit but not yet applied it; the other fields show the edited values meanwhile. A list can trail an edit accepted a moment earlier; read the limit chase by id to confirm."
                            },
                            "last_error": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why Lean last refused an edit or could not rest the order, or null. An edit Lean refuses, such as a smaller size that fills overtook, leaves the earlier values in place."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "quantity",
                            "offset_ticks",
                            "offset_price",
                            "offset_shares",
                            "offset_beat_best",
                            "offset_midpoint",
                            "price_limit",
                            "status",
                            "current_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "edit_pending",
                            "last_error",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "action": "buy",
                    "quantity": "40",
                    "offset_ticks": null,
                    "offset_price": null,
                    "offset_shares": null,
                    "offset_beat_best": true,
                    "offset_midpoint": null,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": null,
                    "edit_pending": true,
                    "last_error": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The offset, price limit or quantity are invalid for this market, the quantity is less than already filled, a test key’s buy costs more than its simulated balance, a sell is more than the account holds beyond its other resting sells and stop losses, or the limit chase has ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "A cancel is already pending for the limit chase, an earlier edit has not been applied yet (edit_pending is true), another edit changed it while this one was being checked, or its resting order moved above the price or size this edit was checked at; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The request conflicts with the current state"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is VENUE_NOT_ALLOWED, ORDER_NOTIONAL_LIMIT or DAILY_NOTIONAL_LIMIT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, or Lean has paused limit chases on the venue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "Trading is paused for this key or its trading account, or Lean has paused limit chases on the venue"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "cancelLimitChase",
        "summary": "Cancel a limit chase",
        "description": "Stops a limit chase and cancels its resting order. Shares it already bought or sold stay with the account. Canceling works while trading is paused. A live limit chase answers with cancel_requested_at set and its status unchanged; it reads canceled a moment later, once Lean has applied the cancel. A test limit chase reads canceled at once.",
        "tags": [
          "Limit chases"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The limit chase, with its cancel requested",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "market_id": {
                              "type": "string",
                              "nullable": true,
                              "minLength": 1
                            },
                            "venue": {
                              "type": "string",
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "ticker": {
                              "type": "string",
                              "minLength": 1
                            },
                            "side": {
                              "type": "string",
                              "enum": [
                                "yes",
                                "no"
                              ]
                            },
                            "action": {
                              "type": "string",
                              "enum": [
                                "buy",
                                "sell"
                              ]
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "offset_ticks": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10,
                              "description": "Ticks behind the best price, or null when the chase uses another offset."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the chase uses another offset."
                            },
                            "offset_shares": {
                              "type": "string",
                              "nullable": true,
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most shares the order lets rest ahead of it in the queue, or null when the chase uses another offset."
                            },
                            "offset_beat_best": {
                              "type": "boolean",
                              "description": "True when the order rests one tick better than the best price on its own side."
                            },
                            "offset_midpoint": {
                              "type": "string",
                              "nullable": true,
                              "description": "For a limit chase made in the Lean app that rests as far back as it can within this many dollars of the midpoint, ignoring the best price on its own side. Null when the chase uses another offset. A request cannot set it."
                            },
                            "price_limit": {
                              "type": "string",
                              "nullable": true
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "filled",
                                "canceled",
                                "failed",
                                "expired"
                              ]
                            },
                            "current_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "The price the order rests at now, or null while it waits for a book to follow."
                            },
                            "filled_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "avg_fill_price": {
                              "type": "string",
                              "nullable": true
                            },
                            "expires_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "cancel_requested_at": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time",
                              "description": "When a cancel was asked for, or null. A live limit chase keeps its status until Lean applies the cancel a moment later, then reads canceled."
                            },
                            "edit_pending": {
                              "type": "boolean",
                              "nullable": true,
                              "description": "True while Lean has accepted an edit but not yet applied it; the other fields show the edited values meanwhile. A list can trail an edit accepted a moment earlier; read the limit chase by id to confirm."
                            },
                            "last_error": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why Lean last refused an edit or could not rest the order, or null. An edit Lean refuses, such as a smaller size that fills overtook, leaves the earlier values in place."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "market_id",
                            "venue",
                            "ticker",
                            "side",
                            "action",
                            "quantity",
                            "offset_ticks",
                            "offset_price",
                            "offset_shares",
                            "offset_beat_best",
                            "offset_midpoint",
                            "price_limit",
                            "status",
                            "current_price",
                            "filled_quantity",
                            "avg_fill_price",
                            "expires_at",
                            "cancel_requested_at",
                            "edit_pending",
                            "last_error",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "7b2f4e19-0c6d-4a83-9e51-d4a8b3c2f706",
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venue": "polymarket",
                    "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                    "side": "yes",
                    "action": "buy",
                    "quantity": "25",
                    "offset_ticks": 1,
                    "offset_price": null,
                    "offset_shares": null,
                    "offset_beat_best": false,
                    "offset_midpoint": null,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": "2026-11-11T15:05:00.000Z",
                    "edit_pending": false,
                    "last_error": null,
                    "created_at": "2026-11-11T15:00:00.000Z",
                    "updated_at": "2026-11-11T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The limit chase has already ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The limit chase has already ended"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/conditional-sells": {
      "post": {
        "operationId": "createConditionalSell",
        "summary": "Create a conditional sell",
        "description": "Sells a leader position and, as it fills, sells the same number of shares of each follower position, never below the follower’s floor price. A limit leader rests a sell at limit_price at once; a stop leader waits until its best bid falls to trigger_price, then sells down to trigger_price minus slippage_limit. With a limit leader, the conditional sell pauses while a follower’s book holds too little at or above its floor, and resumes by itself once that depth has held for 5 seconds; a live key’s create can answer paused for that reason. Every leg is a different position this key’s trading account holds, on a venue its allow list includes, and each must hold the quantity beyond the account’s other resting sells, stop losses and conditional sells. The sale is booked as orders at the leader’s lowest price and each follower’s floor would be: it counts toward the rolling day and is held to the venue allow list, but as a sale it only takes risk off, so no notional limit refuses it. On a test key the conditional sell is checked, recorded, listed and booked but never sells. Kalshi, Polymarket, Polymarket US and Hyperliquid run conditional sells.",
        "tags": [
          "Conditional sells"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "leader": {
                    "type": "object",
                    "properties": {
                      "market_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "description": "The market whose shares the leader sells."
                      },
                      "venue": {
                        "type": "string",
                        "enum": [
                          "kalshi",
                          "polymarket",
                          "polymarket_us",
                          "hyperliquid",
                          "lighter"
                        ],
                        "description": "The venue holding the leader’s shares. Lighter is refused with 422 and reason NO_EXECUTABLE_VENUE."
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "limit",
                          "stop"
                        ],
                        "description": "limit rests a sell at limit_price at once; stop sells nothing until the best bid falls to trigger_price, then sells down to trigger_price minus slippage_limit."
                      },
                      "limit_price": {
                        "type": "string",
                        "description": "For a limit leader, the price the sell rests at, in dollars between 0.0001 and 0.9999 on the market’s price tick."
                      },
                      "trigger_price": {
                        "type": "string",
                        "description": "For a stop leader, the best bid that starts the sale, in dollars between 0.0001 and 0.9999. It must be below the current best bid, or the sale would start at once."
                      },
                      "slippage_limit": {
                        "type": "string",
                        "description": "For a stop leader, how far below trigger_price the sale may fill, in dollars above 0 and at most 0.2, below trigger_price. Defaults to 0.05."
                      }
                    },
                    "required": [
                      "market_id",
                      "venue",
                      "type"
                    ],
                    "additionalProperties": false,
                    "description": "The position whose sale drives the rest."
                  },
                  "quantity": {
                    "type": "string",
                    "pattern": "^\\d+(?:\\.\\d+)?$",
                    "description": "Shares the leader sells. Each follower sells the same count as the leader fills, so every leg’s position must cover it beyond the account’s other resting sells, stop losses and conditional sells."
                  },
                  "followers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "market_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 512,
                          "description": "The market whose shares the follower sells."
                        },
                        "venue": {
                          "type": "string",
                          "enum": [
                            "kalshi",
                            "polymarket",
                            "polymarket_us",
                            "hyperliquid",
                            "lighter"
                          ],
                          "description": "The venue holding the follower’s shares. Lighter is refused with 422 and reason NO_EXECUTABLE_VENUE."
                        },
                        "floor_price": {
                          "type": "string",
                          "description": "The lowest price the follower sells at, in dollars between 0.0001 and 0.9999 on the market’s price tick. A test key also needs it at or below the follower’s current best bid. With a limit leader, the conditional sell pauses while the book holds too little at or above it."
                        }
                      },
                      "required": [
                        "market_id",
                        "venue",
                        "floor_price"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 5,
                    "description": "From 1 to 5 positions to sell as the leader fills. Every leg, leader included, is a different position."
                  }
                },
                "required": [
                  "leader",
                  "quantity",
                  "followers"
                ],
                "additionalProperties": false
              },
              "example": {
                "leader": {
                  "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                  "venue": "polymarket",
                  "type": "limit",
                  "limit_price": "0.62"
                },
                "quantity": "25",
                "followers": [
                  {
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwptb25leWxpbmU6Z2FtZTpERU4",
                    "venue": "kalshi",
                    "floor_price": "0.55"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The conditional sell, selling, waiting or paused for a follower’s floor",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "paused",
                                "hedging",
                                "canceled",
                                "filled"
                              ],
                              "description": "active: the leader is selling or waiting. paused: selling stopped for pause_reason. hedging: the leader is done and followers are still selling. canceled or filled: ended."
                            },
                            "pause_reason": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "user",
                                "floor",
                                "ceiling",
                                "leader_unconfirmed",
                                "leader_ended",
                                "leader_account_changed",
                                "leader_rejected"
                              ],
                              "description": "Why a paused conditional sell stopped: floor when a follower’s book holds too little at or above its floor, user when it was paused in the app, or a leader_ reason when the venue did not confirm, ended or refused the leader order."
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "leader": {
                              "type": "object",
                              "properties": {
                                "market_id": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "kalshi",
                                    "polymarket",
                                    "polymarket_us",
                                    "hyperliquid"
                                  ]
                                },
                                "ticker": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "side": {
                                  "type": "string",
                                  "enum": [
                                    "yes",
                                    "no"
                                  ]
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "limit",
                                    "stop"
                                  ]
                                },
                                "limit_price": {
                                  "type": "string",
                                  "description": "The lowest price the leader sells at: limit_price for a limit leader, trigger_price minus slippage_limit for a stop."
                                },
                                "trigger_price": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "slippage_limit": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "filled_quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "avg_fill_price": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "market_id",
                                "venue",
                                "ticker",
                                "side",
                                "type",
                                "limit_price",
                                "trigger_price",
                                "slippage_limit",
                                "filled_quantity",
                                "avg_fill_price"
                              ]
                            },
                            "followers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "floor_price": {
                                    "type": "string"
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "idle",
                                      "selling",
                                      "retrying",
                                      "below_minimum",
                                      "failed",
                                      "done"
                                    ],
                                    "description": "idle: nothing to sell yet. selling: a sell is working. retrying: a sell failed and another will be sent. below_minimum: the shares owed are under the venue minimum and wait for more leader fills. failed: out of retries, so the shares stay unsold. done: every share owed is sold."
                                  },
                                  "dispatched_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "unhedged_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares the leader has sold that this follower has not sold yet."
                                  },
                                  "failed_attempts": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "id",
                                  "market_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "floor_price",
                                  "state",
                                  "dispatched_quantity",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "unhedged_quantity",
                                  "failed_attempts"
                                ]
                              }
                            },
                            "unhedged_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most leader shares sold that any follower has not sold yet."
                            },
                            "reject_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why the venue refused the first leader order, which canceled the conditional sell."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "status",
                            "pause_reason",
                            "quantity",
                            "leader",
                            "followers",
                            "unhedged_quantity",
                            "reject_reason",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30",
                    "status": "active",
                    "pause_reason": null,
                    "quantity": "25",
                    "leader": {
                      "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                      "venue": "polymarket",
                      "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                      "side": "yes",
                      "type": "limit",
                      "limit_price": "0.62",
                      "trigger_price": null,
                      "slippage_limit": null,
                      "filled_quantity": "0",
                      "avg_fill_price": null
                    },
                    "followers": [
                      {
                        "id": "9e41c7a2-3b58-4f6d-a0e9-7c2d5b18f364",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwptb25leWxpbmU6Z2FtZTpERU4",
                        "venue": "kalshi",
                        "ticker": "KXNFLGAME-26OCT11DENLAC-DEN",
                        "side": "yes",
                        "floor_price": "0.55",
                        "state": "idle",
                        "dispatched_quantity": "0",
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "unhedged_quantity": "0",
                        "failed_attempts": 0
                      }
                    ],
                    "unhedged_quantity": "0",
                    "reject_reason": null,
                    "created_at": "2026-11-17T15:00:00.000Z",
                    "updated_at": "2026-11-17T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "The prices or quantity are invalid for a leg’s market, a leg’s market is not open, two legs are the same position, a stop leader’s trigger price is at or above its best bid, a leg holds less than the quantity beyond the account’s other sells, or, with a test key only, a follower has no bid or a floor above its best bid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the trade scope, or a live key’s account cannot trade on a leg’s venue: no API key is connected for Kalshi or Polymarket US, or the Polymarket wallet is not set up or its approvals need refreshing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The Polymarket account setup changed while the conditional sell was being created; finish setup in the Lean app and send it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The Polymarket account setup changed while the conditional sell was being created"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "details.reason is NO_EXECUTABLE_VENUE or VENUE_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Refused by a limit; nothing was changed"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Trading is paused for this key or its trading account, Lean has paused managed orders on a leg’s venue, or a leg’s book could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "A required service is temporarily unavailable."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listConditionalSells",
        "summary": "List conditional sells",
        "description": "Conditional sells of this key’s trading account in this key’s mode, newest first: every one still selling, waiting or paused, and those that ended in the last day.",
        "tags": [
          "Conditional sells"
        ],
        "responses": {
          "200": {
            "description": "Conditional sells, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "conditional_sells": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "active",
                                      "paused",
                                      "hedging",
                                      "canceled",
                                      "filled"
                                    ],
                                    "description": "active: the leader is selling or waiting. paused: selling stopped for pause_reason. hedging: the leader is done and followers are still selling. canceled or filled: ended."
                                  },
                                  "pause_reason": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "user",
                                      "floor",
                                      "ceiling",
                                      "leader_unconfirmed",
                                      "leader_ended",
                                      "leader_account_changed",
                                      "leader_rejected"
                                    ],
                                    "description": "Why a paused conditional sell stopped: floor when a follower’s book holds too little at or above its floor, user when it was paused in the app, or a leader_ reason when the venue did not confirm, ended or refused the leader order."
                                  },
                                  "quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "leader": {
                                    "type": "object",
                                    "properties": {
                                      "market_id": {
                                        "type": "string",
                                        "nullable": true,
                                        "minLength": 1
                                      },
                                      "venue": {
                                        "type": "string",
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid"
                                        ]
                                      },
                                      "ticker": {
                                        "type": "string",
                                        "minLength": 1
                                      },
                                      "side": {
                                        "type": "string",
                                        "enum": [
                                          "yes",
                                          "no"
                                        ]
                                      },
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "limit",
                                          "stop"
                                        ]
                                      },
                                      "limit_price": {
                                        "type": "string",
                                        "description": "The lowest price the leader sells at: limit_price for a limit leader, trigger_price minus slippage_limit for a stop."
                                      },
                                      "trigger_price": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "slippage_limit": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "filled_quantity": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$"
                                      },
                                      "avg_fill_price": {
                                        "type": "string",
                                        "nullable": true
                                      }
                                    },
                                    "required": [
                                      "market_id",
                                      "venue",
                                      "ticker",
                                      "side",
                                      "type",
                                      "limit_price",
                                      "trigger_price",
                                      "slippage_limit",
                                      "filled_quantity",
                                      "avg_fill_price"
                                    ]
                                  },
                                  "followers": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "market_id": {
                                          "type": "string",
                                          "nullable": true,
                                          "minLength": 1
                                        },
                                        "venue": {
                                          "type": "string",
                                          "enum": [
                                            "kalshi",
                                            "polymarket",
                                            "polymarket_us",
                                            "hyperliquid"
                                          ]
                                        },
                                        "ticker": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "side": {
                                          "type": "string",
                                          "enum": [
                                            "yes",
                                            "no"
                                          ]
                                        },
                                        "floor_price": {
                                          "type": "string"
                                        },
                                        "state": {
                                          "type": "string",
                                          "enum": [
                                            "idle",
                                            "selling",
                                            "retrying",
                                            "below_minimum",
                                            "failed",
                                            "done"
                                          ],
                                          "description": "idle: nothing to sell yet. selling: a sell is working. retrying: a sell failed and another will be sent. below_minimum: the shares owed are under the venue minimum and wait for more leader fills. failed: out of retries, so the shares stay unsold. done: every share owed is sold."
                                        },
                                        "dispatched_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "filled_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$"
                                        },
                                        "avg_fill_price": {
                                          "type": "string",
                                          "nullable": true
                                        },
                                        "unhedged_quantity": {
                                          "type": "string",
                                          "pattern": "^\\d+(?:\\.\\d+)?$",
                                          "description": "Shares the leader has sold that this follower has not sold yet."
                                        },
                                        "failed_attempts": {
                                          "type": "integer",
                                          "minimum": 0
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "market_id",
                                        "venue",
                                        "ticker",
                                        "side",
                                        "floor_price",
                                        "state",
                                        "dispatched_quantity",
                                        "filled_quantity",
                                        "avg_fill_price",
                                        "unhedged_quantity",
                                        "failed_attempts"
                                      ]
                                    }
                                  },
                                  "unhedged_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "The most leader shares sold that any follower has not sold yet."
                                  },
                                  "reject_reason": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Why the venue refused the first leader order, which canceled the conditional sell."
                                  },
                                  "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "updated_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "livemode": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "pause_reason",
                                  "quantity",
                                  "leader",
                                  "followers",
                                  "unhedged_quantity",
                                  "reject_reason",
                                  "created_at",
                                  "updated_at",
                                  "livemode"
                                ]
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "conditional_sells",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "conditional_sells": [
                      {
                        "id": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30",
                        "status": "active",
                        "pause_reason": null,
                        "quantity": "25",
                        "leader": {
                          "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                          "venue": "polymarket",
                          "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                          "side": "yes",
                          "type": "limit",
                          "limit_price": "0.62",
                          "trigger_price": null,
                          "slippage_limit": null,
                          "filled_quantity": "0",
                          "avg_fill_price": null
                        },
                        "followers": [
                          {
                            "id": "9e41c7a2-3b58-4f6d-a0e9-7c2d5b18f364",
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwptb25leWxpbmU6Z2FtZTpERU4",
                            "venue": "kalshi",
                            "ticker": "KXNFLGAME-26OCT11DENLAC-DEN",
                            "side": "yes",
                            "floor_price": "0.55",
                            "state": "idle",
                            "dispatched_quantity": "0",
                            "filled_quantity": "0",
                            "avg_fill_price": null,
                            "unhedged_quantity": "0",
                            "failed_attempts": 0
                          }
                        ],
                        "unhedged_quantity": "0",
                        "reject_reason": null,
                        "created_at": "2026-11-17T15:00:00.000Z",
                        "updated_at": "2026-11-17T15:00:00.000Z",
                        "livemode": false
                      }
                    ],
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/conditional-sells/{id}": {
      "get": {
        "operationId": "getConditionalSell",
        "summary": "Get a conditional sell",
        "description": "One conditional sell of this key’s trading account by id.",
        "tags": [
          "Conditional sells"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The conditional sell",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "paused",
                                "hedging",
                                "canceled",
                                "filled"
                              ],
                              "description": "active: the leader is selling or waiting. paused: selling stopped for pause_reason. hedging: the leader is done and followers are still selling. canceled or filled: ended."
                            },
                            "pause_reason": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "user",
                                "floor",
                                "ceiling",
                                "leader_unconfirmed",
                                "leader_ended",
                                "leader_account_changed",
                                "leader_rejected"
                              ],
                              "description": "Why a paused conditional sell stopped: floor when a follower’s book holds too little at or above its floor, user when it was paused in the app, or a leader_ reason when the venue did not confirm, ended or refused the leader order."
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "leader": {
                              "type": "object",
                              "properties": {
                                "market_id": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "kalshi",
                                    "polymarket",
                                    "polymarket_us",
                                    "hyperliquid"
                                  ]
                                },
                                "ticker": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "side": {
                                  "type": "string",
                                  "enum": [
                                    "yes",
                                    "no"
                                  ]
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "limit",
                                    "stop"
                                  ]
                                },
                                "limit_price": {
                                  "type": "string",
                                  "description": "The lowest price the leader sells at: limit_price for a limit leader, trigger_price minus slippage_limit for a stop."
                                },
                                "trigger_price": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "slippage_limit": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "filled_quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "avg_fill_price": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "market_id",
                                "venue",
                                "ticker",
                                "side",
                                "type",
                                "limit_price",
                                "trigger_price",
                                "slippage_limit",
                                "filled_quantity",
                                "avg_fill_price"
                              ]
                            },
                            "followers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "floor_price": {
                                    "type": "string"
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "idle",
                                      "selling",
                                      "retrying",
                                      "below_minimum",
                                      "failed",
                                      "done"
                                    ],
                                    "description": "idle: nothing to sell yet. selling: a sell is working. retrying: a sell failed and another will be sent. below_minimum: the shares owed are under the venue minimum and wait for more leader fills. failed: out of retries, so the shares stay unsold. done: every share owed is sold."
                                  },
                                  "dispatched_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "unhedged_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares the leader has sold that this follower has not sold yet."
                                  },
                                  "failed_attempts": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "id",
                                  "market_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "floor_price",
                                  "state",
                                  "dispatched_quantity",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "unhedged_quantity",
                                  "failed_attempts"
                                ]
                              }
                            },
                            "unhedged_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most leader shares sold that any follower has not sold yet."
                            },
                            "reject_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why the venue refused the first leader order, which canceled the conditional sell."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "status",
                            "pause_reason",
                            "quantity",
                            "leader",
                            "followers",
                            "unhedged_quantity",
                            "reject_reason",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30",
                    "status": "active",
                    "pause_reason": null,
                    "quantity": "25",
                    "leader": {
                      "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                      "venue": "polymarket",
                      "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                      "side": "yes",
                      "type": "limit",
                      "limit_price": "0.62",
                      "trigger_price": null,
                      "slippage_limit": null,
                      "filled_quantity": "0",
                      "avg_fill_price": null
                    },
                    "followers": [
                      {
                        "id": "9e41c7a2-3b58-4f6d-a0e9-7c2d5b18f364",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwptb25leWxpbmU6Z2FtZTpERU4",
                        "venue": "kalshi",
                        "ticker": "KXNFLGAME-26OCT11DENLAC-DEN",
                        "side": "yes",
                        "floor_price": "0.55",
                        "state": "idle",
                        "dispatched_quantity": "0",
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "unhedged_quantity": "0",
                        "failed_attempts": 0
                      }
                    ],
                    "unhedged_quantity": "0",
                    "reject_reason": null,
                    "created_at": "2026-11-17T15:00:00.000Z",
                    "updated_at": "2026-11-17T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "cancelConditionalSell",
        "summary": "Cancel a conditional sell",
        "description": "Stops a conditional sell: Lean cancels its resting leader sell and any follower sells still working. Shares already sold stay sold. Canceling works while trading is paused. The answer reads canceled.",
        "tags": [
          "Conditional sells"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "example": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The conditional sell, canceled",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "active",
                                "paused",
                                "hedging",
                                "canceled",
                                "filled"
                              ],
                              "description": "active: the leader is selling or waiting. paused: selling stopped for pause_reason. hedging: the leader is done and followers are still selling. canceled or filled: ended."
                            },
                            "pause_reason": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "user",
                                "floor",
                                "ceiling",
                                "leader_unconfirmed",
                                "leader_ended",
                                "leader_account_changed",
                                "leader_rejected"
                              ],
                              "description": "Why a paused conditional sell stopped: floor when a follower’s book holds too little at or above its floor, user when it was paused in the app, or a leader_ reason when the venue did not confirm, ended or refused the leader order."
                            },
                            "quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$"
                            },
                            "leader": {
                              "type": "object",
                              "properties": {
                                "market_id": {
                                  "type": "string",
                                  "nullable": true,
                                  "minLength": 1
                                },
                                "venue": {
                                  "type": "string",
                                  "enum": [
                                    "kalshi",
                                    "polymarket",
                                    "polymarket_us",
                                    "hyperliquid"
                                  ]
                                },
                                "ticker": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "side": {
                                  "type": "string",
                                  "enum": [
                                    "yes",
                                    "no"
                                  ]
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "limit",
                                    "stop"
                                  ]
                                },
                                "limit_price": {
                                  "type": "string",
                                  "description": "The lowest price the leader sells at: limit_price for a limit leader, trigger_price minus slippage_limit for a stop."
                                },
                                "trigger_price": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "slippage_limit": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "filled_quantity": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "avg_fill_price": {
                                  "type": "string",
                                  "nullable": true
                                }
                              },
                              "required": [
                                "market_id",
                                "venue",
                                "ticker",
                                "side",
                                "type",
                                "limit_price",
                                "trigger_price",
                                "slippage_limit",
                                "filled_quantity",
                                "avg_fill_price"
                              ]
                            },
                            "followers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "market_id": {
                                    "type": "string",
                                    "nullable": true,
                                    "minLength": 1
                                  },
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "floor_price": {
                                    "type": "string"
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "idle",
                                      "selling",
                                      "retrying",
                                      "below_minimum",
                                      "failed",
                                      "done"
                                    ],
                                    "description": "idle: nothing to sell yet. selling: a sell is working. retrying: a sell failed and another will be sent. below_minimum: the shares owed are under the venue minimum and wait for more leader fills. failed: out of retries, so the shares stay unsold. done: every share owed is sold."
                                  },
                                  "dispatched_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "filled_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$"
                                  },
                                  "avg_fill_price": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "unhedged_quantity": {
                                    "type": "string",
                                    "pattern": "^\\d+(?:\\.\\d+)?$",
                                    "description": "Shares the leader has sold that this follower has not sold yet."
                                  },
                                  "failed_attempts": {
                                    "type": "integer",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "id",
                                  "market_id",
                                  "venue",
                                  "ticker",
                                  "side",
                                  "floor_price",
                                  "state",
                                  "dispatched_quantity",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "unhedged_quantity",
                                  "failed_attempts"
                                ]
                              }
                            },
                            "unhedged_quantity": {
                              "type": "string",
                              "pattern": "^\\d+(?:\\.\\d+)?$",
                              "description": "The most leader shares sold that any follower has not sold yet."
                            },
                            "reject_reason": {
                              "type": "string",
                              "nullable": true,
                              "description": "Why the venue refused the first leader order, which canceled the conditional sell."
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "status",
                            "pause_reason",
                            "quantity",
                            "leader",
                            "followers",
                            "unhedged_quantity",
                            "reject_reason",
                            "created_at",
                            "updated_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "5b2f8c14-7d3e-4a91-8c06-e4f1a9d27b30",
                    "status": "canceled",
                    "pause_reason": null,
                    "quantity": "25",
                    "leader": {
                      "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                      "venue": "polymarket",
                      "ticker": "pm:0x2222222222222222222222222222222222222222222222222222222222222222",
                      "side": "yes",
                      "type": "limit",
                      "limit_price": "0.62",
                      "trigger_price": null,
                      "slippage_limit": null,
                      "filled_quantity": "0",
                      "avg_fill_price": null
                    },
                    "followers": [
                      {
                        "id": "9e41c7a2-3b58-4f6d-a0e9-7c2d5b18f364",
                        "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwptb25leWxpbmU6Z2FtZTpERU4",
                        "venue": "kalshi",
                        "ticker": "KXNFLGAME-26OCT11DENLAC-DEN",
                        "side": "yes",
                        "floor_price": "0.55",
                        "state": "idle",
                        "dispatched_quantity": "0",
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "unhedged_quantity": "0",
                        "failed_attempts": 0
                      }
                    ],
                    "unhedged_quantity": "0",
                    "reject_reason": null,
                    "created_at": "2026-11-17T15:00:00.000Z",
                    "updated_at": "2026-11-17T15:00:00.000Z",
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The conditional sell has already ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The conditional sell has already ended"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/account/config": {
      "get": {
        "operationId": "getAccountConfig",
        "summary": "Get account configuration",
        "description": "What this key may do, the spend limits an order placed with it is held to, where they come from, how much of the rolling 24 hour limit is left, the venues the account allows, its slippage cap, if it sets one, and whether trading is paused. `venues` gives each venue’s connection status: `ready`, `not_configured` or `unavailable`. It covers Kalshi, Polymarket, Polymarket US, Hyperliquid and Lighter.",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "Configuration of the key and its trading account",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "read",
                                  "trade",
                                  "route",
                                  "withdraw"
                                ]
                              },
                              "description": "What this key may do."
                            },
                            "limits": {
                              "type": "object",
                              "properties": {
                                "max_order_notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "daily_notional_limit_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "daily_notional_remaining_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "key": {
                                  "type": "object",
                                  "properties": {
                                    "max_order_notional_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_limit_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_used_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "max_order_notional_usd",
                                    "daily_notional_limit_usd",
                                    "daily_notional_used_usd"
                                  ]
                                },
                                "account": {
                                  "type": "object",
                                  "properties": {
                                    "max_order_notional_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_limit_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_used_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "max_order_notional_usd",
                                    "daily_notional_limit_usd",
                                    "daily_notional_used_usd"
                                  ]
                                }
                              },
                              "required": [
                                "max_order_notional_usd",
                                "daily_notional_limit_usd",
                                "daily_notional_remaining_usd",
                                "key",
                                "account"
                              ]
                            },
                            "allowed_venues": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "ready",
                                      "not_configured",
                                      "unavailable"
                                    ],
                                    "description": "`ready` when POST /v1/orders can place on the venue for this key, `not_configured` until the venue account is connected in the Lean app, `unavailable` when it is connected but cannot trade right now: trading is switched off for the key, trading has not been authorized in the Lean app, or the venue refused the stored connection."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "status"
                                ]
                              },
                              "description": "Whether each venue account is connected. Venue accounts are connected only in the Lean app. A test key reports every venue `ready`, since its orders never reach a venue."
                            },
                            "max_slippage_bps": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10000
                            },
                            "paused": {
                              "type": "object",
                              "properties": {
                                "global": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "account": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "key": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                }
                              },
                              "required": [
                                "global",
                                "account",
                                "key"
                              ]
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "scopes",
                            "limits",
                            "allowed_venues",
                            "venues",
                            "max_slippage_bps",
                            "paused",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scopes": [
                      "read",
                      "trade"
                    ],
                    "limits": {
                      "max_order_notional_usd": "50",
                      "daily_notional_limit_usd": "500",
                      "daily_notional_remaining_usd": "494.5",
                      "key": {
                        "max_order_notional_usd": "50",
                        "daily_notional_limit_usd": "1000",
                        "daily_notional_used_usd": "5.5"
                      },
                      "account": {
                        "max_order_notional_usd": "100",
                        "daily_notional_limit_usd": "500",
                        "daily_notional_used_usd": "5.5"
                      }
                    },
                    "allowed_venues": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "venues": [
                      {
                        "venue": "kalshi",
                        "status": "not_configured"
                      },
                      {
                        "venue": "polymarket",
                        "status": "ready"
                      },
                      {
                        "venue": "polymarket_us",
                        "status": "not_configured"
                      },
                      {
                        "venue": "hyperliquid",
                        "status": "ready"
                      }
                    ],
                    "max_slippage_bps": 200,
                    "paused": {
                      "global": null,
                      "account": null,
                      "key": null
                    },
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/account/limits": {
      "post": {
        "operationId": "lowerKeyLimits",
        "summary": "Lower this key's limits",
        "description": "A key may lower its own per order and rolling 24 hour limits. Raising them needs a signed in session in the dashboard; a raise is refused with `details.reason` `LIMIT_RAISE_NOT_ALLOWED`.",
        "tags": [
          "Account"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "max_order_notional_usd": {
                    "type": "string",
                    "description": "Positive USD amount with at most 6 decimal places"
                  },
                  "daily_notional_limit_usd": {
                    "type": "string",
                    "description": "Positive USD amount with at most 6 decimal places"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "max_order_notional_usd": "50"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Configuration after the change",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "read",
                                  "trade",
                                  "route",
                                  "withdraw"
                                ]
                              },
                              "description": "What this key may do."
                            },
                            "limits": {
                              "type": "object",
                              "properties": {
                                "max_order_notional_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "daily_notional_limit_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "daily_notional_remaining_usd": {
                                  "type": "string",
                                  "pattern": "^\\d+(?:\\.\\d+)?$"
                                },
                                "key": {
                                  "type": "object",
                                  "properties": {
                                    "max_order_notional_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_limit_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_used_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "max_order_notional_usd",
                                    "daily_notional_limit_usd",
                                    "daily_notional_used_usd"
                                  ]
                                },
                                "account": {
                                  "type": "object",
                                  "properties": {
                                    "max_order_notional_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_limit_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    },
                                    "daily_notional_used_usd": {
                                      "type": "string",
                                      "pattern": "^\\d+(?:\\.\\d+)?$"
                                    }
                                  },
                                  "required": [
                                    "max_order_notional_usd",
                                    "daily_notional_limit_usd",
                                    "daily_notional_used_usd"
                                  ]
                                }
                              },
                              "required": [
                                "max_order_notional_usd",
                                "daily_notional_limit_usd",
                                "daily_notional_remaining_usd",
                                "key",
                                "account"
                              ]
                            },
                            "allowed_venues": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              }
                            },
                            "venues": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "venue": {
                                    "type": "string",
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid",
                                      "lighter"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "ready",
                                      "not_configured",
                                      "unavailable"
                                    ],
                                    "description": "`ready` when POST /v1/orders can place on the venue for this key, `not_configured` until the venue account is connected in the Lean app, `unavailable` when it is connected but cannot trade right now: trading is switched off for the key, trading has not been authorized in the Lean app, or the venue refused the stored connection."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "status"
                                ]
                              },
                              "description": "Whether each venue account is connected. Venue accounts are connected only in the Lean app. A test key reports every venue `ready`, since its orders never reach a venue."
                            },
                            "max_slippage_bps": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10000
                            },
                            "paused": {
                              "type": "object",
                              "properties": {
                                "global": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "account": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "key": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string"
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                }
                              },
                              "required": [
                                "global",
                                "account",
                                "key"
                              ]
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "scopes",
                            "limits",
                            "allowed_venues",
                            "venues",
                            "max_slippage_bps",
                            "paused",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scopes": [
                      "read",
                      "trade"
                    ],
                    "limits": {
                      "max_order_notional_usd": "50",
                      "daily_notional_limit_usd": "500",
                      "daily_notional_remaining_usd": "494.5",
                      "key": {
                        "max_order_notional_usd": "50",
                        "daily_notional_limit_usd": "1000",
                        "daily_notional_used_usd": "5.5"
                      },
                      "account": {
                        "max_order_notional_usd": "100",
                        "daily_notional_limit_usd": "500",
                        "daily_notional_used_usd": "5.5"
                      }
                    },
                    "allowed_venues": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "venues": [
                      {
                        "venue": "kalshi",
                        "status": "not_configured"
                      },
                      {
                        "venue": "polymarket",
                        "status": "ready"
                      },
                      {
                        "venue": "polymarket_us",
                        "status": "not_configured"
                      },
                      {
                        "venue": "hyperliquid",
                        "status": "ready"
                      }
                    ],
                    "max_slippage_bps": 200,
                    "paused": {
                      "global": null,
                      "account": null,
                      "key": null
                    },
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid amounts, or a daily limit below the limit per order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid amounts, or a daily limit below the limit per order"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "The change would raise a limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "The change would raise a limit"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/account/pause": {
      "post": {
        "operationId": "pauseTrading",
        "summary": "Pause order placement",
        "description": "Stops new orders for this key or for every key of its trading account, and stops queued orders that have not reached a venue yet. It also stops withdrawals, transfers, conversions, merges and redeems. Reads, cancels and resting orders are unaffected, and transfer quotes still answer. Only the Lean dashboard can resume.",
        "tags": [
          "Account"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scope": {
                    "type": "string",
                    "enum": [
                      "api_key",
                      "trading_account"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "default": "Paused by API key"
                  }
                },
                "required": [
                  "scope"
                ]
              },
              "example": {
                "scope": "api_key",
                "reason": "Strategy halted"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Pauses now covering this key",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "paused": {
                              "type": "object",
                              "properties": {
                                "global": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "account": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                },
                                "key": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "reason": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "operator",
                                        "dashboard",
                                        "api_key"
                                      ]
                                    },
                                    "since": {
                                      "type": "string",
                                      "format": "date-time"
                                    }
                                  },
                                  "required": [
                                    "reason",
                                    "source",
                                    "since"
                                  ]
                                }
                              },
                              "required": [
                                "global",
                                "account",
                                "key"
                              ]
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "paused",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "paused": {
                      "global": null,
                      "account": null,
                      "key": {
                        "reason": "Strategy halted",
                        "source": "api_key",
                        "since": "2026-10-29T18:00:00.000Z"
                      }
                    },
                    "livemode": false
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ws/token": {
      "post": {
        "operationId": "createStreamTicket",
        "summary": "Create a stream ticket",
        "description": "Mints a short lived ticket for one connection to the /v1/ws WebSocket, so the API key itself never travels over the socket. Connect, then send `{\"op\":\"auth\",\"ticket\":\"<token>\"}` as the first frame.",
        "tags": [
          "Streaming"
        ],
        "responses": {
          "200": {
            "description": "A ticket bound to this key, its trading account and mode",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "token": {
                              "type": "string",
                              "minLength": 1,
                              "description": "Opaque ticket for one WebSocket connection. Send it as the first frame on /v1/ws."
                            },
                            "expires_at": {
                              "type": "string",
                              "format": "date-time",
                              "description": "A connection must authenticate before this time."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "token",
                            "expires_at",
                            "livemode"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "token": "stream_ticket_example",
                    "expires_at": "2026-10-29T18:00:30.000Z",
                    "livemode": true
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid, expired or revoked API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the scope this route needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "This API key lacks the scope this route needs"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "headers": {
              "Retry-After": {
                "description": "Seconds remaining in the upstream read cooldown, when available",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "RATE_LIMITED",
                    "message": "Too many requests for this API key"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Streaming is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "Streaming is not configured"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "operationId": "listApiKeys",
        "summary": "List API keys",
        "description": "Every API key of the signed in user across their trading accounts, including revoked and expired keys. Secrets are never returned; each key shows only its prefix.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "API keys of the signed in user, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "keys": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "keyPrefix": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "tradingAccountId": {
                                    "type": "string",
                                    "format": "uuid"
                                  },
                                  "scopes": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "enum": [
                                        "read",
                                        "trade",
                                        "route",
                                        "withdraw"
                                      ]
                                    },
                                    "minItems": 1
                                  },
                                  "mode": {
                                    "type": "string",
                                    "enum": [
                                      "test",
                                      "live"
                                    ]
                                  },
                                  "maxOrderNotionalMicros": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true
                                  },
                                  "dailyNotionalLimitMicros": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true
                                  },
                                  "maxWithdrawalMicros": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "exclusiveMinimum": true
                                  },
                                  "dailyWithdrawalLimitMicros": {
                                    "type": "integer",
                                    "nullable": true,
                                    "minimum": 0,
                                    "exclusiveMinimum": true
                                  },
                                  "expiresAt": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "revokedAt": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "lastUsedAt": {
                                    "type": "string",
                                    "nullable": true,
                                    "format": "date-time"
                                  },
                                  "createdAt": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "oauthClient": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "claude",
                                      "claude_code",
                                      "chatgpt",
                                      "codex",
                                      "cursor",
                                      "vscode",
                                      "loopback",
                                      "external"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "keyPrefix",
                                  "tradingAccountId",
                                  "scopes",
                                  "mode",
                                  "maxOrderNotionalMicros",
                                  "dailyNotionalLimitMicros",
                                  "maxWithdrawalMicros",
                                  "dailyWithdrawalLimitMicros",
                                  "expiresAt",
                                  "revokedAt",
                                  "lastUsedAt",
                                  "createdAt",
                                  "oauthClient"
                                ]
                              }
                            }
                          },
                          "required": [
                            "keys"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Keys": {
                    "summary": "Newest first; secrets are never returned",
                    "value": {
                      "success": true,
                      "data": {
                        "keys": [
                          {
                            "id": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                            "name": "Pricing bot",
                            "mode": "test",
                            "keyPrefix": "lean_sk_test_xxxxxxxx",
                            "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                            "scopes": [
                              "read",
                              "trade"
                            ],
                            "maxOrderNotionalMicros": 100000000,
                            "dailyNotionalLimitMicros": 500000000,
                            "maxWithdrawalMicros": null,
                            "dailyWithdrawalLimitMicros": null,
                            "expiresAt": "2027-01-27T18:00:00.000Z",
                            "revokedAt": null,
                            "lastUsedAt": "2026-10-29T18:05:12.000Z",
                            "createdAt": "2026-10-29T18:00:00.000Z"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4d7e1a90-3c2b-4f65-9e08-b1a6c5d2f374"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing token": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing authorization header"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4d7e1a90-3c2b-4f65-9e08-b1a6c5d2f374"
                      }
                    }
                  },
                  "Invalid token": {
                    "summary": "Expired, malformed, or an API key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid or expired token"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4d7e1a90-3c2b-4f65-9e08-b1a6c5d2f374"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "No access": {
                    "summary": "The account does not have access to Lean yet",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "You do not have a whitelist code. Please join the waitlist and fill out the form on the landing page."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4d7e1a90-3c2b-4f65-9e08-b1a6c5d2f374"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "4d7e1a90-3c2b-4f65-9e08-b1a6c5d2f374"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createApiKey",
        "summary": "Create an API key",
        "description": "Creates a test or live key on one of your trading accounts with the scopes and limits you choose, up to the account’s own. The secret is returned once in this response; store it, because it cannot be shown again.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "tradingAccountId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "read",
                        "trade",
                        "route",
                        "withdraw"
                      ]
                    },
                    "minItems": 1
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "test",
                      "live"
                    ],
                    "default": "test"
                  },
                  "maxOrderNotionalMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  },
                  "dailyNotionalLimitMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  },
                  "expiresInDays": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 1,
                    "maximum": 90
                  },
                  "maxWithdrawalMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  },
                  "dailyWithdrawalLimitMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "name",
                  "tradingAccountId",
                  "scopes",
                  "maxOrderNotionalMicros",
                  "dailyNotionalLimitMicros",
                  "expiresInDays"
                ]
              },
              "example": {
                "name": "Pricing bot",
                "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                "scopes": [
                  "read",
                  "trade"
                ],
                "mode": "test",
                "maxOrderNotionalMicros": 100000000,
                "dailyNotionalLimitMicros": 500000000,
                "expiresInDays": 90
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new key and its secret, shown once",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "apiKey": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "keyPrefix": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "tradingAccountId": {
                                  "type": "string",
                                  "format": "uuid"
                                },
                                "scopes": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "enum": [
                                      "read",
                                      "trade",
                                      "route",
                                      "withdraw"
                                    ]
                                  },
                                  "minItems": 1
                                },
                                "mode": {
                                  "type": "string",
                                  "enum": [
                                    "test",
                                    "live"
                                  ]
                                },
                                "maxOrderNotionalMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true
                                },
                                "dailyNotionalLimitMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true
                                },
                                "maxWithdrawalMicros": {
                                  "type": "integer",
                                  "nullable": true,
                                  "minimum": 0,
                                  "exclusiveMinimum": true
                                },
                                "dailyWithdrawalLimitMicros": {
                                  "type": "integer",
                                  "nullable": true,
                                  "minimum": 0,
                                  "exclusiveMinimum": true
                                },
                                "expiresAt": {
                                  "type": "string",
                                  "nullable": true,
                                  "format": "date-time"
                                },
                                "revokedAt": {
                                  "type": "string",
                                  "nullable": true,
                                  "format": "date-time"
                                },
                                "lastUsedAt": {
                                  "type": "string",
                                  "nullable": true,
                                  "format": "date-time"
                                },
                                "createdAt": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "oauthClient": {
                                  "type": "string",
                                  "nullable": true,
                                  "enum": [
                                    "claude",
                                    "claude_code",
                                    "chatgpt",
                                    "codex",
                                    "cursor",
                                    "vscode",
                                    "loopback",
                                    "external"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "name",
                                "keyPrefix",
                                "tradingAccountId",
                                "scopes",
                                "mode",
                                "maxOrderNotionalMicros",
                                "dailyNotionalLimitMicros",
                                "maxWithdrawalMicros",
                                "dailyWithdrawalLimitMicros",
                                "expiresAt",
                                "revokedAt",
                                "lastUsedAt",
                                "createdAt",
                                "oauthClient"
                              ]
                            },
                            "secret": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "apiKey",
                            "secret"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Created": {
                    "summary": "The secret is shown once",
                    "value": {
                      "success": true,
                      "data": {
                        "apiKey": {
                          "id": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                          "name": "Pricing bot",
                          "mode": "test",
                          "keyPrefix": "lean_sk_test_xxxxxxxx",
                          "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                          "scopes": [
                            "read",
                            "trade"
                          ],
                          "maxOrderNotionalMicros": 100000000,
                          "dailyNotionalLimitMicros": 500000000,
                          "maxWithdrawalMicros": null,
                          "dailyWithdrawalLimitMicros": null,
                          "expiresAt": "2027-01-27T18:00:00.000Z",
                          "revokedAt": null,
                          "lastUsedAt": null,
                          "createdAt": "2026-10-29T18:00:00.000Z"
                        },
                        "secret": "lean_sk_test_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Invalid limits": {
                    "summary": "The daily limit is below the per order limit",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "dailyNotionalLimitMicros",
                            "message": "dailyNotionalLimitMicros must be at least maxOrderNotionalMicros"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing token": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing authorization header"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  },
                  "Invalid token": {
                    "summary": "Expired, malformed, or an API key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid or expired token"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "No access": {
                    "summary": "The account does not have access to Lean yet",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "You do not have a whitelist code. Please join the waitlist and fill out the form on the landing page."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "No such account": {
                    "summary": "tradingAccountId is not one of yours",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "Trading account not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Too many active keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Too many keys": {
                    "summary": "Revoke a key first",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "CONFLICT",
                        "message": "At most 10 active API keys; revoke one first"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "A limit is above the trading account's own",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "A limit is above the trading account's own"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "b8c2f5e1-6a3d-4097-8e4b-2f1d7a9c0e63"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/{id}": {
      "delete": {
        "operationId": "revokeApiKey",
        "summary": "Revoke an API key",
        "description": "Revokes a key at once, and requests with it are refused from then on. Revoking a key again returns it unchanged.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path",
            "example": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09"
          }
        ],
        "responses": {
          "200": {
            "description": "The revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1
                            },
                            "keyPrefix": {
                              "type": "string",
                              "minLength": 1
                            },
                            "tradingAccountId": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "read",
                                  "trade",
                                  "route",
                                  "withdraw"
                                ]
                              },
                              "minItems": 1
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "test",
                                "live"
                              ]
                            },
                            "maxOrderNotionalMicros": {
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "dailyNotionalLimitMicros": {
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "maxWithdrawalMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "dailyWithdrawalLimitMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "expiresAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "revokedAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "lastUsedAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "oauthClient": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "claude",
                                "claude_code",
                                "chatgpt",
                                "codex",
                                "cursor",
                                "vscode",
                                "loopback",
                                "external"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "keyPrefix",
                            "tradingAccountId",
                            "scopes",
                            "mode",
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "maxWithdrawalMicros",
                            "dailyWithdrawalLimitMicros",
                            "expiresAt",
                            "revokedAt",
                            "lastUsedAt",
                            "createdAt",
                            "oauthClient"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "examples": {
                  "Revoked": {
                    "summary": "Lean refuses the key from now on",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                        "name": "Pricing bot",
                        "mode": "test",
                        "keyPrefix": "lean_sk_test_xxxxxxxx",
                        "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                        "scopes": [
                          "read",
                          "trade"
                        ],
                        "maxOrderNotionalMicros": 100000000,
                        "dailyNotionalLimitMicros": 500000000,
                        "maxWithdrawalMicros": null,
                        "dailyWithdrawalLimitMicros": null,
                        "expiresAt": "2027-01-27T18:00:00.000Z",
                        "revokedAt": "2026-10-29T19:30:00.000Z",
                        "lastUsedAt": "2026-10-29T18:05:12.000Z",
                        "createdAt": "2026-10-29T18:00:00.000Z"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Bad id": {
                    "summary": "id is not a UUID",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "Invalid request",
                        "details": [
                          {
                            "path": "id",
                            "message": "Invalid uuid"
                          }
                        ]
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Missing token": {
                    "summary": "No Authorization header",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Missing authorization header"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  },
                  "Invalid token": {
                    "summary": "Expired, malformed, or an API key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "UNAUTHORIZED",
                        "message": "Invalid or expired token"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "No access": {
                    "summary": "The account does not have access to Lean yet",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "FORBIDDEN",
                        "message": "You do not have a whitelist code. Please join the waitlist and fill out the form on the landing page."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Not found": {
                    "summary": "No such key for this user",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "NOT_FOUND",
                        "message": "API key not found"
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "examples": {
                  "Internal error": {
                    "summary": "Unexpected server error",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "INTERNAL_ERROR",
                        "message": "An internal error occurred."
                      },
                      "meta": {
                        "timestampMs": 1791741600000,
                        "requestId": "1f9a6d3c-8e4b-4c27-a051-e7b3d0c8f592"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/{id}/limits": {
      "patch": {
        "operationId": "updateApiKeyLimits",
        "summary": "Change an API key's limits",
        "description": "Raises or lowers an active key's limits, up to its trading account's own.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "maxOrderNotionalMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  },
                  "dailyNotionalLimitMicros": {
                    "type": "integer",
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 9007199254740991
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "maxOrderNotionalMicros": 50000000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The key with its new limits",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1
                            },
                            "keyPrefix": {
                              "type": "string",
                              "minLength": 1
                            },
                            "tradingAccountId": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "scopes": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "read",
                                  "trade",
                                  "route",
                                  "withdraw"
                                ]
                              },
                              "minItems": 1
                            },
                            "mode": {
                              "type": "string",
                              "enum": [
                                "test",
                                "live"
                              ]
                            },
                            "maxOrderNotionalMicros": {
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "dailyNotionalLimitMicros": {
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "maxWithdrawalMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "dailyWithdrawalLimitMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true
                            },
                            "expiresAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "revokedAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "lastUsedAt": {
                              "type": "string",
                              "nullable": true,
                              "format": "date-time"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "oauthClient": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "claude",
                                "claude_code",
                                "chatgpt",
                                "codex",
                                "cursor",
                                "vscode",
                                "loopback",
                                "external"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "keyPrefix",
                            "tradingAccountId",
                            "scopes",
                            "mode",
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "maxWithdrawalMicros",
                            "dailyWithdrawalLimitMicros",
                            "expiresAt",
                            "revokedAt",
                            "lastUsedAt",
                            "createdAt",
                            "oauthClient"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                    "name": "Pricing bot",
                    "keyPrefix": "lean_sk_test_xxxxxxxx",
                    "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                    "scopes": [
                      "read",
                      "trade"
                    ],
                    "mode": "test",
                    "maxOrderNotionalMicros": 50000000,
                    "dailyNotionalLimitMicros": 500000000,
                    "maxWithdrawalMicros": null,
                    "dailyWithdrawalLimitMicros": null,
                    "expiresAt": "2027-01-27T18:00:00.000Z",
                    "revokedAt": null,
                    "lastUsedAt": "2026-10-29T18:00:00.000Z",
                    "createdAt": "2026-10-29T17:00:00.000Z",
                    "oauthClient": null
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid limits, or a daily limit below the per order limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid limits, or a daily limit below the per order limit"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "422": {
            "description": "A limit is above the trading account's own",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "A limit is above the trading account's own"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/accounts/{tradingAccountId}/limits": {
      "get": {
        "operationId": "getApiAccountLimits",
        "summary": "Get a trading account's API limits",
        "description": "The account's own API limits, allowed venues and slippage cap, and the limits every key on the account is held to. A limit the account has not set is reported as 100,000,000 USD, the most an account limit can be; each key still holds orders to its own limits.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "tradingAccountId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The account's settings and effective limits",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "maxOrderNotionalMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100000000000000
                            },
                            "dailyNotionalLimitMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100000000000000
                            },
                            "allowedVenues": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              },
                              "minItems": 1
                            },
                            "maxSlippageBps": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10000
                            },
                            "tradingAccountId": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "effectiveLimits": {
                              "type": "object",
                              "properties": {
                                "maxOrderNotionalMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true,
                                  "maximum": 9007199254740991
                                },
                                "dailyNotionalLimitMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "maxOrderNotionalMicros",
                                "dailyNotionalLimitMicros"
                              ]
                            }
                          },
                          "required": [
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "allowedVenues",
                            "maxSlippageBps",
                            "tradingAccountId",
                            "effectiveLimits"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "maxOrderNotionalMicros": 100000000,
                    "dailyNotionalLimitMicros": 500000000,
                    "allowedVenues": null,
                    "maxSlippageBps": null,
                    "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                    "effectiveLimits": {
                      "maxOrderNotionalMicros": 100000000,
                      "dailyNotionalLimitMicros": 500000000
                    }
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateApiAccountLimits",
        "summary": "Set a trading account's API limits",
        "description": "Replaces the account's own limits, allowed venues and slippage cap; a null slippage cap sets none. Each limit can be at most 100,000,000 USD; a null limit leaves that limit unset, so only each key's own limits apply.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "tradingAccountId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "maxOrderNotionalMicros": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 100000000000000
                  },
                  "dailyNotionalLimitMicros": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "exclusiveMinimum": true,
                    "maximum": 100000000000000
                  },
                  "allowedVenues": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "string",
                      "enum": [
                        "kalshi",
                        "polymarket",
                        "polymarket_us",
                        "hyperliquid",
                        "lighter"
                      ]
                    },
                    "minItems": 1
                  },
                  "maxSlippageBps": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0,
                    "maximum": 10000
                  }
                },
                "required": [
                  "maxOrderNotionalMicros",
                  "dailyNotionalLimitMicros",
                  "allowedVenues",
                  "maxSlippageBps"
                ],
                "additionalProperties": false
              },
              "example": {
                "maxOrderNotionalMicros": 100000000,
                "dailyNotionalLimitMicros": 500000000,
                "allowedVenues": null,
                "maxSlippageBps": null
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The account's settings after the change",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "maxOrderNotionalMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100000000000000
                            },
                            "dailyNotionalLimitMicros": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 100000000000000
                            },
                            "allowedVenues": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid",
                                  "lighter"
                                ]
                              },
                              "minItems": 1
                            },
                            "maxSlippageBps": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0,
                              "maximum": 10000
                            },
                            "tradingAccountId": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "effectiveLimits": {
                              "type": "object",
                              "properties": {
                                "maxOrderNotionalMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true,
                                  "maximum": 9007199254740991
                                },
                                "dailyNotionalLimitMicros": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "exclusiveMinimum": true,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "maxOrderNotionalMicros",
                                "dailyNotionalLimitMicros"
                              ]
                            }
                          },
                          "required": [
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "allowedVenues",
                            "maxSlippageBps",
                            "tradingAccountId",
                            "effectiveLimits"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "maxOrderNotionalMicros": 100000000,
                    "dailyNotionalLimitMicros": 500000000,
                    "allowedVenues": null,
                    "maxSlippageBps": null,
                    "tradingAccountId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                    "effectiveLimits": {
                      "maxOrderNotionalMicros": 100000000,
                      "dailyNotionalLimitMicros": 500000000
                    }
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "Not found"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/suspensions": {
      "get": {
        "operationId": "listApiTradingSuspensions",
        "summary": "List trading pauses",
        "description": "Every pause that stops orders from your API keys: pauses on a key, pauses on a trading account, and a platform wide halt if one is in force. Each shows who set it, why and since when.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pauses covering the signed in user's keys and trading accounts, and the global halt if one is set",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "suspensions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "scope": {
                                    "type": "string",
                                    "enum": [
                                      "global",
                                      "trading_account",
                                      "api_key"
                                    ]
                                  },
                                  "scopeId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "operator",
                                      "dashboard",
                                      "api_key"
                                    ]
                                  },
                                  "reason": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "since": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                },
                                "required": [
                                  "scope",
                                  "scopeId",
                                  "source",
                                  "reason",
                                  "since"
                                ]
                              }
                            }
                          },
                          "required": [
                            "suspensions"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "suspensions": [
                      {
                        "scope": "api_key",
                        "scopeId": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                        "source": "dashboard",
                        "reason": "Strategy misbehaving; investigating",
                        "since": "2026-10-29T18:00:00.000Z"
                      }
                    ]
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such key or trading account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No such key or trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/{id}/suspension": {
      "put": {
        "operationId": "pauseApiKey",
        "summary": "Pause an API key",
        "description": "Stops one key placing new orders until you resume it. The key can still read and cancel, and its resting orders stay on the venues. Pausing a key that is already paused changes nothing.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "reason"
                ]
              },
              "example": {
                "reason": "Strategy misbehaving; investigating"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The pause. An existing pause keeps its original source and reason. The key can still read and cancel",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "global",
                                "trading_account",
                                "api_key"
                              ]
                            },
                            "scopeId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "operator",
                                "dashboard",
                                "api_key"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "minLength": 1
                            },
                            "since": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "scope",
                            "scopeId",
                            "source",
                            "reason",
                            "since"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scope": "api_key",
                    "scopeId": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                    "source": "dashboard",
                    "reason": "Strategy misbehaving; investigating",
                    "since": "2026-10-29T18:00:00.000Z"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such key or trading account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No such key or trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "resumeApiKey",
        "summary": "Resume an API key",
        "description": "Lifts a pause you or the key set, so the key can place orders again. A pause Lean set can only be lifted by Lean.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The pause that was lifted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "global",
                                "trading_account",
                                "api_key"
                              ]
                            },
                            "scopeId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "operator",
                                "dashboard",
                                "api_key"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "minLength": 1
                            },
                            "since": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "scope",
                            "scopeId",
                            "source",
                            "reason",
                            "since"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scope": "api_key",
                    "scopeId": "0c4f8e2a-9b1d-4e73-a6f5-3d8b2c7e1a09",
                    "source": "dashboard",
                    "reason": "Strategy misbehaving; investigating",
                    "since": "2026-10-29T18:00:00.000Z"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such key or trading account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No such key or trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The key is not paused, or Lean paused it and only Lean can resume it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The key is not paused, or Lean paused it and only Lean can resume it"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    },
    "/api-keys/accounts/{tradingAccountId}/suspension": {
      "put": {
        "operationId": "pauseTradingAccountApiTrading",
        "summary": "Pause API trading on a trading account",
        "description": "Stops every API key of one trading account placing new orders until you resume it. Keys can still read and cancel, and resting orders stay on the venues.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "tradingAccountId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "reason"
                ]
              },
              "example": {
                "reason": "Strategy misbehaving; investigating"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The pause, covering every key of the account. An existing pause keeps its original source and reason",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "global",
                                "trading_account",
                                "api_key"
                              ]
                            },
                            "scopeId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "operator",
                                "dashboard",
                                "api_key"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "minLength": 1
                            },
                            "since": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "scope",
                            "scopeId",
                            "source",
                            "reason",
                            "since"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scope": "trading_account",
                    "scopeId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                    "source": "dashboard",
                    "reason": "Strategy misbehaving; investigating",
                    "since": "2026-10-29T18:00:00.000Z"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such key or trading account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No such key or trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "resumeTradingAccountApiTrading",
        "summary": "Resume API trading on a trading account",
        "description": "Lifts a pause on a trading account so its keys can place orders again. A pause Lean set can only be lifted by Lean.",
        "tags": [
          "API keys"
        ],
        "security": [
          {
            "sessionToken": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "tradingAccountId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The pause that was lifted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "scope": {
                              "type": "string",
                              "enum": [
                                "global",
                                "trading_account",
                                "api_key"
                              ]
                            },
                            "scopeId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "operator",
                                "dashboard",
                                "api_key"
                              ]
                            },
                            "reason": {
                              "type": "string",
                              "minLength": 1
                            },
                            "since": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": [
                            "scope",
                            "scopeId",
                            "source",
                            "reason",
                            "since"
                          ]
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "timestampMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "requestId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "traceId": {
                              "type": "string",
                              "minLength": 1
                            },
                            "cachedAtMs": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "cache",
                                "database",
                                "clickhouse",
                                "upstream",
                                "fallback",
                                "internal"
                              ]
                            }
                          },
                          "required": [
                            "timestampMs",
                            "requestId"
                          ]
                        }
                      },
                      "required": [
                        "success",
                        "data",
                        "meta"
                      ]
                    },
                    {
                      "$ref": "#/components/schemas/ApiError"
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "scope": "trading_account",
                    "scopeId": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                    "source": "dashboard",
                    "reason": "Strategy misbehaving; investigating",
                    "since": "2026-10-29T18:00:00.000Z"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "400": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Invalid request"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "401": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Invalid or expired token"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FORBIDDEN",
                    "message": "You do not have access to this trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such key or trading account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "NOT_FOUND",
                    "message": "No such key or trading account"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The account is not paused, or Lean paused it and only Lean can resume it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "CONFLICT",
                    "message": "The account is not paused, or Lean paused it and only Lean can resume it"
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          },
          "500": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "INTERNAL_ERROR",
                    "message": "An internal error occurred."
                  },
                  "meta": {
                    "timestampMs": 1792771200000,
                    "requestId": "7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "{baseUrl}",
          "description": "Lean API",
          "variables": {
            "baseUrl": {
              "default": "https://api.lean.xyz",
              "description": "The Lean API base URL. Same value as LEAN_API_URL in the guides."
            }
          }
        }
      ]
    }
  }
}
