Skip to main content
POST
Error

Authorizations

Authorization
string
header
required

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.

Body

application/json
client_order_id
string
required

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.

Maximum string length: 40
Pattern: ^[A-Za-z0-9_-]{1,40}$
max_slippage_bps
integer
required

Furthest each sell may trade below the best bid as read when it is placed, in basis points.

Required range: 0 <= x <= 10000
venue
enum<string>

Only this venue. Defaults to every venue.

Available options:
kalshi,
polymarket,
polymarket_us,
hyperliquid
market_id
string

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.

Required string length: 1 - 512
limit_price
string

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
enum<string>

With limit_price: gtc rests the unfilled part, ioc cancels it. Defaults to gtc with limit_price and ioc without.

Available options:
gtc,
ioc

Response

One leg per position in scope

success
enum<boolean>
required
Available options:
true
data
object
required
meta
object
required