{
  "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:…` 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:…` 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`."
            },
            "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`.",
            "name": "search",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "sports"
              ],
              "description": "Market category. Every listed market is `sports` today."
            },
            "required": false,
            "description": "Market category. Every listed market is `sports` today.",
            "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,
              "example": "nfl"
            },
            "required": false,
            "name": "league",
            "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"
              ],
              "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",
              "enum": [
                "open",
                "closed"
              ],
              "description": "`open`: at least one venue leg is `tradable`. `closed`: no leg is, including markets whose legs are only `unopened` or `resolving`."
            },
            "required": false,
            "description": "`open`: at least one venue leg is `tradable`. `closed`: no leg is, including markets whose legs are only `unopened` or `resolving`.",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only fixtures starting at or after this time. Defaults to 12 hours ago."
            },
            "required": false,
            "description": "Only fixtures 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 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 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": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query",
            "example": 2
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "required": false,
            "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": {
                                "type": "object",
                                "properties": {
                                  "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"
                                        ]
                                      },
                                      "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",
                                      "label",
                                      "period",
                                      "subject",
                                      "stat",
                                      "line"
                                    ]
                                  },
                                  "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"
                                          ]
                                        },
                                        "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."
                                        },
                                        "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."
                                            }
                                          },
                                          "required": [
                                            "source",
                                            "rules",
                                            "end_date",
                                            "url"
                                          ],
                                          "description": "How this venue resolves its market."
                                        },
                                        "fees": {
                                          "type": "object",
                                          "nullable": true,
                                          "properties": {
                                            "formula": {
                                              "type": "string",
                                              "enum": [
                                                "price_curve",
                                                "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."
                                            },
                                            "maker_rate": {
                                              "type": "string",
                                              "pattern": "^\\d+(?:\\.\\d+)?$",
                                              "description": "The rate, as a fraction of 1, a resting order pays when it fills."
                                            },
                                            "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 on Kalshi and Polymarket US, and when the venue's fee terms for the market are not recorded."
                                        }
                                      },
                                      "required": [
                                        "venue",
                                        "ticker",
                                        "side",
                                        "status",
                                        "tradable",
                                        "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": [
                                  "id",
                                  "title",
                                  "outcome",
                                  "line",
                                  "fixture",
                                  "group",
                                  "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 and how that venue resolves it. A market id keeps resolving after its fixture leaves the default list window. A venue symbol that names one market, such as a Polymarket token id or a Hyperliquid book coin, returns that market under its market id.",
        "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",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "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"
                                  ]
                                },
                                "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",
                                "label",
                                "period",
                                "subject",
                                "stat",
                                "line"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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."
                                  },
                                  "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."
                                      }
                                    },
                                    "required": [
                                      "source",
                                      "rules",
                                      "end_date",
                                      "url"
                                    ],
                                    "description": "How this venue resolves its market."
                                  },
                                  "fees": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "formula": {
                                        "type": "string",
                                        "enum": [
                                          "price_curve",
                                          "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."
                                      },
                                      "maker_rate": {
                                        "type": "string",
                                        "pattern": "^\\d+(?:\\.\\d+)?$",
                                        "description": "The rate, as a fraction of 1, a resting order pays when it fills."
                                      },
                                      "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 on Kalshi and Polymarket US, and when the venue's fee terms for the market are not recorded."
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "status",
                                  "tradable",
                                  "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."
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "outcome",
                            "line",
                            "fixture",
                            "group",
                            "legs",
                            "equivalence",
                            "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": "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": "hl:9999",
                        "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
                        },
                        "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,
                        "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
                        },
                        "fees": {
                          "formula": "price_curve",
                          "taker_rate": "0.03",
                          "maker_rate": "0",
                          "exponent": 1
                        }
                      }
                    ],
                    "equivalence": "verified",
                    "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}/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": "Dollars to spend on a buy, in place of quantity. The quote covers the shares that amount buys within limit_price and max_slippage_bps, when set.",
              "example": "25"
            },
            "required": false,
            "description": "Dollars to spend on a buy, in place of quantity, at most two decimals. The quote covers the shares that amount buys within limit_price and max_slippage_bps, when set.",
            "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 it has no book to quote; details.reason is MARKET_NOT_TRADABLE",
            "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"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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"
              ],
              "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"
                                    ]
                                  },
                                  "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+)?$"
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "bids",
                                  "asks",
                                  "bid_quantity",
                                  "ask_quantity",
                                  "bid_notional_usd",
                                  "ask_notional_usd"
                                ]
                              }
                            },
                            "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"
                                              ]
                                            },
                                            "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"
                                              ]
                                            },
                                            "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"
                                ]
                              }
                            },
                            "as_of": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "market_id",
                            "venues",
                            "combined",
                            "total_bid_quantity",
                            "total_ask_quantity",
                            "total_bid_notional_usd",
                            "total_ask_notional_usd",
                            "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": {
                    "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                    "venues": [
                      {
                        "venue": "hyperliquid",
                        "ticker": "hl:9999",
                        "side": "yes",
                        "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",
                        "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"
                            }
                          ]
                        }
                      ]
                    },
                    "total_bid_quantity": "350",
                    "total_ask_quantity": "200",
                    "total_bid_notional_usd": "187",
                    "total_ask_notional_usd": "110.8",
                    "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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"
              ]
            },
            "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"
                                    ]
                                  },
                                  "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",
                "5m",
                "15m",
                "1h",
                "2h"
              ],
              "default": "1m",
              "description": "Length of each candle."
            },
            "required": false,
            "description": "Length of each candle.",
            "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."
            },
            "required": false,
            "description": "Candles that open before this time. Defaults to now.",
            "name": "end",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid"
              ],
              "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",
                                "5m",
                                "15m",
                                "1h",
                                "2h"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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 25 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 25: 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."
            },
            "required": true,
            "description": "Markets separated by commas, at most 25: 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.",
            "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
                                  },
                                  "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"
                                          ]
                                        },
                                        "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"
                                      ]
                                    }
                                  }
                                },
                                "required": [
                                  "market_id",
                                  "best_bid",
                                  "best_bid_quantity",
                                  "best_ask",
                                  "best_ask_quantity",
                                  "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",
                        "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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.",
        "tags": [
          "Orders"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "venue": {
                    "type": "string",
                    "enum": [
                      "kalshi",
                      "polymarket",
                      "polymarket_us",
                      "hyperliquid"
                    ],
                    "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
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid"
                                        ]
                                      },
                                      "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"
                                              ]
                                            },
                                            "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",
                                      "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",
                          "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"
                    ],
                    "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."
                  }
                },
                "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"
                                    ]
                                  },
                                  "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
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid"
                                        ]
                                      },
                                      "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"
                                              ]
                                            },
                                            "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",
                                      "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"
                                ]
                              }
                            },
                            "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",
                          "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": "Order placement is paused for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "FEATURE_DISABLED",
                    "message": "Order placement is paused for this key"
                  },
                  "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.",
        "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 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, and an order that matches nothing 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."
                  },
                  "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."
                  }
                },
                "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
                                      },
                                      "venue": {
                                        "type": "string",
                                        "nullable": true,
                                        "enum": [
                                          "kalshi",
                                          "polymarket",
                                          "polymarket_us",
                                          "hyperliquid"
                                        ]
                                      },
                                      "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"
                                              ]
                                            },
                                            "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",
                                      "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",
                          "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, the size or both of a resting good til canceled order on one venue. Lean cancels the order and, once the cancel is confirmed with its final fill, places a new good til canceled order on the same venue with the same post_only for the rest of the new size: the answer is the new order, its replaces_order_id names the old one, and the old order’s replaced_by_order_id names the new one. Each keeps its own fills. A Kalshi, Polymarket US or Hyperliquid cancel is confirmed within the request. A live Polymarket cancel is confirmed some time after it is requested, so the first amend usually answers 409 REPLACEMENT_PENDING; send the same amend again once the old order reads canceled and the replacement is placed for what did not fill. The new order is placed as the calling key places one. Every check the new order faces, from the venue’s price and size rules and a post_only price that would trade to the key’s caps, the rolling day and the account’s cash or shares, runs before the cancel with what the old order holds counted as free, and a refusal leaves the order resting. Only a change between that check and the placement, such as another order spending the cash, can refuse the new order after the cancel, and the old order then stays canceled. Split, routed and immediate or cancel orders 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": "The client_order_id of the new order that replaces this one. Omit and Lean picks one."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "client_order_id": "bot-0002",
                "limit_price": "0.52",
                "quantity": "12"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The order that replaced it",
            "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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                    "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": "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 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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                        "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": "API error",
            "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"
                      }
                    }
                  }
                }
              }
            }
          },
          "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, else Polymarket US, since Hyperliquid has no fill or kill. gtd rests like gtc until expires_at, and is placed on Kalshi, Polymarket and Polymarket US, since Hyperliquid has no order expiry. 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."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When a gtd order expires, as an ISO 8601 time. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. 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, since Polymarket cannot rest post-only. 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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                        "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",
                        "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",
                        "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",
                        "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",
                        "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",
                        "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",
                        "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_on_hyperliquid": {
                    "summary": "gtd with only a Hyperliquid listing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "gtd orders are placed on Kalshi, Polymarket, or Polymarket US, since Hyperliquid has no order expiry, and this order has none of them to go to"
                      },
                      "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 placed through the API on this key’s trading account, newest first. 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. Filter by status, venue, market, text in the market title or `client_order_id`, 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 status."
            },
            "required": false,
            "description": "Only orders in this status.",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid"
              ],
              "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 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",
                                    "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
                                  },
                                  "venue": {
                                    "type": "string",
                                    "nullable": true,
                                    "enum": [
                                      "kalshi",
                                      "polymarket",
                                      "polymarket_us",
                                      "hyperliquid"
                                    ]
                                  },
                                  "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"
                                          ]
                                        },
                                        "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",
                                  "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
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "orders",
                            "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": {
                  "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",
                            "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": "3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3",
                            "client_order_id": "bot-2026-10-29-0001",
                            "market_id": "mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4",
                            "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,
                        "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,
                        "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/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, else Polymarket US, since Hyperliquid has no fill or kill. gtd rests like gtc until expires_at, and is placed on Kalshi, Polymarket and Polymarket US, since Hyperliquid has no order expiry. 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."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When a gtd order expires, as an ISO 8601 time. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. 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, since Polymarket cannot rest post-only. 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"
                                  ]
                                },
                                "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"
                                        ]
                                      },
                                      "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+)?$"
                                      }
                                    },
                                    "required": [
                                      "venue",
                                      "ticker",
                                      "side",
                                      "quantity",
                                      "limit_price",
                                      "notional_usd",
                                      "expected_fill_quantity",
                                      "expected_average_price",
                                      "expected_fee_usd",
                                      "expected_resting_fee_usd"
                                    ]
                                  }
                                }
                              },
                              "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_on_hyperliquid": {
                    "summary": "gtd with only a Hyperliquid listing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "VALIDATION_ERROR",
                        "message": "gtd orders are placed on Kalshi, Polymarket, or Polymarket US, since Hyperliquid has no order expiry, and this order has none of them to go to"
                      },
                      "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 it has no book to quote; details.reason is MARKET_NOT_TRADABLE",
            "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, else Polymarket US, since Hyperliquid has no fill or kill. gtd rests like gtc until expires_at, and is placed on Kalshi, Polymarket and Polymarket US, since Hyperliquid has no order expiry. 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."
                        },
                        "expires_at": {
                          "type": "string",
                          "format": "date-time",
                          "description": "When a gtd order expires, as an ISO 8601 time. Required with gtd and refused with any other time_in_force. At least 3 minutes and at most 30 days ahead. 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, since Polymarket cannot rest post-only. 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"
                ]
              },
              "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"
                                            ]
                                          },
                                          "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"
                                                  ]
                                                },
                                                "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+)?$"
                                                }
                                              },
                                              "required": [
                                                "venue",
                                                "ticker",
                                                "side",
                                                "quantity",
                                                "limit_price",
                                                "notional_usd",
                                                "expected_fill_quantity",
                                                "expected_average_price",
                                                "expected_fee_usd",
                                                "expected_resting_fee_usd"
                                              ]
                                            }
                                          }
                                        },
                                        "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"
                              }
                            ]
                          },
                          "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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                        "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": "API error",
            "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"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The order is not open",
            "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"
              ],
              "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"
                                    ]
                                  },
                                  "ticker": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "side": {
                                    "type": "string",
                                    "enum": [
                                      "yes",
                                      "no"
                                    ]
                                  },
                                  "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",
                                  "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",
                        "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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                    "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, or ROUTE_NOT_EXECUTABLE or LIMIT_BELOW_ROUTE_PRICE when no route can fill the whole quantity within the limit. 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
                            },
                            "venue": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "kalshi",
                                "polymarket",
                                "polymarket_us",
                                "hyperliquid"
                              ]
                            },
                            "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"
                                    ]
                                  },
                                  "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",
                            "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",
                    "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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+)?$"
                                  }
                                },
                                "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"
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
              ],
              "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 listed market 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 listed market 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"
                                    ]
                                  },
                                  "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."
                                  },
                                  "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."
                                  },
                                  "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
                                  }
                                },
                                "required": [
                                  "venue",
                                  "ticker",
                                  "side",
                                  "quantity",
                                  "average_price",
                                  "cost_basis_usd",
                                  "mark_price",
                                  "unrealized_pnl_usd",
                                  "market_id",
                                  "title",
                                  "outcome"
                                ]
                              }
                            },
                            "unavailable": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "kalshi",
                                  "polymarket",
                                  "polymarket_us",
                                  "hyperliquid"
                                ]
                              }
                            },
                            "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"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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"
              ],
              "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"
                                    ]
                                  },
                                  "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 this venue’s profit and loss record last changed, or null when it was read live or has no record yet."
                                  }
                                },
                                "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"
                                ]
                              }
                            },
                            "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-10T16:00:00.000Z"
                      },
                      {
                        "venue": "hyperliquid",
                        "realized_pnl_usd": "12.5",
                        "unrealized_pnl_usd": "2.5",
                        "total_pnl_usd": "15",
                        "updated_at": "2026-11-10T16: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."
            },
            "required": false,
            "description": "End of the range. Defaults to now.",
            "name": "end",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "kalshi",
                "polymarket",
                "polymarket_us",
                "hyperliquid"
              ],
              "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"
                              ]
                            },
                            "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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, including routed orders whose venue order is not placed yet, which no venue lists."
                            },
                            "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"
                                    ]
                                  },
                                  "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"
                                    ],
                                    "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 or balance could not be read."
                            },
                            "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"
                  }
                }
              }
            }
          },
          "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transfers/quote": {
      "post": {
        "operationId": "quoteTransfer",
        "summary": "Quote a transfer",
        "description": "What moving cash from one venue of this key’s trading account to the other would cost and deliver, the smallest amount the route accepts and what the sending venue holds. 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"
                    ],
                    "description": "The venue the cash leaves."
                  },
                  "to_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "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"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid"
                              ]
                            },
                            "amount_usd": {
                              "type": "string",
                              "minLength": 1
                            },
                            "fee_usd": {
                              "type": "string",
                              "minLength": 1,
                              "description": "What the move costs, taken out of amount_usd."
                            },
                            "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 or an invalid amount",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Same venue twice, an unknown venue or an invalid amount"
                  },
                  "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": "FEATURE_DISABLED with details.reason LIVE_TRANSFERS_UNAVAILABLE 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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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 the other venue. Transfers are simulated against test cash for test keys; live keys are refused with LIVE_TRANSFERS_UNAVAILABLE. Nothing moves until the transfer is executed with the owner’s signatures over `authorization.payloads` or 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"
                    ],
                    "description": "The venue the cash leaves."
                  },
                  "to_venue": {
                    "type": "string",
                    "enum": [
                      "polymarket",
                      "hyperliquid"
                    ],
                    "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"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid"
                              ]
                            },
                            "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"
                              ]
                            },
                            "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, an unknown field or an invalid amount",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Same venue twice, an unknown venue, an unknown field or an invalid amount"
                  },
                  "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",
            "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",
            "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"
                  },
                  "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 LIVE_TRANSFERS_UNAVAILABLE for a live key, or TRADING_PAUSED",
            "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"
                                    ]
                                  },
                                  "to_venue": {
                                    "type": "string",
                                    "enum": [
                                      "polymarket",
                                      "hyperliquid"
                                    ]
                                  },
                                  "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"
                                    ]
                                  },
                                  "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 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"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid"
                              ]
                            },
                            "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"
                              ]
                            },
                            "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"
                  }
                }
              }
            }
          },
          "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 LIVE_TRANSFERS_UNAVAILABLE for a live key, or TRADING_PAUSED",
            "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.",
        "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"
                              ]
                            },
                            "to_venue": {
                              "type": "string",
                              "enum": [
                                "polymarket",
                                "hyperliquid"
                              ]
                            },
                            "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"
                              ]
                            },
                            "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 and limit chase of the test key’s trading account, made by any test key on that account and not only the calling key, which returns the account’s test balances to the starting amount and clears its test positions. 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_transfers": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "livemode": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "deleted_orders",
                            "deleted_withdrawals",
                            "deleted_stop_losses",
                            "deleted_limit_chases",
                            "deleted_transfers",
                            "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_transfers": 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"
                    ],
                    "description": "The venue holding the shares to sell. Every venue runs stop losses and take profits."
                  },
                  "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 if it has not started selling. 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 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"
                  }
                }
              }
            }
          },
          "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, 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"
                  }
                }
              }
            }
          }
        }
      },
      "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.",
        "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"
                  }
                }
              }
            }
          },
          "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"
                  }
                }
              }
            }
          }
        }
      },
      "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"
                  }
                }
              }
            }
          },
          "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"
                    ],
                    "description": "The venue to rest the order on. Every venue runs limit chases."
                  },
                  "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 offset_ticks or offset_price, not both. Defaults to 0, resting at the best price."
                  },
                  "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 offset_ticks or offset_price, not both."
                  },
                  "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. 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 offset is in dollars or shares."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the offset is in ticks or shares."
                            },
                            "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 offset is in ticks or dollars. Set from the app; the API creates tick and dollar offsets only."
                            },
                            "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."
                            },
                            "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",
                            "price_limit",
                            "status",
                            "current_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": "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,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": 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 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"
                  }
                }
              }
            }
          },
          "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",
            "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"
                  }
                }
              }
            }
          }
        }
      },
      "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 offset is in dollars or shares."
                                  },
                                  "offset_price": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Dollars behind the best price, or null when the offset is in ticks or shares."
                                  },
                                  "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 offset is in ticks or dollars. Set from the app; the API creates tick and dollar offsets only."
                                  },
                                  "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."
                                  },
                                  "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",
                                  "price_limit",
                                  "status",
                                  "current_price",
                                  "filled_quantity",
                                  "avg_fill_price",
                                  "expires_at",
                                  "cancel_requested_at",
                                  "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,
                        "price_limit": "0.45",
                        "status": "active",
                        "current_price": "0.39",
                        "filled_quantity": "0",
                        "avg_fill_price": null,
                        "expires_at": null,
                        "cancel_requested_at": 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"
                  }
                }
              }
            }
          },
          "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 offset is in dollars or shares."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the offset is in ticks or shares."
                            },
                            "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 offset is in ticks or dollars. Set from the app; the API creates tick and dollar offsets only."
                            },
                            "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."
                            },
                            "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",
                            "price_limit",
                            "status",
                            "current_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": "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,
                    "price_limit": "0.45",
                    "status": "active",
                    "current_price": "0.39",
                    "filled_quantity": "0",
                    "avg_fill_price": null,
                    "expires_at": null,
                    "cancel_requested_at": 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"
                  }
                }
              }
            }
          }
        }
      },
      "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 offset is in dollars or shares."
                            },
                            "offset_price": {
                              "type": "string",
                              "nullable": true,
                              "description": "Dollars behind the best price, or null when the offset is in ticks or shares."
                            },
                            "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 offset is in ticks or dollars. Set from the app; the API creates tick and dollar offsets only."
                            },
                            "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."
                            },
                            "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",
                            "price_limit",
                            "status",
                            "current_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": "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,
                    "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",
                    "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"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/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.",
        "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"
                                ]
                              }
                            },
                            "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",
                            "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"
                    ],
                    "max_slippage_bps": 200,
                    "paused": {
                      "global": null,
                      "account": null,
                      "key": null
                    },
                    "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 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"
                                ]
                              }
                            },
                            "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",
                            "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"
                    ],
                    "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. Reads, cancels and resting orders are unaffected. 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"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "keyPrefix",
                                  "tradingAccountId",
                                  "scopes",
                                  "mode",
                                  "maxOrderNotionalMicros",
                                  "dailyNotionalLimitMicros",
                                  "maxWithdrawalMicros",
                                  "dailyWithdrawalLimitMicros",
                                  "expiresAt",
                                  "revokedAt",
                                  "lastUsedAt",
                                  "createdAt"
                                ]
                              }
                            }
                          },
                          "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",
                    "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"
                                }
                              },
                              "required": [
                                "id",
                                "name",
                                "keyPrefix",
                                "tradingAccountId",
                                "scopes",
                                "mode",
                                "maxOrderNotionalMicros",
                                "dailyNotionalLimitMicros",
                                "maxWithdrawalMicros",
                                "dailyWithdrawalLimitMicros",
                                "expiresAt",
                                "revokedAt",
                                "lastUsedAt",
                                "createdAt"
                              ]
                            },
                            "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"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "keyPrefix",
                            "tradingAccountId",
                            "scopes",
                            "mode",
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "maxWithdrawalMicros",
                            "dailyWithdrawalLimitMicros",
                            "expiresAt",
                            "revokedAt",
                            "lastUsedAt",
                            "createdAt"
                          ]
                        },
                        "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"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "keyPrefix",
                            "tradingAccountId",
                            "scopes",
                            "mode",
                            "maxOrderNotionalMicros",
                            "dailyNotionalLimitMicros",
                            "maxWithdrawalMicros",
                            "dailyWithdrawalLimitMicros",
                            "expiresAt",
                            "revokedAt",
                            "lastUsedAt",
                            "createdAt"
                          ]
                        },
                        "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"
                  },
                  "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": "https://api.lean.xyz",
          "description": "Lean API"
        }
      ]
    },
    "/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"
                                ]
                              },
                              "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"
                      ]
                    },
                    "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"
                                ]
                              },
                              "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": "https://api.lean.xyz",
          "description": "Lean API"
        }
      ]
    },
    "/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": "https://api.lean.xyz",
          "description": "Lean API"
        }
      ]
    },
    "/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": "https://api.lean.xyz",
          "description": "Lean API"
        }
      ]
    },
    "/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": "https://api.lean.xyz",
          "description": "Lean API"
        }
      ]
    }
  }
}
