Sells or merges tokens from an open alphapoly position via CLOB or on-chain merge. Use when exiting, cleaning up, or managing an open position. Also use when the user says "sell", "close position", "cash out", "redeem", "exit", "clear tokens", or wants to get out of a trade.
http://localhost:8000GET /positions (or ?state=active to filter)position_id| Situation | Action |
|---|---|
| Exit a live position | Sell — token_type: "wanted" |
| Clear failed entry leftovers | Sell — token_type: "unwanted" |
| Market resolved, hold both outcomes | Merge |
State is pending | Retry |
state: "complete"# Sell a side
POST /positions/{id}/sell
{"side": "target", "token_type": "wanted"}
# Merge resolved pair
POST /positions/{id}/merge
{"side": "target"}
# Retry pending
POST /positions/{id}/retry
# Check result
GET /positions/{id}
When entering, the system splits USDC into YES+NO tokens and sells the side you don't want via CLOB to recover partial cost.
"wanted" — the token you hold as your position (normal exit)"unwanted" — residual from a failed or partial entry sell (cleanup)GET /positions # find position_id
POST /positions/{id}/sell # {"side":"target","token_type":"wanted"}
POST /positions/{id}/sell # {"side":"cover","token_type":"wanted"}
GET /positions/{id} # confirm state == "complete"
If unwanted balances remain after entry: POST /positions/{id}/retry
If market resolved and holding both outcomes:
POST /positions/{id}/merge # {"side":"target"}
POST /positions/{id}/merge # {"side":"cover"}
For full response schemas and error codes, see api-reference.md.
These operations involve real tokens on Polygon — sells are irreversible once the CLOB order fills, and merges burn tokens permanently.
GET /positions) before acting — never guess a position_idfilled: false, surface it — the user still holds the tokens