{"openapi":"3.1.0","info":{"title":"Agent Desk Public API","version":"1.0.0","description":"Hyperliquid-grade REST + Streamable HTTP MCP API for long-tail token perpetuals and 7-day European options settled on 30-min TWAP spot. Carry sign convention: negative = house pays trader, positive = trader pays house."},"servers":[{"url":"https://druidcircle.app"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key"},"BearerAuth":{"type":"http","scheme":"bearer"}},"schemas":{"ErrorEnvelope":{"type":"object","required":["ok","error"],"properties":{"ok":{"const":false},"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}},"PerpQuoteRequest":{"type":"object","required":["chain","address","side","size_usd"],"properties":{"chain":{"type":"string","example":"solana"},"address":{"type":"string"},"side":{"type":"string","enum":["long","short"]},"size_usd":{"type":"number","minimum":1},"leverage":{"type":"number","minimum":1,"maximum":3,"default":1},"builder_id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{1,47}$"},"builder_fee_bps":{"type":"integer","minimum":0,"maximum":50}}},"OptionQuoteRequest":{"type":"object","required":["chain","address","kind","size_usd"],"properties":{"chain":{"type":"string","example":"solana"},"address":{"type":"string"},"kind":{"type":"string","enum":["call","put"]},"size_usd":{"type":"number","minimum":1},"horizon_days":{"type":"integer","enum":[7],"default":7},"builder_id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{1,47}$"},"builder_fee_bps":{"type":"integer","minimum":0,"maximum":50}}},"OrderRequest":{"type":"object","required":["quote_id","instrument"],"properties":{"quote_id":{"type":"string"},"instrument":{"type":"string","enum":["perp","option"]},"builder_id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{1,47}$"},"builder_fee_bps":{"type":"integer","minimum":0,"maximum":50}}},"CreateKeyRequest":{"type":"object","properties":{"label":{"type":"string","maxLength":80},"scopes":{"type":"array","items":{"type":"string","enum":["read","quote","trade","stream","admin"]},"default":["read","quote","trade","stream"]},"builder_id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{1,47}$"},"builder_fee_bps":{"type":"integer","minimum":0,"maximum":50,"default":0},"rate_limit_rpm":{"type":"integer","minimum":1,"maximum":10000,"default":120}}},"TpslRequest":{"type":"object","description":"Set or clear TWAP30-evaluated TP/SL seals. Pass null to clear; omit to keep unchanged.","properties":{"take_profit_px":{"type":["number","null"],"exclusiveMinimum":0},"stop_loss_px":{"type":["number","null"],"exclusiveMinimum":0}}},"MCPJsonRpcRequest":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"const":"2.0"},"id":{"type":["string","integer","null"]},"method":{"type":"string","enum":["initialize","notifications/initialized","tools/list","tools/call","ping"]},"params":{"type":"object"}}}}},"paths":{"/v1/meta":{"get":{"summary":"Exchange metadata, caps, carry sign convention, and settlement model","tags":["Market Data"],"responses":{"200":{"description":"Exchange metadata"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/markets/search":{"get":{"summary":"Search tradable markets by symbol, name, or contract address","tags":["Market Data"],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string","minLength":1,"maxLength":100}},{"name":"chain","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Normalized market search results"},"400":{"description":"Invalid query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/markets/{chain}/{address}":{"get":{"summary":"Full market snapshot: spot, 30m TWAP, carry rates, vault caps, and option availability","tags":["Market Data"],"parameters":[{"name":"chain","in":"path","required":true,"schema":{"type":"string"}},{"name":"address","in":"path","required":true,"schema":{"type":"string"}},{"name":"size_usd","in":"query","required":false,"schema":{"type":"number","default":100.0}}],"responses":{"200":{"description":"Market snapshot"},"400":{"description":"Invalid chain/address","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/markets/{chain}/{address}/bars":{"get":{"summary":"Historical OHLCV bars, closes, live spot, and 30m TWAP for a market (1h, 4h, or 24h)","tags":["Market Data"],"parameters":[{"name":"chain","in":"path","required":true,"schema":{"type":"string"}},{"name":"address","in":"path","required":true,"schema":{"type":"string"}},{"name":"window","in":"query","required":false,"schema":{"type":"string","enum":["1h","4h","24h"],"default":"4h"}}],"responses":{"200":{"description":"OHLCV bars and TWAP30"},"400":{"description":"Invalid chain/address or window","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/omens":{"get":{"summary":"Live ranked Short-Omen Board of desk-verified shortable memecoins (3-min cached)","tags":["Market Data"],"parameters":[{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["score","pump","carry","mcap"],"default":"score"}},{"name":"chain","in":"query","required":false,"schema":{"type":"string","enum":["all","solana","base","ethereum"],"default":"all"}},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":50,"default":12}}],"responses":{"200":{"description":"Ranked shortable memecoin omens with carry rates, room, and signal tags"},"400":{"description":"Invalid filter parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/leaderboard":{"get":{"summary":"Live trader leaderboard aggregated from real paper book & wallet ledger positions","tags":["Market Data"],"parameters":[{"name":"traveller_name","in":"query","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Ranked leaderboard entries with realized/unrealized P&L, win rate, volume, and prestige tier"},"400":{"description":"Invalid limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/quotes/perp":{"post":{"summary":"Lock a 60-second perpetual quote","tags":["Trading"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerpQuoteRequest"}}}},"responses":{"200":{"description":"Locked perp quote with quote_id, expires_at, and terms"},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"422":{"description":"Quote refused by desk policy or limits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/quotes/option":{"post":{"summary":"Lock a 60-second 7-day European option quote","tags":["Trading"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionQuoteRequest"}}}},"responses":{"200":{"description":"Locked option quote with quote_id, expires_at, premium_usd, strike_px"},"400":{"description":"Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"422":{"description":"Quote refused","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/orders":{"post":{"summary":"Execute a quoted perp or option order (supports Idempotency-Key)","tags":["Trading"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Client-generated unique key (max 255 chars). Replaying the same key with the same payload returns the exact stored response with header X-Idempotency-Replay: true. Reusing a key with a different payload returns 409 IDEMPOTENCY_KEY_CONFLICT.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderRequest"}}}},"responses":{"200":{"description":"Order filled and position opened"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"404":{"description":"Quote not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"409":{"description":"Order rejected or idempotency key conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/positions/{position_id}/close":{"post":{"summary":"Close an open perp position at 30-min TWAP spot (supports Idempotency-Key)","tags":["Trading"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"position_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Client-generated unique key (max 255 chars). Replaying the same key with the same payload returns the exact stored response with header X-Idempotency-Replay: true. Reusing a key with a different payload returns 409 IDEMPOTENCY_KEY_CONFLICT.","schema":{"type":"string","maxLength":255}}],"responses":{"200":{"description":"Position closed and settled"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"404":{"description":"Position not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"409":{"description":"Close rejected (stale window, option, or idempotency conflict)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/positions/{position_id}/tpsl":{"post":{"summary":"Set or clear TWAP30-evaluated take-profit / stop-loss seals on an open perp (zero wick stop-outs)","tags":["Trading"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"position_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TpslRequest"}}}},"responses":{"200":{"description":"Updated perp position with persisted TP/SL seals"},"400":{"description":"Invalid TP/SL bounds or non-perp position","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"404":{"description":"Position not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/positions":{"get":{"summary":"List open and settled perp and option positions with live mark, P&L, liq price, and carry","tags":["Account"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["all","open","closed","settled"]}},{"name":"instrument","in":"query","required":false,"schema":{"type":"string","enum":["all","perp","option"]}}],"responses":{"200":{"description":"Positions list"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/account":{"get":{"summary":"Normalized account summary (mode, free/bound balance, margin locked, P&L, open counts)","tags":["Account"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"responses":{"200":{"description":"Account summary"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/keys":{"post":{"summary":"Create a scoped API key with optional builder_id, builder_fee_bps (0-50 bps), and sliding-window rate limit (dev/admin-gated)","tags":["Builder Codes & Keys"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateKeyRequest"}}}},"responses":{"200":{"description":"Created scoped API key (plaintext api_key returned once)"},"400":{"description":"Invalid scope, builder_id, builder_fee_bps, or rate limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"403":{"description":"Admin scope required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}},"get":{"summary":"List API key metadata (never returns raw secrets; dev/admin-gated)","tags":["Builder Codes & Keys"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"builder_id","in":"query","required":false,"schema":{"type":"string"}},{"name":"include_revoked","in":"query","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"API key metadata list"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"403":{"description":"Admin scope required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/keys/{key_id}":{"delete":{"summary":"Revoke an API key immediately (dev/admin-gated)","tags":["Builder Codes & Keys"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"key_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Revoked key metadata"},"404":{"description":"Key not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/builders/{builder_id}/stats":{"get":{"summary":"Builder attribution stats: attributed volume, quotes/orders/fills counts, accrued fees, and recent fills","tags":["Builder Codes & Keys"],"parameters":[{"name":"builder_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"recent_limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":20}}],"responses":{"200":{"description":"Builder volume, fills, and accrued builder fees"},"400":{"description":"Invalid builder_id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/stream/positions":{"get":{"summary":"Server-Sent Events (SSE) stream of live position & account snapshots, diffs, and heartbeats","tags":["Streaming"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"interval_s","in":"query","required":false,"schema":{"type":"number","default":2.0,"minimum":0.1,"maximum":30.0}},{"name":"heartbeat_s","in":"query","required":false,"schema":{"type":"number","default":15.0,"minimum":0.5,"maximum":60.0}},{"name":"max_events","in":"query","required":false,"schema":{"type":"integer","minimum":1}},{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["all","open","closed","settled"]}},{"name":"instrument","in":"query","required":false,"schema":{"type":"string","enum":["all","perp","option"]}},{"name":"diff_only","in":"query","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"text/event-stream emitting 'snapshot', 'diff', and 'heartbeat' events"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/stream/omens":{"get":{"summary":"Server-Sent Events (SSE) stream of the live ranked Short-Omen Board with diff-friendly frames & heartbeats","tags":["Streaming"],"parameters":[{"name":"sort","in":"query","required":false,"schema":{"type":"string","enum":["score","pump","carry","mcap"],"default":"score"}},{"name":"chain","in":"query","required":false,"schema":{"type":"string","enum":["all","solana","base","ethereum"],"default":"all"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":50,"default":12}},{"name":"interval_s","in":"query","required":false,"schema":{"type":"number","default":5.0,"minimum":0.1,"maximum":60.0}},{"name":"heartbeat_s","in":"query","required":false,"schema":{"type":"number","default":15.0,"minimum":0.5,"maximum":60.0}},{"name":"max_events","in":"query","required":false,"schema":{"type":"integer","minimum":1}},{"name":"diff_only","in":"query","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"text/event-stream emitting 'snapshot', 'diff', and 'heartbeat' events"},"400":{"description":"Invalid stream parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/stream/book":{"get":{"summary":"Server-Sent Events (SSE) stream of the live house & position book with diff-friendly frames & heartbeats","tags":["Streaming"],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"parameters":[{"name":"interval_s","in":"query","required":false,"schema":{"type":"number","default":2.0,"minimum":0.1,"maximum":30.0}},{"name":"heartbeat_s","in":"query","required":false,"schema":{"type":"number","default":15.0,"minimum":0.5,"maximum":60.0}},{"name":"max_events","in":"query","required":false,"schema":{"type":"integer","minimum":1}},{"name":"diff_only","in":"query","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"text/event-stream emitting 'snapshot', 'diff', and 'heartbeat' events"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}},"/v1/openapi.json":{"get":{"summary":"Scoped OpenAPI 3.1 JSON specification for /v1/* and /mcp","tags":["Discovery"],"responses":{"200":{"description":"OpenAPI 3.1 JSON"}}}},"/mcp":{"post":{"summary":"Streamable HTTP MCP JSON-RPC 2.0 server (protocolVersion 2025-03-26)","tags":["MCP"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MCPJsonRpcRequest"}}}},"responses":{"200":{"description":"JSON-RPC 2.0 response"},"202":{"description":"Notification accepted"}}}}}}