{"openapi":"3.1.0","info":{"title":"Cofferline API","version":"0.1.0","description":"Treasury infrastructure for autonomous agents. Identity is your wallet (SIWE); no email, no CAPTCHA. Structured errors: {code, message, remediation, docs_url, request_id}. Mutations accept Idempotency-Key."},"servers":[{"url":"https://api.cofferline.com"}],"components":{"securitySchemes":{"Bearer":{"type":"http","scheme":"bearer","description":"cl_sess_… session token or cl_key_… API key"}},"schemas":{"FeatureRequest":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"status":{"type":"string","enum":["open","planned","shipped","declined"]},"created_at":{"type":"string"}},"required":["id","title","status","created_at"]},"AccountExport":{"type":"object","properties":{"export_version":{"type":"integer"},"generated_at":{"type":"string"},"truncated":{"type":"array","items":{"type":"string"}},"account":{"type":"object","properties":{"address":{"type":"string"},"contact":{"type":["string","null"]},"kind":{"type":"string"},"created_at":{"type":"string"},"offboarded_at":{"type":["string","null"]}},"required":["address","contact","kind","created_at","offboarded_at"]},"api_keys":{"type":"array","items":{"type":"object","additionalProperties":{}}},"sessions":{"type":"array","items":{"type":"object","additionalProperties":{}}},"policies":{"type":"array","items":{"type":"object","additionalProperties":{}}},"delegations":{"type":"array","items":{"type":"object","additionalProperties":{}}},"intents":{"type":"array","items":{"type":"object","additionalProperties":{}}},"ledger_entries":{"type":"array","items":{"type":"object","additionalProperties":{}}},"payment_credits":{"type":"array","items":{"type":"object","additionalProperties":{}}},"balance":{"type":["object","null"],"properties":{"micro":{"type":"string"}},"required":["micro"]},"events":{"type":"array","items":{"type":"object","additionalProperties":{}}},"webhooks":{"type":"object","properties":{"secret_configured":{"type":"boolean"},"failures":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["secret_configured","failures"]},"auto_topup":{"type":["object","null"],"properties":{"rule":{"type":["object","null"],"additionalProperties":{}},"authorizations":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["rule","authorizations"]},"venue_credentials":{"type":"array","items":{"type":"object","additionalProperties":{}}},"pm_orders":{"type":"array","items":{"type":"object","additionalProperties":{}}},"pm_positions":{"type":"array","items":{"type":"object","additionalProperties":{}}},"audit_log":{"type":"array","items":{"type":"object","additionalProperties":{}}},"statements_manifest":{"type":"object","properties":{"bucket_bound":{"type":"boolean"},"keys":{"type":"array","items":{"type":"string"}}},"required":["bucket_bound","keys"]}},"required":["export_version","generated_at","truncated","account","api_keys","sessions","policies","delegations","intents","ledger_entries","payment_credits","balance","events","webhooks","auto_topup","venue_credentials","pm_orders","pm_positions","audit_log","statements_manifest"]},"OffboardResult":{"type":"object","properties":{"offboarded":{"type":"boolean","enum":[true]},"address":{"type":"string"},"offboarded_at":{"type":"string"},"deleted":{"type":"object","properties":{"api_keys_revoked":{"type":"integer"},"sessions_revoked":{"type":"integer"},"credentials_zeroed":{"type":"integer"},"auto_topup_arrows_removed":{"type":"integer"},"webhook_secret_removed":{"type":"boolean"},"webhook_failures_removed":{"type":"integer"},"contact_scrubbed":{"type":"boolean"}},"required":["api_keys_revoked","sessions_revoked","credentials_zeroed","auto_topup_arrows_removed","webhook_secret_removed","webhook_failures_removed","contact_scrubbed"]},"retained":{"type":"array","items":{"type":"string"}},"scheduled":{"type":"array","items":{"type":"string"}},"delegations_revoked":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"account":{"type":"string"},"uninstall_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]},"invalidate_nonce_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]}},"required":["id","account","uninstall_call","invalidate_nonce_call"]}},"cancellation":{},"note":{"type":"string"}},"required":["offboarded","address","offboarded_at","deleted","retained","scheduled","delegations_revoked","note"]},"OffboardRequest":{"type":"object","properties":{"confirm_wallet_address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"reason":{"type":"string","maxLength":300,"default":"offboard"}},"required":["confirm_wallet_address"]},"PendingSettlement":{"type":"object","properties":{"settlement_status":{"type":"string","enum":["pending"]},"nonce":{"type":"string"},"value_usd":{"type":"string"},"remediation":{"type":"string"}},"required":["settlement_status","nonce","value_usd","remediation"]},"Delegation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"account":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"},"status":{"type":"string","enum":["prepared","active","revoked","expired"]},"permission_id":{"type":"string"},"validation_id":{"type":"string"},"enable_data":{"type":"string"},"kernel_nonce":{"type":"integer"},"digest":{"type":"string"},"session_key":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"scope":{},"account_deployed":{"type":"boolean"},"valid_until":{"type":"string"},"created_at":{"type":"string"},"confirmed_at":{"type":["string","null"]},"revoked_at":{"type":["string","null"]}},"required":["id","account","chain_id","status","permission_id","validation_id","enable_data","kernel_nonce","digest","session_key","valid_until","created_at","confirmed_at","revoked_at"]},"DelegationPrepareRequest":{"type":"object","properties":{"account":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"The Kernel v3.1 smart account granting scope"},"chain_id":{"anyOf":[{"type":"number","enum":[84532]},{"type":"number","enum":[8453]}]},"calls":{"type":"array","items":{"type":"object","properties":{"target":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"selector":{"type":"string","pattern":"^0x[0-9a-fA-F]{8}$","example":"0xd0e30db0"},"value_limit":{"type":"string","pattern":"^\\d+$"}},"required":["target","selector","value_limit"]},"minItems":1,"maxItems":32},"valid_after":{"type":"integer","minimum":0},"valid_until":{"type":"integer","exclusiveMinimum":0},"rate_limit":{"type":"object","properties":{"count":{"type":"integer","exclusiveMinimum":0},"interval_secs":{"type":"integer","minimum":0}},"required":["count"]}},"required":["account","chain_id","calls","valid_until"]},"DelegationRevocation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["revoked"]},"revocation":{"type":"object","properties":{"uninstall_call":{"type":"object","properties":{"to":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"data":{"type":"string"}},"required":["to","data"]},"invalidate_nonce_call":{"type":"object","properties":{"to":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"data":{"type":"string"}},"required":["to","data"]},"note":{"type":"string"}},"required":["uninstall_call","invalidate_nonce_call","note"]}},"required":["id","status","revocation"]},"AutoTopupState":{"type":"object","properties":{"threshold_usd":{"type":"string"},"max_per_month":{"type":"integer"},"suspended":{"type":"boolean"},"consecutive_failures":{"type":"integer"},"quiver":{"type":"object","properties":{"ready":{"type":"integer"},"settled":{"type":"integer"},"failed":{"type":"integer"},"expired":{"type":"integer"}},"required":["ready","settled","failed","expired"]},"ready_value_usd":{"type":"string"},"used_this_month":{"type":"integer"},"arrows":{"type":"array","items":{"type":"object","properties":{"nonce":{"type":"string"},"payer":{"type":"string"},"value_usd":{"type":"string"},"valid_before":{"type":"string"},"status":{"type":"string","enum":["ready","settling","settled","failed","expired"]},"tx_hash":{"type":["string","null"]},"fail_reason":{"type":["string","null"]}},"required":["nonce","payer","value_usd","valid_before","status","tx_hash","fail_reason"]}}},"required":["threshold_usd","max_per_month","suspended","consecutive_failures","quiver","ready_value_usd","used_this_month","arrows"]},"PrepaidBalance":{"type":"object","properties":{"balance_usd":{"type":"string"},"currency":{"type":"string","enum":["USD"]}},"required":["balance_usd","currency"]},"PmCredentialRotation":{"type":"object","properties":{"credential_id":{"type":"string","format":"uuid"},"venue":{"type":"string","enum":["polymarket"]},"funder":{"type":"string"},"old_owner":{"type":"string"},"new_owner":{"type":"string"},"prev_owner":{"type":"string"},"call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"},"value":{"type":"string","enum":["0"]}},"required":["to","data","value"]},"sequence":{"type":"array","items":{"type":"string"}},"rotation_policy":{"type":"string"}},"required":["credential_id","venue","funder","old_owner","new_owner","prev_owner","call","sequence","rotation_policy"]},"PmOnboarding":{"type":"object","properties":{"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"trade_ready":{"type":"boolean"},"approvals":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"description":{"type":"string"},"approved":{"type":"boolean"},"call":{"type":["object","null"],"properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]}},"required":["id","description","approved","call"]}},"collateral":{"type":"object","properties":{"pusd":{"type":"string"},"usdce_unwrapped":{"type":"string"},"wrap_calls":{"type":["array","null"],"items":{"type":"object","properties":{"id":{"type":"string"},"description":{"type":"string"},"to":{"type":"string"},"data":{"type":"string"}},"required":["id","description","to","data"]}}},"required":["pusd","usdce_unwrapped","wrap_calls"]},"collateral_note":{"type":"string"}},"required":["address","trade_ready","approvals","collateral","collateral_note"]}},"parameters":{}},"paths":{"/v1/auth/challenge":{"post":{"tags":["auth"],"summary":"Start SIWE authentication: returns a single-use challenge","requestBody":{"description":"Wallet address to authenticate","content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"}},"required":["address"]}}}},"responses":{"200":{"description":"SIWE challenge (10-minute, single-use nonce)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"nonce":{"type":"string"},"domain":{"type":"string"},"uri":{"type":"string"},"version":{"type":"string","enum":["1"]},"chain_id":{"type":"integer"},"issued_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"expiration_time":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["message","nonce","domain","uri","version","chain_id","issued_at","expiration_time"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/auth/verify":{"post":{"tags":["auth"],"summary":"Complete SIWE authentication: exchanges a signed challenge for a session","description":"Exchanges a signed SIWE challenge for a bearer session, creating the account row on first sign-in.\n\nOn the dev environment only, sending `x-cofferline-test-account: 1` marks a NEWLY created account as an automated-test fixture (#227): it is left out of the operator's tenant counts and is the only kind of row the housekeeping sweep deletes. It never changes an account that already exists, and it is ignored entirely in production.","requestBody":{"description":"The signed SIWE message","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"signature":{"type":"string","pattern":"^0x[0-9a-fA-F]+$"}},"required":["message","signature"]}}}},"responses":{"200":{"description":"Bearer session token (returned once)","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"},"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["token","address","expires_at"]}}}},"401":{"description":"Expired/used nonce or invalid signature","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/feedback":{"get":{"tags":["feedback"],"summary":"Every feature request ever submitted (public, unauthenticated)","description":"The transparent counterpart to charging for submission: titles, statuses, and dates are public so anyone can see what has been asked and what came of it. Bodies and requesters are not published.","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":200,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Newest first","content":{"application/json":{"schema":{"type":"object","properties":{"requests":{"type":"array","items":{"$ref":"#/components/schemas/FeatureRequest"}}},"required":["requests"]}}}}}},"post":{"tags":["feedback"],"summary":"Submit a feature request ($1, anti-spam)","description":"Costs $1, charged to the prepaid balance when funded, otherwise answered with standard x402 payment requirements — retry with the signed authorization in X-PAYMENT. The charge exists purely as spam friction; the resulting request appears in the public list at GET /v1/feedback. On the x402 path the fee settles on-chain first; a durable pending-settlement record (carrying this request's body) exists before anything is broadcast, so an interrupted submission converges on exactly one credit, one fee debit and one recorded request (202 = outcome pending, reconciled from chain truth).","security":[{"Bearer":[]}],"requestBody":{"description":"What you want and why","content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","minLength":8,"maxLength":120},"body":{"type":"string","minLength":20,"maxLength":4000}},"required":["title","body"]}}}},"responses":{"201":{"description":"Recorded and delivered to the operator","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"charged_usd":{"type":"string"},"paid_ref":{"type":"string"}},"required":["id","status","charged_usd","paid_ref"]}}}},"202":{"description":"Fee settlement outcome unknown — being reconciled from chain truth; do not re-sign","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PendingSettlement"}}}},"400":{"description":"Invalid payment authorization","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"402":{"description":"Payment required — pay via x402 or top up the prepaid balance","content":{"application/json":{"schema":{"type":"object","properties":{"x402Version":{"type":"number"},"error":{"type":"string"},"accepts":{"type":"array","items":{}}},"required":["x402Version","error","accepts"]}}}},"503":{"description":"Payments unconfigured, or the settlement reconciler unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/quotes":{"post":{"tags":["quotes"],"summary":"Free live quote comparison: best full-size venue quote vs a sliced execution estimate","description":"Unauthenticated and free (edge rate-limited). Every number derives from live venue quote APIs at request time. The sliced figure comes from the SAME planner that executes intents, run in its preview mode: one extra small quote from the winning venue measures price impact, the planner sizes slices against half the stated slippage budget, and it may return one slice or refuse outright. It is an estimate, never a promise.","requestBody":{"description":"Pair and size to quote","content":{"application/json":{"schema":{"type":"object","properties":{"chain_id":{"type":"integer","default":8453},"sell_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"buy_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"sell_amount":{"type":"string","pattern":"^[1-9]\\d*$"}},"required":["sell_token","buy_token","sell_amount"]}}}},"responses":{"200":{"description":"Live comparison","content":{"application/json":{"schema":{"type":"object","properties":{"chain_id":{"type":"integer"},"sell_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"buy_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"sell_amount":{"type":"string"},"quoted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"full_size":{"type":"object","properties":{"quotes":{"type":"array","items":{"type":"object","properties":{"venue":{"type":"string"},"buy_amount":{"type":"string"},"fee_amount":{"type":"string"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["venue","buy_amount","fee_amount","expires_at"]},"minItems":1},"best_venue":{"type":"string"},"best_buy_amount":{"type":"string"}},"required":["quotes","best_venue","best_buy_amount"]},"sliced_plan":{"type":["object","null"],"properties":{"slice_count":{"type":"integer","minimum":1},"slice_sell_amount":{"type":"string"},"probe_sell_amount":{"type":"string"},"probe_buy_amount":{"type":"string"},"impact_bps_at_full_size":{"type":"number"},"interval_ms":{"type":"integer","minimum":0},"estimated_buy_total":{"type":"string"},"venue":{"type":"string"}},"required":["slice_count","slice_sell_amount","probe_sell_amount","probe_buy_amount","impact_bps_at_full_size","interval_ms","estimated_buy_total","venue"]},"expected_savings":{"type":["object","null"],"properties":{"buy_amount":{"type":"string"},"bps":{"type":"number"}},"required":["buy_amount","bps"]},"planner_abort":{"type":["object","null"],"properties":{"reason":{"type":"string"},"detail":{"type":"string"}},"required":["reason","detail"]},"assumed_max_slippage_bps":{"type":"integer"},"metered_fee":{"type":"object","properties":{"product":{"type":"string","enum":["conversion"]},"estimated_fee_usd":{"type":"string"},"basis":{"type":"string"}},"required":["product","estimated_fee_usd","basis"]}},"required":["chain_id","sell_token","buy_token","sell_amount","quoted_at","full_size","sliced_plan","expected_savings","planner_abort","assumed_max_slippage_bps","metered_fee"]}}}},"400":{"description":"Invalid request or unsupported chain","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"502":{"description":"No venue answered","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/screenings":{"post":{"tags":["screening"],"summary":"Screen an address against sanctions lists (OFAC SDN)","description":"Real OFAC SDN crypto-address data. sanctioned:true means the address is on the list; policies may require screening above a USD threshold before outbound transfers (COUNTERPARTY_BLOCKED).","requestBody":{"description":"Address to screen","content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},"required":["address"]}}}},"responses":{"200":{"description":"Screening result","content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"sanctioned":{"type":"boolean"},"lists":{"type":"array","items":{"type":"string"}},"provider_count":{"type":"integer"}},"required":["address","sanctioned","lists","provider_count"]}}}}}}},"/v1/tokens":{"get":{"tags":["tokens"],"summary":"Tokens this platform will accept on an intent, per chain","description":"Unauthenticated and free (edge rate-limited). `symbol` is the exact UPPERCASE string a policy's spend.token_allowlist must carry — the allowlist resolves names through this same registry and refuses one it cannot identify. `stable` means USD-pegged and valued 1:1, which is what makes a conversion's spend caps evaluable; a euro-pegged token reports false. Membership is not a promise that a pair is routable at a given size — POST /v1/quotes answers that live.","parameters":[{"schema":{"type":"string","pattern":"^\\d+$","description":"Limit to one chain. Omit to list every supported chain."},"required":false,"description":"Limit to one chain. Omit to list every supported chain.","name":"chain_id","in":"query"}],"responses":{"200":{"description":"Registry contents per chain","content":{"application/json":{"schema":{"type":"object","properties":{"chains":{"type":"array","items":{"type":"object","properties":{"chain_id":{"type":"integer"},"name":{"type":"string"},"wrapped_native":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"venues":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"settles":{"type":"boolean"}},"required":["name","settles"]}},"tokens":{"type":"array","items":{"type":"object","properties":{"symbol":{"type":"string"},"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"decimals":{"type":"integer"},"stable":{"type":"boolean"}},"required":["symbol","address","decimals","stable"]}}},"required":["chain_id","name","wrapped_native","venues","tokens"]}},"note":{"type":"string"}},"required":["chains","note"]}}}},"400":{"description":"Malformed or unsupported chain_id","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/me":{"get":{"tags":["auth"],"summary":"Identify the authenticated account","security":[{"Bearer":[]}],"responses":{"200":{"description":"The wallet address and credential kind","content":{"application/json":{"schema":{"type":"object","properties":{"address":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"auth_kind":{"type":"string","enum":["session","api_key","cf_access","payment"]}},"required":["address","auth_kind"]}}}},"401":{"description":"Missing or invalid credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/keys":{"post":{"tags":["keys"],"summary":"Create an API key (raw token returned exactly once)","description":"Optionally pinned to a subset of wallets (#154): a wallet-scoped key reaches only classified wallet-bearing surfaces, only for its own wallets, deny-by-default. Requesting the supervisor scope mints the fleet-discipline credential (read + revocations/cancels/panic, nothing that opens exposure).","security":[{"Bearer":[]}],"requestBody":{"description":"Optional name, scopes, expiry, IP/wallet pins","content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin","supervisor"]},"minItems":1},"expires_in_days":{"type":"integer","minimum":1,"maximum":365},"allowed_ips":{"type":"array","items":{"type":"string","minLength":3,"maxLength":45,"pattern":"^[0-9A-Fa-f:.]+$"},"minItems":1,"maxItems":50},"wallets":{"type":"array","items":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"minItems":1,"maxItems":50}}}}}},"responses":{"201":{"description":"The new key; store the token now","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"token":{"type":"string"},"name":{"type":["string","null"]},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin","supervisor"]}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"allowed_ips":{"type":["array","null"],"items":{"type":"string"}},"wallets":{"type":["array","null"],"items":{"type":"string"}}},"required":["id","token","name","scopes","created_at","expires_at","allowed_ips","wallets"]}}}},"400":{"description":"Invalid request or impossible scope/pin combination","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"Requires session or admin-scoped key","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["keys"],"summary":"List this account's API keys (never returns token material)","security":[{"Bearer":[]}],"responses":{"200":{"description":"All keys including revoked ones","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":["string","null"]},"scopes":{"type":"array","items":{"type":"string"}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"allowed_ips":{"type":["array","null"],"items":{"type":"string"}},"wallets":{"type":["array","null"],"items":{"type":"string"}}},"required":["id","name","scopes","created_at","last_used_at","revoked_at","expires_at","allowed_ips","wallets"]}}},"required":["keys"]}}}},"403":{"description":"Requires session, admin- or supervisor-scoped key","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/keys/enroll":{"post":{"tags":["keys"],"summary":"Enroll a fleet: mint one wallet-scoped API key per agent wallet, atomically","description":"One call, one key per agent wallet, each pinned to exactly its own wallet (deny-by-default enforcement). All keys are minted in a single transaction — a fleet is enrolled entirely or not at all. Tokens are returned exactly once.","security":[{"Bearer":[]}],"requestBody":{"description":"The agent wallets to enroll (max 25)","content":{"application/json":{"schema":{"type":"object","properties":{"agents":{"type":"array","items":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"name":{"type":"string","maxLength":100},"scopes":{"type":"array","items":{"type":"string","enum":["read","write"]},"minItems":1},"expires_in_days":{"type":"integer","minimum":1,"maximum":365},"allowed_ips":{"type":"array","items":{"type":"string","minLength":3,"maxLength":45,"pattern":"^[0-9A-Fa-f:.]+$"},"minItems":1,"maxItems":50}},"required":["wallet"]},"minItems":1,"maxItems":25}},"required":["agents"]}}}},"responses":{"201":{"description":"One key per agent, request order; store tokens now","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"token":{"type":"string"},"name":{"type":["string","null"]},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin","supervisor"]}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"allowed_ips":{"type":["array","null"],"items":{"type":"string"}},"wallets":{"type":["array","null"],"items":{"type":"string"}}},"required":["id","token","name","scopes","created_at","expires_at","allowed_ips","wallets"]}}},"required":["keys"]}}}},"400":{"description":"Invalid request (e.g. duplicate agent wallets)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"Requires session or admin-scoped key","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/keys/rotate":{"post":{"tags":["keys"],"summary":"Rotate API keys in batch: identical grants, fresh tokens, atomic","description":"Replaces each named key with a new one whose scopes/wallets/IP pins are copied server-side (rotation never widens), then retires the old credential — immediately, or after overlap_seconds (never past its own prior expiry). All-or-nothing: any invalid id fails the whole batch with no changes. Tokens are returned exactly once.","security":[{"Bearer":[]}],"requestBody":{"description":"The key ids to rotate (max 100)","content":{"application/json":{"schema":{"type":"object","properties":{"key_ids":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":100},"overlap_seconds":{"type":"integer","minimum":0,"maximum":86400,"default":0}},"required":["key_ids"]}}}},"responses":{"200":{"description":"Old→new mapping; store the new tokens now","content":{"application/json":{"schema":{"type":"object","properties":{"rotated":{"type":"array","items":{"type":"object","properties":{"old_id":{"type":"string","format":"uuid"},"old_valid_until":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"key":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"token":{"type":"string"},"name":{"type":["string","null"]},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin","supervisor"]}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]},"allowed_ips":{"type":["array","null"],"items":{"type":"string"}},"wallets":{"type":["array","null"],"items":{"type":"string"}}},"required":["id","token","name","scopes","created_at","expires_at","allowed_ips","wallets"]}},"required":["old_id","old_valid_until","key"]}}},"required":["rotated"]}}}},"403":{"description":"Requires session or admin-scoped key","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"One or more ids are unknown, foreign, revoked, or expired","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/keys/{id}":{"delete":{"tags":["keys"],"summary":"Revoke an API key","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Key revoked","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"revoked":{"type":"boolean","enum":[true]}},"required":["id","revoked"]}}}},"403":{"description":"The target key's wallet pin exceeds this key's scope (#289)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No active key with that id on this account","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/account/export":{"get":{"tags":["account"],"summary":"Export all of this account's data (wallet-verified, tenant-isolated)","description":"Returns a complete, versioned JSON snapshot of everything this account owns: profile, API-key/session metadata (never token material), policies, delegations, intents, the double-entry ledger, prepaid credits and balance, events, webhook configuration and failures, auto-topup rule and authorization metadata (never the EIP-3009 signatures), venue credential metadata (never the sealed ciphertext), PM orders and positions, audit records, and an R2 statement object manifest. Authenticated ⇒ wallet-verified; RLS scopes it to your account. Unbounded sections are capped (see `truncated`).","security":[{"Bearer":[]}],"responses":{"200":{"description":"The account data export","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountExport"}}}},"403":{"description":"Requires a session or an unrestricted credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/account/offboard":{"post":{"tags":["account"],"summary":"Offboard this account: type-to-confirm, revoke everything, scrub PII, retire in place","description":"Wallet-verified account closure. Echo your wallet address in `confirm_wallet_address` (type-to-confirm). Suspends the account, revokes every API key AND session (including the calling credential), flips delegations to revoked with owner-submittable uninstall/invalidate calldata, zeroes every venue-credential ciphertext, removes the auto-topup rule and arrows (with cancellation instructions — deleting the row does NOT revoke the signatures on-chain), removes the webhook secret and dead-letters, scrubs the account's contact field, and marks the account offboarded. The row is NOT deleted: the append-only ledger, events and intents FK into it, and those books plus the audit trail of money movement are retained by design. R2 statement objects are deleted by the housekeeping sweep (they are regenerable re-derivations of the retained ledger). Idempotent: re-running an already-offboarded account is a no-op that returns the same retirement facts. Requires a session or admin-scoped key.","security":[{"Bearer":[]}],"requestBody":{"description":"Type-to-confirm the wallet address","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OffboardRequest"}}}},"responses":{"200":{"description":"Offboarded; finish any on-chain revocation with the calldata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OffboardResult"}}}},"400":{"description":"The confirmation address does not match the authenticated wallet","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"Requires a session or admin-scoped key","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/policies":{"put":{"tags":["policies"],"summary":"Submit a policy document; creates immutable version n+1 for its wallet","description":"Versions are hash-addressed and append-only — history is never rewritten. Re-submitting the latest document verbatim returns the existing version instead of minting a duplicate. Only version, wallet and chain_id are required: anything omitted is filled from the published platform defaults, stored as part of the document, and listed in `defaulted`.","security":[{"Bearer":[]}],"requestBody":{"description":"Policy document; {version, wallet, chain_id} is a complete one (schema: /schemas/policy-v1.json)","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"number","enum":[1]},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"},"float":{"type":"object","properties":{"token":{"type":"string","default":"USDC"},"min":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0","description":"Sweep volatile balances into `token` when float falls below this. 0 disables autonomous sweeping."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"sweep_above_pct":{"type":"integer","minimum":1,"maximum":100,"default":25}},"default":{"token":"USDC","min":"0","target":"0","sweep_above_pct":25}},"execution":{"type":"object","properties":{"max_slippage_bps":{"type":"integer","minimum":1,"maximum":10000,"default":50},"max_slice_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"deadline_minutes":{"type":"integer","minimum":1,"default":30},"venues":{"type":"array","items":{"type":"string"},"minItems":1,"default":["cow","paraswap"],"description":"Execution venues, in preference order. Membership is the allowlist — a venue absent here is refused — and the FIRST entry is the one routing prefers. ['paraswap','cow'] therefore means something different from ['cow','paraswap']."}},"default":{"max_slippage_bps":50,"max_slice_usd":"250","deadline_minutes":30,"venues":["cow","paraswap"]}},"gas":{"type":"object","properties":{"floor":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.001","description":"Top up when the native balance drops below this. 0 disables top-ups."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.005","description":"Native balance a top-up restores, and the ceiling on native value any delegated call may carry."},"strategy":{"type":"string","enum":["topup"],"default":"topup"}},"default":{"floor":"0.001","target":"0.005","strategy":"topup"}},"stables":{"type":"object","properties":{"canonical":{"type":"string","default":"USDC"},"tolerance_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null,"description":"Non-canonical stable balance above which the wallet converts to the canonical stable without being asked. null disables unprompted FX entirely."}},"default":{"canonical":"USDC","tolerance_usd":null}},"spend":{"type":"object","properties":{"daily_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"1000"},"per_tx_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"velocity_per_hour":{"type":"integer","minimum":1,"default":10},"token_allowlist":{"type":"array","items":{"type":"string"},"minItems":1,"default":["USDC","WETH"],"description":"Symbols this wallet may END UP HOLDING. The buy leg of a conversion is checked against it; the sell leg deliberately is not."},"counterparty_screening_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":"100"},"human_approval_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null}},"default":{"daily_usd":"1000","per_tx_usd":"250","velocity_per_hour":10,"token_allowlist":["USDC","WETH"],"counterparty_screening_above_usd":"100","human_approval_above_usd":null}},"alerts":{"type":"object","properties":{"webhook":{"type":["string","null"],"format":"uri","default":null},"events":{"type":"array","items":{"type":"string"},"default":["*"],"description":"Event types delivered to `webhook`; '*' is every type."}},"default":{"webhook":null,"events":["*"]}},"prediction_markets":{"type":"object","properties":{"per_market_cap_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"daily_loss_stop_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"max_resolution_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"market_allowlist":{"type":"array","items":{"type":"string"},"minItems":1},"exposure_basis":{"type":"string","enum":["gross","net"]}},"required":["per_market_cap_usd","daily_loss_stop_usd","max_resolution_exposure_usd"]},"rebalance":{"type":"object","properties":{"max_amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"corridors":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["max_amount_usd","corridors"]}},"required":["version","wallet","chain_id"]}}}},"responses":{"200":{"description":"Unchanged — latest version already matches","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"version":{"type":"integer"},"hash":{"type":"string"},"created_at":{"type":"string"},"unchanged":{"type":"boolean"},"document":{"type":"object","properties":{"version":{"type":"number","enum":[1]},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"},"float":{"type":"object","properties":{"token":{"type":"string","default":"USDC"},"min":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0","description":"Sweep volatile balances into `token` when float falls below this. 0 disables autonomous sweeping."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"sweep_above_pct":{"type":"integer","minimum":1,"maximum":100,"default":25}},"default":{"token":"USDC","min":"0","target":"0","sweep_above_pct":25}},"execution":{"type":"object","properties":{"max_slippage_bps":{"type":"integer","minimum":1,"maximum":10000,"default":50},"max_slice_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"deadline_minutes":{"type":"integer","minimum":1,"default":30},"venues":{"type":"array","items":{"type":"string"},"minItems":1,"default":["cow","paraswap"],"description":"Execution venues, in preference order. Membership is the allowlist — a venue absent here is refused — and the FIRST entry is the one routing prefers. ['paraswap','cow'] therefore means something different from ['cow','paraswap']."}},"default":{"max_slippage_bps":50,"max_slice_usd":"250","deadline_minutes":30,"venues":["cow","paraswap"]}},"gas":{"type":"object","properties":{"floor":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.001","description":"Top up when the native balance drops below this. 0 disables top-ups."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.005","description":"Native balance a top-up restores, and the ceiling on native value any delegated call may carry."},"strategy":{"type":"string","enum":["topup"],"default":"topup"}},"default":{"floor":"0.001","target":"0.005","strategy":"topup"}},"stables":{"type":"object","properties":{"canonical":{"type":"string","default":"USDC"},"tolerance_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null,"description":"Non-canonical stable balance above which the wallet converts to the canonical stable without being asked. null disables unprompted FX entirely."}},"default":{"canonical":"USDC","tolerance_usd":null}},"spend":{"type":"object","properties":{"daily_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"1000"},"per_tx_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"velocity_per_hour":{"type":"integer","minimum":1,"default":10},"token_allowlist":{"type":"array","items":{"type":"string"},"minItems":1,"default":["USDC","WETH"],"description":"Symbols this wallet may END UP HOLDING. The buy leg of a conversion is checked against it; the sell leg deliberately is not."},"counterparty_screening_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":"100"},"human_approval_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null}},"default":{"daily_usd":"1000","per_tx_usd":"250","velocity_per_hour":10,"token_allowlist":["USDC","WETH"],"counterparty_screening_above_usd":"100","human_approval_above_usd":null}},"alerts":{"type":"object","properties":{"webhook":{"type":["string","null"],"format":"uri","default":null},"events":{"type":"array","items":{"type":"string"},"default":["*"],"description":"Event types delivered to `webhook`; '*' is every type."}},"default":{"webhook":null,"events":["*"]}},"prediction_markets":{"type":"object","properties":{"per_market_cap_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"daily_loss_stop_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"max_resolution_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"market_allowlist":{"type":"array","items":{"type":"string"},"minItems":1},"exposure_basis":{"type":"string","enum":["gross","net"]}},"required":["per_market_cap_usd","daily_loss_stop_usd","max_resolution_exposure_usd"]},"rebalance":{"type":"object","properties":{"max_amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"corridors":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["max_amount_usd","corridors"]}},"required":["version","wallet","chain_id"]},"defaulted":{"type":"array","items":{"type":"string"}}},"required":["wallet","version","hash","created_at","document","defaulted"]}}}},"201":{"description":"New immutable version created","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"version":{"type":"integer"},"hash":{"type":"string"},"created_at":{"type":"string"},"unchanged":{"type":"boolean"},"document":{"type":"object","properties":{"version":{"type":"number","enum":[1]},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"},"float":{"type":"object","properties":{"token":{"type":"string","default":"USDC"},"min":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0","description":"Sweep volatile balances into `token` when float falls below this. 0 disables autonomous sweeping."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"sweep_above_pct":{"type":"integer","minimum":1,"maximum":100,"default":25}},"default":{"token":"USDC","min":"0","target":"0","sweep_above_pct":25}},"execution":{"type":"object","properties":{"max_slippage_bps":{"type":"integer","minimum":1,"maximum":10000,"default":50},"max_slice_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"deadline_minutes":{"type":"integer","minimum":1,"default":30},"venues":{"type":"array","items":{"type":"string"},"minItems":1,"default":["cow","paraswap"],"description":"Execution venues, in preference order. Membership is the allowlist — a venue absent here is refused — and the FIRST entry is the one routing prefers. ['paraswap','cow'] therefore means something different from ['cow','paraswap']."}},"default":{"max_slippage_bps":50,"max_slice_usd":"250","deadline_minutes":30,"venues":["cow","paraswap"]}},"gas":{"type":"object","properties":{"floor":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.001","description":"Top up when the native balance drops below this. 0 disables top-ups."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.005","description":"Native balance a top-up restores, and the ceiling on native value any delegated call may carry."},"strategy":{"type":"string","enum":["topup"],"default":"topup"}},"default":{"floor":"0.001","target":"0.005","strategy":"topup"}},"stables":{"type":"object","properties":{"canonical":{"type":"string","default":"USDC"},"tolerance_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null,"description":"Non-canonical stable balance above which the wallet converts to the canonical stable without being asked. null disables unprompted FX entirely."}},"default":{"canonical":"USDC","tolerance_usd":null}},"spend":{"type":"object","properties":{"daily_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"1000"},"per_tx_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"velocity_per_hour":{"type":"integer","minimum":1,"default":10},"token_allowlist":{"type":"array","items":{"type":"string"},"minItems":1,"default":["USDC","WETH"],"description":"Symbols this wallet may END UP HOLDING. The buy leg of a conversion is checked against it; the sell leg deliberately is not."},"counterparty_screening_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":"100"},"human_approval_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null}},"default":{"daily_usd":"1000","per_tx_usd":"250","velocity_per_hour":10,"token_allowlist":["USDC","WETH"],"counterparty_screening_above_usd":"100","human_approval_above_usd":null}},"alerts":{"type":"object","properties":{"webhook":{"type":["string","null"],"format":"uri","default":null},"events":{"type":"array","items":{"type":"string"},"default":["*"],"description":"Event types delivered to `webhook`; '*' is every type."}},"default":{"webhook":null,"events":["*"]}},"prediction_markets":{"type":"object","properties":{"per_market_cap_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"daily_loss_stop_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"max_resolution_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"market_allowlist":{"type":"array","items":{"type":"string"},"minItems":1},"exposure_basis":{"type":"string","enum":["gross","net"]}},"required":["per_market_cap_usd","daily_loss_stop_usd","max_resolution_exposure_usd"]},"rebalance":{"type":"object","properties":{"max_amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"corridors":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["max_amount_usd","corridors"]}},"required":["version","wallet","chain_id"]},"defaulted":{"type":"array","items":{"type":"string"}}},"required":["wallet","version","hash","created_at","document","defaulted"]}}}},"400":{"description":"Document failed validation","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["policies"],"summary":"List policy versions (newest first)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":false,"name":"wallet","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"All versions, optionally filtered by wallet","content":{"application/json":{"schema":{"type":"object","properties":{"policies":{"type":"array","items":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"version":{"type":"integer"},"hash":{"type":"string"},"created_at":{"type":"string"},"unchanged":{"type":"boolean"},"document":{"type":"object","properties":{"version":{"type":"number","enum":[1]},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"chain_id":{"type":"integer"},"float":{"type":"object","properties":{"token":{"type":"string","default":"USDC"},"min":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0","description":"Sweep volatile balances into `token` when float falls below this. 0 disables autonomous sweeping."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"sweep_above_pct":{"type":"integer","minimum":1,"maximum":100,"default":25}},"default":{"token":"USDC","min":"0","target":"0","sweep_above_pct":25}},"execution":{"type":"object","properties":{"max_slippage_bps":{"type":"integer","minimum":1,"maximum":10000,"default":50},"max_slice_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"deadline_minutes":{"type":"integer","minimum":1,"default":30},"venues":{"type":"array","items":{"type":"string"},"minItems":1,"default":["cow","paraswap"],"description":"Execution venues, in preference order. Membership is the allowlist — a venue absent here is refused — and the FIRST entry is the one routing prefers. ['paraswap','cow'] therefore means something different from ['cow','paraswap']."}},"default":{"max_slippage_bps":50,"max_slice_usd":"250","deadline_minutes":30,"venues":["cow","paraswap"]}},"gas":{"type":"object","properties":{"floor":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.001","description":"Top up when the native balance drops below this. 0 disables top-ups."},"target":{"type":"string","pattern":"^\\d+(\\.\\d{1,18})?$","default":"0.005","description":"Native balance a top-up restores, and the ceiling on native value any delegated call may carry."},"strategy":{"type":"string","enum":["topup"],"default":"topup"}},"default":{"floor":"0.001","target":"0.005","strategy":"topup"}},"stables":{"type":"object","properties":{"canonical":{"type":"string","default":"USDC"},"tolerance_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null,"description":"Non-canonical stable balance above which the wallet converts to the canonical stable without being asked. null disables unprompted FX entirely."}},"default":{"canonical":"USDC","tolerance_usd":null}},"spend":{"type":"object","properties":{"daily_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"1000"},"per_tx_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"250"},"velocity_per_hour":{"type":"integer","minimum":1,"default":10},"token_allowlist":{"type":"array","items":{"type":"string"},"minItems":1,"default":["USDC","WETH"],"description":"Symbols this wallet may END UP HOLDING. The buy leg of a conversion is checked against it; the sell leg deliberately is not."},"counterparty_screening_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":"100"},"human_approval_above_usd":{"type":["string","null"],"pattern":"^\\d+(\\.\\d{1,6})?$","default":null}},"default":{"daily_usd":"1000","per_tx_usd":"250","velocity_per_hour":10,"token_allowlist":["USDC","WETH"],"counterparty_screening_above_usd":"100","human_approval_above_usd":null}},"alerts":{"type":"object","properties":{"webhook":{"type":["string","null"],"format":"uri","default":null},"events":{"type":"array","items":{"type":"string"},"default":["*"],"description":"Event types delivered to `webhook`; '*' is every type."}},"default":{"webhook":null,"events":["*"]}},"prediction_markets":{"type":"object","properties":{"per_market_cap_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"daily_loss_stop_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"max_resolution_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"market_allowlist":{"type":"array","items":{"type":"string"},"minItems":1},"exposure_basis":{"type":"string","enum":["gross","net"]}},"required":["per_market_cap_usd","daily_loss_stop_usd","max_resolution_exposure_usd"]},"rebalance":{"type":"object","properties":{"max_amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"corridors":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["max_amount_usd","corridors"]}},"required":["version","wallet","chain_id"]}},"required":["wallet","version","hash","created_at","document"]}}},"required":["policies"]}}}}}}},"/v1/checks":{"post":{"tags":["checks"],"summary":"Pre-flight: would this spend be allowed by the wallet's policy?","description":"The decision is made from the wallet's in-memory Durable Object state, after one database read to resolve the active policy version. allow/deny with the violated rule and remaining budget. Counterparty screening (#35) is folded in when configured.","security":[{"Bearer":[]}],"requestBody":{"description":"The prospective spend","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"token":{"type":"string"},"counterparty":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},"required":["wallet","amount_usd","token"]}}}},"responses":{"200":{"description":"allow/deny with rule + remaining budget","content":{"application/json":{"schema":{"type":"object","properties":{"allowed":{"type":"boolean"},"rule":{"type":["string","null"]},"reason":{"type":["string","null"]},"remaining_daily_usd":{"type":"string"},"policy_version":{"type":"integer"}},"required":["allowed","rule","reason","remaining_daily_usd","policy_version"]}}}},"403":{"description":"COUNTERPARTY_BLOCKED — sanctioned counterparty","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy for the wallet","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/checks/pm-order":{"post":{"tags":["checks"],"summary":"Pre-flight: would this prediction-market order be allowed?","description":"Evaluates the wallet's prediction_markets policy rules (per-market cap, daily loss stop, resolution exposure, market allowlist) against the prospective order, under the policy's exposure_basis (gross by default; net offsets YES/NO held in the same market). The response reports the basis used and both bases' floored figures. Geo-gated: venue-restricted jurisdictions receive 451 (JURISDICTION_BLOCKED); unknown origins fail closed.","security":[{"Bearer":[]}],"requestBody":{"description":"The prospective order + live exposures","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"condition_id":{"type":"string","minLength":1},"cost_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"state":{"type":"object","properties":{"market_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"realized_loss_today_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"total_open_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"}},"default":{"market_exposure_usd":"0","realized_loss_today_usd":"0","total_open_exposure_usd":"0"}}},"required":["wallet","condition_id","cost_usd"]}}}},"responses":{"200":{"description":"allow/deny with the violated rule","content":{"application/json":{"schema":{"type":"object","properties":{"allowed":{"type":"boolean"},"rule":{"type":["string","null"]},"reason":{"type":["string","null"]},"remaining_market_cap_usd":{"type":["string","null"]},"policy_version":{"type":"integer"},"exposure_basis":{"type":"string","enum":["gross","net"]},"exposure":{"type":"object","properties":{"gross":{"type":"object","properties":{"market_exposure_usd":{"type":"string"},"total_open_exposure_usd":{"type":"string"}},"required":["market_exposure_usd","total_open_exposure_usd"]},"net":{"type":["object","null"],"properties":{"market_exposure_usd":{"type":"string"},"total_open_exposure_usd":{"type":"string"}},"required":["market_exposure_usd","total_open_exposure_usd"]}},"required":["gross","net"]}},"required":["allowed","rule","reason","remaining_market_cap_usd","policy_version","exposure_basis","exposure"]}}}},"404":{"description":"No policy for the wallet","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED — venue-restricted jurisdiction","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"UNAVAILABLE — the server-side exposure floor could not be established (#251), so an exposure-adding order cannot be honestly pre-flighted. Same behavior as the order route itself.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/events":{"get":{"tags":["events"],"summary":"Poll typed events with a monotonic cursor","description":"Events are append-only; the id is the cursor. Pass ?cursor=<last seen id> to receive strictly newer events in order. The polling alternative to webhooks.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":false,"name":"wallet","in":"query"},{"schema":{"type":"string","enum":["policy.updated","intent.created","intent.executing","intent.filled","intent.cancelled","intent.aborted","policy.violated","budget.threshold","balance.low","gas.low","delegation.created","delegation.confirmed","delegation.expiring","delegation.renewed","delegation.revoked","reconciliation.completed","reconciliation.discrepancy","security.alert","ops.alert","ingest.silent","ingest.recovered","pm.credential_stored","pm.credential_revoked","pm.order_placed","balance.topup_auto","balance.topup_failed","balance.auto_topup_exhausted","balance.topup_recovered","balance.debited","auto_topup.expiring","account.control_changed","pm.exposure_high","pm.trade_ready","pm.trade_ready_stopped","venue.degraded","platform.vendor_changed","platform.prepaid_caps_changed"]},"required":false,"name":"type","in":"query"}],"responses":{"200":{"description":"Ordered events after the cursor","content":{"application/json":{"schema":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer"},"type":{"type":"string","enum":["policy.updated","intent.created","intent.executing","intent.filled","intent.cancelled","intent.aborted","policy.violated","budget.threshold","balance.low","gas.low","delegation.created","delegation.confirmed","delegation.expiring","delegation.renewed","delegation.revoked","reconciliation.completed","reconciliation.discrepancy","security.alert","ops.alert","ingest.silent","ingest.recovered","pm.credential_stored","pm.credential_revoked","pm.order_placed","balance.topup_auto","balance.topup_failed","balance.auto_topup_exhausted","balance.topup_recovered","balance.debited","auto_topup.expiring","account.control_changed","pm.exposure_high","pm.trade_ready","pm.trade_ready_stopped","venue.degraded","platform.vendor_changed","platform.prepaid_caps_changed"]},"wallet":{"type":["string","null"],"pattern":"^0x[0-9a-fA-F]{40}$"},"payload":{"type":"object","additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["id","type","wallet","payload","created_at"]}},"next_cursor":{"type":["integer","null"]}},"required":["events","next_cursor"]}}}}}}},"/v1/statements":{"get":{"tags":["statements"],"summary":"Deterministic period statement derived from the append-only ledger","description":"Same wallet+period always yields byte-identical content (and hash) for a fixed ledger range. format=csv returns the balance table as CSV. Exports are immutable content-addressed R2 objects.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":true,"name":"wallet","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"required":true,"name":"period","in":"query"},{"schema":{"type":"string","enum":["json","csv"],"default":"json"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"The statement","content":{"application/json":{"schema":{"type":"object","properties":{"statement":{"type":"object","properties":{"statement_version":{"type":"integer"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"period":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"entry_count":{"type":"integer"},"balances":{"type":"array","items":{"type":"object","properties":{"account":{"type":"string"},"token":{"type":"string"},"chain_id":{"type":"number"},"net":{"type":"string"}},"required":["account","token","chain_id","net"]}},"fees":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string"},"chain_id":{"type":"number"},"total":{"type":"string"}},"required":["token","chain_id","total"]}},"conversions":{"type":"integer"}},"required":["statement_version","wallet","period","entry_count","balances","fees","conversions"]},"content_hash":{"type":"string"},"export":{"type":"object","properties":{"bucket_key":{"type":"string"},"created":{"type":"boolean"},"exported":{"type":"boolean"}},"required":["bucket_key","created","exported"]}},"required":["statement","content_hash","export"]}},"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Invalid period","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"}},"required":["code"]}}}}}}},"/v1/webhooks/secret":{"get":{"tags":["webhooks"],"summary":"Fetch (creating if needed) the HMAC secret used to sign deliveries to you","security":[{"Bearer":[]}],"responses":{"200":{"description":"Verify x-cofferline-signature (t=<unix>,v1=<hmac>) as HMAC-SHA256 over `${t}.${event_id}.${raw_body}`; reject a timestamp older than ~5 minutes","content":{"application/json":{"schema":{"type":"object","properties":{"secret":{"type":"string"}},"required":["secret"]}}}}}}},"/v1/webhooks/failures":{"get":{"tags":["webhooks"],"summary":"Dead-lettered deliveries for this account (at-least-once exhausted retries)","description":"Most recent first. Pass ?cursor=<last seen id> to page older failures — a busy incident can dead-letter more than one page (#153), and a truncated tail must be walkable.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":["integer","null"],"minimum":0},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Most recent first","content":{"application/json":{"schema":{"type":"object","properties":{"failures":{"type":"array","items":{"type":"object","properties":{"id":{"type":"number"},"url":{"type":"string"},"event_id":{"type":"number"},"event_type":{"type":"string"},"failed_at":{"type":"string"}},"required":["id","url","event_id","event_type","failed_at"]}},"next_cursor":{"type":["integer","null"]}},"required":["failures","next_cursor"]}}}}}}},"/v1/intents":{"post":{"tags":["intents"],"summary":"Create a conversion intent (enforced against the wallet's active policy)","security":[{"Bearer":[]}],"requestBody":{"description":"The intent","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"kind":{"type":"string","enum":["conversion","gas_topup"]},"sell_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"buy_token":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"sell_amount":{"type":"string","pattern":"^[1-9]\\d*$"},"max_slippage_bps":{"type":"integer","minimum":1},"venues":{"type":"array","items":{"type":"string"},"minItems":1}},"required":["wallet","kind","sell_token","buy_token","sell_amount"]}}}},"responses":{"201":{"description":"Planned intent","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"kind":{"type":"string","enum":["conversion","gas_topup"]},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"policy_version":{"type":"integer"},"policy_hash":{"type":"string"},"params":{"type":"object","additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"report":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":{}}]}},"required":["id","wallet","kind","status","policy_version","policy_hash","params","created_at","updated_at","report"]}}}},"400":{"description":"INVALID_REQUEST — a token is not supported on this chain","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"402":{"description":"Payment required — prepaid balance below the intent fee (when metering is enforced)","content":{"application/json":{"schema":{"type":"object","properties":{"x402Version":{"type":"number"},"error":{"type":"string"},"accepts":{"type":"array","items":{}},"topup":{"type":"string"}},"required":["x402Version","error","accepts","topup"]}}}},"403":{"description":"EXECUTION_DISABLED — wallet-specific platform switch","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy exists for the wallet","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"POLICY_VIOLATION — request exceeds the active policy","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"UNAVAILABLE — the executor queue refused the dispatch; the intent was aborted, not admitted","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["intents"],"summary":"List intents, newest first","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":false,"name":"wallet","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Intents (paged: limit ≤ 200, default 50)","content":{"application/json":{"schema":{"type":"object","properties":{"intents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"kind":{"type":"string","enum":["conversion","gas_topup"]},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"policy_version":{"type":"integer"},"policy_hash":{"type":"string"},"params":{"type":"object","additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"report":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":{}}]}},"required":["id","wallet","kind","status","policy_version","policy_hash","params","created_at","updated_at","report"]}}},"required":["intents"]}}}}}}},"/v1/intents/{id}":{"get":{"tags":["intents"],"summary":"Fetch an intent","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The intent","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"kind":{"type":"string","enum":["conversion","gas_topup"]},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"policy_version":{"type":"integer"},"policy_hash":{"type":"string"},"params":{"type":"object","additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"report":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":{}}]}},"required":["id","wallet","kind","status","policy_version","policy_hash","params","created_at","updated_at","report"]}}}},"404":{"description":"Unknown intent","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/intents/{id}/cancel":{"post":{"tags":["intents"],"summary":"Cancel a planned intent","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Cancelled","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"kind":{"type":"string","enum":["conversion","gas_topup"]},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"policy_version":{"type":"integer"},"policy_hash":{"type":"string"},"params":{"type":"object","additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"report":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":{}}]}},"required":["id","wallet","kind","status","policy_version","policy_hash","params","created_at","updated_at","report"]}}}},"403":{"description":"The intent's wallet is outside the key's wallet scope (#289)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"Unknown intent or not cancellable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/delegations/prepare":{"post":{"tags":["delegations"],"summary":"Prepare a scoped session-key grant; returns the ONE digest the owner signs","description":"Builds the exact Kernel v3.1 permission {call allowlist, expiry, optional rate limit} naming the Cofferline executor as session signer. The scope must fit inside the account's active policy (SPEC §10: delegation ≤ policy). The returned digest is the only thing the account owner ever signs — the permission installs on-chain atomically with the first delegated execution.","security":[{"Bearer":[]}],"requestBody":{"description":"Grant scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DelegationPrepareRequest"}}}},"responses":{"201":{"description":"Prepared grant with owner-signable digest","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Delegation"}}}},"403":{"description":"EXECUTION_DISABLED — wallet-specific platform switch","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy exists for the account","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"Invalid scope or POLICY_VIOLATION","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Executor signer not configured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/delegations/{id}/confirm":{"post":{"tags":["delegations"],"summary":"Activate a grant by proving the owner signed the enable digest","description":"Verifies the signature against the account's on-chain ECDSA owner and the live Kernel nonce, then activates the delegation for the executor. The permission itself reaches the chain with the first delegated userOp.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Owner's 65-byte signature over the digest (raw or personal_sign)","content":{"application/json":{"schema":{"type":"object","properties":{"enable_sig":{"type":"string","pattern":"^0x[0-9a-fA-F]{130}$"},"owner":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},"required":["enable_sig"]}}}},"responses":{"200":{"description":"Delegation active","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Delegation"}}}},"400":{"description":"Signature does not recover to the account owner","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"Unknown delegation or missing policy","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"Counterfactual account mismatch, stale nonce, or wrong status","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"POLICY_VIOLATION — the active policy no longer covers this grant","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/delegations/{id}":{"delete":{"tags":["delegations"],"summary":"Revoke a delegation; returns owner-calldata for on-chain finality","description":"The executor stops honoring the grant immediately. On-chain removal is the owner's own transaction (returned here as calldata) — revocation never requires Cofferline.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DelegationRevocation"}}}},"403":{"description":"The delegation's wallet is outside the key's wallet scope (#289)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"Unknown delegation","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["delegations"],"summary":"Fetch one delegation","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The delegation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Delegation"}}}},"404":{"description":"Unknown delegation","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/delegations/{id}/renew":{"post":{"tags":["delegations"],"summary":"Renew an active grant: identical scope, fresh expiry, ONE new owner signature","description":"Prepares a NEW grant with the same call allowlist and rate limit but a fresh valid_until (default: the original's duration, capped at 90 days). The old grant stays active until its natural expiry — no authority gap. The returned digest is signed and confirmed exactly like prepare. The scope is re-checked against the CURRENT policy (#18).","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"description":"Optional new expiry (unix seconds); defaults to now + the original duration","required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"valid_until":{"type":"integer","exclusiveMinimum":0}}}}}},"responses":{"201":{"description":"Renewal prepared with a fresh owner-signable digest","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Delegation"}}}},"403":{"description":"EXECUTION_DISABLED — wallet-specific platform switch","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"Unknown delegation or missing policy","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"Only active delegations renew","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"POLICY_VIOLATION — the current policy no longer covers this scope","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Executor signer not configured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/delegations":{"get":{"tags":["delegations"],"summary":"List delegations (newest first)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":false,"name":"account","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Your delegations","content":{"application/json":{"schema":{"type":"object","properties":{"delegations":{"type":"array","items":{"$ref":"#/components/schemas/Delegation"}}},"required":["delegations"]}}}}}}},"/v1/panic":{"post":{"tags":["security"],"summary":"One-call containment: suspend, revoke every credential, return all unwind calldata","description":"Suspends the account (reads, cancels, and revocations stay available), revokes every API key AND every session, flips all delegations to revoked with their owner-submittable uninstall/invalidate calldata, zeroes every venue credential, removes the auto-topup rule, and returns CancelAuthorization instructions for outstanding arrows. Requires a session or admin-scoped key — a leaked read/write key cannot call this. The calling credential dies with the rest: read this response, then sign in again (SIWE) for anything further. Re-enable via the operator.","security":[{"Bearer":[]}],"deprecated":false,"requestBody":{"description":"Why (audited)","content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":300,"default":"panic"}}}}}},"responses":{"200":{"description":"Contained; finish on-chain with the returned calldata","content":{"application/json":{"schema":{"type":"object","properties":{"suspended":{"type":"boolean","enum":[true]},"api_keys_revoked":{"type":"integer"},"sessions_revoked":{"type":"integer"},"credentials_revoked":{"type":"integer"},"delegations_revoked":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"account":{"type":"string"},"uninstall_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]},"invalidate_nonce_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]}},"required":["id","account","uninstall_call","invalidate_nonce_call"]}},"auto_topup_removed":{"type":"integer"},"cancellation":{}},"required":["suspended","api_keys_revoked","sessions_revoked","credentials_revoked","delegations_revoked","auto_topup_removed"]}}}}}}},"/v1/panic/panic":{"post":{"tags":["security"],"summary":"Deprecated alias of POST /v1/panic (#238) — identical behaviour","description":"Suspends the account (reads, cancels, and revocations stay available), revokes every API key AND every session, flips all delegations to revoked with their owner-submittable uninstall/invalidate calldata, zeroes every venue credential, removes the auto-topup rule, and returns CancelAuthorization instructions for outstanding arrows. Requires a session or admin-scoped key — a leaked read/write key cannot call this. The calling credential dies with the rest: read this response, then sign in again (SIWE) for anything further. Re-enable via the operator.","security":[{"Bearer":[]}],"deprecated":true,"requestBody":{"description":"Why (audited)","content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":300,"default":"panic"}}}}}},"responses":{"200":{"description":"Contained; finish on-chain with the returned calldata","content":{"application/json":{"schema":{"type":"object","properties":{"suspended":{"type":"boolean","enum":[true]},"api_keys_revoked":{"type":"integer"},"sessions_revoked":{"type":"integer"},"credentials_revoked":{"type":"integer"},"delegations_revoked":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"account":{"type":"string"},"uninstall_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]},"invalidate_nonce_call":{"type":"object","properties":{"to":{"type":"string"},"data":{"type":"string"}},"required":["to","data"]}},"required":["id","account","uninstall_call","invalidate_nonce_call"]}},"auto_topup_removed":{"type":"integer"},"cancellation":{}},"required":["suspended","api_keys_revoked","sessions_revoked","credentials_revoked","delegations_revoked","auto_topup_removed"]}}}}}}},"/v1/balance/auto-topup":{"put":{"tags":["payments"],"summary":"Configure auto-topup: a threshold plus pre-signed authorizations","description":"Each authorization is a fixed-value EIP-3009 transferWithAuthorization to the treasury with a unique nonce — signed by the payer wallet, settleable exactly once, cancellable on-chain by the payer at any time. When a fee debit drops the balance below the threshold, the platform settles the oldest ready authorization and credits the balance. PUT replaces the rule (and re-arms a suspended one) and ADDS the given authorizations to the quiver; already-known nonces are skipped.","security":[{"Bearer":[]}],"requestBody":{"description":"Threshold, monthly cap, and the quiver to add","content":{"application/json":{"schema":{"type":"object","properties":{"threshold_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"max_per_month":{"type":"integer","minimum":1,"maximum":1000,"default":10},"authorizations":{"type":"array","items":{"type":"object","properties":{"from":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"to":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"value":{"type":"string","pattern":"^\\d+$"},"valid_after":{"type":"string","pattern":"^\\d+$"},"valid_before":{"type":"string","pattern":"^\\d+$"},"nonce":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"signature":{"type":"string","pattern":"^0x[0-9a-fA-F]+$"}},"required":["from","to","value","valid_after","valid_before","nonce","signature"]},"minItems":1,"maxItems":20}},"required":["threshold_usd","authorizations"]}}}},"responses":{"200":{"description":"Rule stored; quiver extended","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AutoTopupState"},{"type":"object","properties":{"authorizations_added":{"type":"integer"},"authorizations_skipped":{"type":"integer"}},"required":["authorizations_added","authorizations_skipped"]}]}}}},"400":{"description":"An authorization failed verification","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"Beneficiary unbound (#284): arrows are self-funded or signed over a 402 challenge nonce","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"Quiver cap exceeded (#351): more than 20 live arrows would be stored","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Treasury signer unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["payments"],"summary":"Auto-topup rule and quiver state","security":[{"Bearer":[]}],"responses":{"200":{"description":"Current rule","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutoTopupState"}}}},"404":{"description":"No auto-topup rule configured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"delete":{"tags":["payments"],"summary":"Remove the auto-topup rule and its unsettled authorizations","description":"Deletes the rule and every stored authorization. Settled credits stay on the ledger. Deleting here does not revoke the signatures cryptographically — the response's `cancellation` block carries everything the payer needs to void each outstanding nonce on-chain (sign CancelAuthorization over the given domain; anyone may submit).","security":[{"Bearer":[]}],"responses":{"200":{"description":"Removed; cancellation instructions for outstanding nonces","content":{"application/json":{"schema":{"type":"object","properties":{"removed_authorizations":{"type":"integer"},"note":{"type":"string"},"cancellation":{"type":"object","properties":{"asset":{"type":"string"},"chain_id":{"type":"integer"},"domain":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"}},"required":["name","version"]},"primary_type":{"type":"string","enum":["CancelAuthorization"]},"types":{"type":"object","properties":{"CancelAuthorization":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"}},"required":["name","type"]}}},"required":["CancelAuthorization"]},"by_payer":{"type":"array","items":{"type":"object","properties":{"authorizer":{"type":"string"},"nonces":{"type":"array","items":{"type":"string"}}},"required":["authorizer","nonces"]}}},"required":["asset","chain_id","domain","primary_type","types","by_payer"]}},"required":["removed_authorizations","note","cancellation"]}}}},"404":{"description":"No auto-topup rule configured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/balance":{"get":{"tags":["payments"],"summary":"Prepaid balance (Σ settled credits − Σ fee debits)","security":[{"Bearer":[]}],"responses":{"200":{"description":"Current balance","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrepaidBalance"}}}}}}},"/v1/balance/topup":{"post":{"tags":["payments"],"summary":"Top up the prepaid balance via x402 (USDC, EIP-3009)","description":"Without an X-PAYMENT header this answers 402 with exact-scheme payment requirements for the requested amount. Retry with the signed transferWithAuthorization: it settles on-chain first (real USDC to the treasury), then credits — the authorization nonce guarantees a retry can never double-credit. A durable pending-settlement record exists before anything is broadcast, so an interrupted request converges on exactly one credit (202 = outcome pending, reconciled from chain truth).","security":[{"Bearer":[]}],"requestBody":{"description":"Top-up amount (USD == USDC)","content":{"application/json":{"schema":{"type":"object","properties":{"amount_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"}},"required":["amount_usd"]}}}},"responses":{"200":{"description":"Settled and credited","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PrepaidBalance"},{"type":"object","properties":{"credited_usd":{"type":"string"},"tx_hash":{"type":"string"}},"required":["credited_usd","tx_hash"]}]}}}},"202":{"description":"Settlement outcome unknown — being reconciled from chain truth; do not re-sign","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PendingSettlement"}}}},"400":{"description":"Invalid or insufficient payment authorization","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"402":{"description":"Payment required — standard x402 requirements","content":{"application/json":{"schema":{"type":"object","properties":{"x402Version":{"type":"number"},"error":{"type":"string"},"accepts":{"type":"array","items":{}}},"required":["x402Version","error","accepts"]}}}},"403":{"description":"Beneficiary unbound (#284): a third-party payer must sign the 402's extra.thirdPartyNonce","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"Prepaid cap exceeded (#349): the top-up would push this account's balance past the per-tenant cap, or the platform's aggregate float past the global cap","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"429":{"description":"Too many concurrent unsettled top-ups for this account (#336): let the in-flight ones settle","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Treasury signer unconfigured, or the payer's balance was unreadable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/rebalances":{"post":{"tags":["rebalances"],"summary":"Move native USDC between the treasury's chains via CCTP (treasury-only)","description":"Burns USDC on the source chain and mints it on the destination via Circle CCTP v2. Treasury-only: the caller must be the executor address, and the amount must fit the policy's `rebalance` section. The mint completes minutes later once Circle attests the burn.","security":[{"Bearer":[]}],"requestBody":{"description":"The rebalance","content":{"application/json":{"schema":{"type":"object","properties":{"from_chain_id":{"type":"integer"},"to_chain_id":{"type":"integer"},"amount":{"type":"string","pattern":"^[1-9]\\d*$"}},"required":["from_chain_id","to_chain_id","amount"]}}}},"responses":{"201":{"description":"Planned rebalance","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"from_chain_id":{"type":"integer"},"to_chain_id":{"type":"integer"},"amount":{"type":"string"},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"phase":{"type":["string","null"]},"burn_tx":{"type":["string","null"]},"mint_tx":{"type":["string","null"]},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["id","from_chain_id","to_chain_id","amount","status","phase","burn_tx","mint_tx","created_at","updated_at"]}}}},"403":{"description":"FORBIDDEN — not the treasury executor","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy exists for the executor","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"POLICY_VIOLATION — corridor or amount outside the rebalance policy","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Executor signer not configured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/rebalances/{id}/complete":{"post":{"tags":["rebalances"],"summary":"Attempt the destination mint now (else the hourly cron does it)","description":"Polls Circle's attestation and, if ready, submits the destination mint immediately — the manual/faster path to the same completion the hourly cron performs. Executor-only. 202 means the attestation isn't ready yet; retry shortly.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Minted","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"from_chain_id":{"type":"integer"},"to_chain_id":{"type":"integer"},"amount":{"type":"string"},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"phase":{"type":["string","null"]},"burn_tx":{"type":["string","null"]},"mint_tx":{"type":["string","null"]},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["id","from_chain_id","to_chain_id","amount","status","phase","burn_tx","mint_tx","created_at","updated_at"]}}}},"202":{"description":"Attestation not ready yet — try again shortly","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"from_chain_id":{"type":"integer"},"to_chain_id":{"type":"integer"},"amount":{"type":"string"},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"phase":{"type":["string","null"]},"burn_tx":{"type":["string","null"]},"mint_tx":{"type":["string","null"]},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["id","from_chain_id","to_chain_id","amount","status","phase","burn_tx","mint_tx","created_at","updated_at"]}}}},"403":{"description":"FORBIDDEN — not the treasury executor","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"Unknown rebalance","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"Not awaiting attestation","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/rebalances/{id}":{"get":{"tags":["rebalances"],"summary":"Fetch a rebalance","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The rebalance","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"from_chain_id":{"type":"integer"},"to_chain_id":{"type":"integer"},"amount":{"type":"string"},"status":{"type":"string","enum":["planned","executing","filled","cancelled","aborted"]},"phase":{"type":["string","null"]},"burn_tx":{"type":["string","null"]},"mint_tx":{"type":["string","null"]},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["id","from_chain_id","to_chain_id","amount","status","phase","burn_tx","mint_tx","created_at","updated_at"]}}}},"404":{"description":"Unknown rebalance","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/credentials":{"post":{"tags":["prediction-markets"],"summary":"Store a venue trade credential (verified live, sealed at rest)","description":"The credential is authenticated against the venue before anything is stored — an invalid key is refused. Material is sealed at rest (AES-256-GCM, bound to your tenant + venue), write-only — no endpoint returns it — and revocation zeroes the ciphertext. Every use is confined server-side to the known trading operations (order place/cancel, authenticated reads, collateral wrap), audited per use, and volume-watched (a `security.alert` webhook fires on anomalous usage). Know what you are handing over. Polymarket: the signer key you store is a FULL OWNER of your funder wallet (Polymarket binds each funder to exactly one signer; Safe funders are 1-of-1), so the trading-only constraint is Cofferline's application policy, not cryptography — a hypothetical compromise of the sealed store would mean control of that one funder. Use a dedicated signer EOA, keep only working trading balances in the funder, and rotate the signer (GET /v1/pm/credentials/{id}/rotation) quarterly or on personnel change. Geo-gated (451) like every prediction-market surface.","security":[{"Bearer":[]}],"requestBody":{"description":"The credential material","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"venue":{"type":"string","enum":["polymarket"],"default":"polymarket"},"label":{"type":"string","maxLength":100},"signer_private_key":{"type":"string","pattern":"^0x[0-9a-fA-F]{64}$"},"maker":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"signature_type":{"anyOf":[{"type":"number","enum":[0]},{"type":"number","enum":[1]},{"type":"number","enum":[2]}],"default":1}},"required":["signer_private_key","maker"]},{"type":"object","properties":{"venue":{"type":"string","enum":["polymarket"],"default":"polymarket"},"label":{"type":"string","maxLength":100},"api_key":{"type":"string","minLength":1,"maxLength":200},"secret":{"type":"string","minLength":1,"maxLength":400},"passphrase":{"type":"string","minLength":1,"maxLength":400},"maker":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"signer":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"signature_type":{"anyOf":[{"type":"number","enum":[0]},{"type":"number","enum":[1]},{"type":"number","enum":[2]}],"default":1}},"required":["api_key","secret","passphrase","maker","signer"]}]}}}},"responses":{"201":{"description":"Stored (verification passed)","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"venue":{"type":"string","enum":["kalshi","polymarket"]},"label":{"type":["string","null"]},"meta":{"type":["object","null"],"additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]}},"required":["id","venue","label","meta","created_at","revoked_at"]}}}},"400":{"description":"The venue rejected the credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"EXECUTION_DISABLED — hosted Polymarket signer-key intake is disabled (#353); use the client-signed flow","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"get":{"tags":["prediction-markets"],"summary":"List stored venue credentials (metadata only — never material)","security":[{"Bearer":[]}],"responses":{"200":{"description":"All credentials","content":{"application/json":{"schema":{"type":"object","properties":{"credentials":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"venue":{"type":"string","enum":["kalshi","polymarket"]},"label":{"type":["string","null"]},"meta":{"type":["object","null"],"additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]}},"required":["id","venue","label","meta","created_at","revoked_at"]}}},"required":["credentials"]}}}}}}},"/v1/pm/credentials/{id}":{"delete":{"tags":["prediction-markets"],"summary":"Revoke a credential (ciphertext destroyed — nothing left to leak)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"venue":{"type":"string","enum":["kalshi","polymarket"]},"label":{"type":["string","null"]},"meta":{"type":["object","null"],"additionalProperties":{}},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"},{"type":"null"}]}},"required":["id","venue","label","meta","created_at","revoked_at"]}}}},"404":{"description":"No such active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/credentials/{id}/rotation":{"get":{"tags":["prediction-markets"],"summary":"Signer rotation calldata: swap the funder Safe's owner to a new EOA","description":"For Polymarket Safe funders (signature_type 2): returns the Safe `swapOwner` calldata that replaces the credential's stored signer with `new_owner`, with the owner-linked-list `prevOwner` parameter derived from the live on-chain owner set (the 0x…01 sentinel for a 1-of-1 Safe). Non-custodial: Cofferline never submits this transaction — you execute it from the funder Safe with your own wallet/UI, then re-store the credential with the new key and revoke the old one (revocation zeroes the sealed material). Recommended cadence: quarterly, or immediately on personnel change or suspected exposure — recommendation only; nothing is enforced server-side.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":true,"name":"new_owner","in":"query"}],"responses":{"200":{"description":"swapOwner call, ready for the funder Safe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PmCredentialRotation"}}}},"404":{"description":"No such active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"Not rotatable (venue/funder type, or owner-set mismatch)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Polygon RPC unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/orders":{"get":{"tags":["prediction-markets"],"summary":"The credential's resting orders, venue-authoritative (reconnect recovery)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"credential_id","in":"query"},{"schema":{"type":"string"},"required":false,"name":"market","in":"query"}],"responses":{"200":{"description":"Resting orders","content":{"application/json":{"schema":{"type":"object","properties":{"orders":{"type":"array","items":{"type":"object","properties":{"venue":{"type":"string","enum":["kalshi","polymarket"]},"order_id":{"type":"string"},"market":{"type":"string"},"token_id":{"type":"string"},"side":{"type":"string"},"price":{"type":"string"},"size":{"type":"string"},"remaining":{"type":"string"},"placed_at":{"type":"string"}},"required":["venue","order_id","market","side","price","size","remaining","placed_at"]}}},"required":["orders"]}}}},"404":{"description":"No active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"429":{"description":"RATE_LIMITED — the PLATFORM-wide aggregate READ budget for this venue is spent, not your per-wallet one (#194). Retry per Retry-After; it refills continuously. Order placement and cancels use a separate lane and are unaffected.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"post":{"tags":["prediction-markets"],"summary":"Route a prediction-market limit order under policy","description":"Places a LIMIT order on Polymarket with your stored trade-scoped credential. The wallet's prediction_markets policy rules are enforced server-side with the ledger-derived exposure floor (#124) — an order the policy forbids is refused with the violated rule, never transmitted. Metered per order (base + bps) from the prepaid balance. Geo-gated (451); disabled environments answer EXECUTION_DISABLED. An operator can also switch off ONE venue platform-wide (#232): that answers EXECUTION_DISABLED naming the venue and the operator's reason, and affects only placement — cancels, cancel-all, open-order reads and fill sync keep working at a switched-off venue, so a position can always be exited.","security":[{"Bearer":[]}],"requestBody":{"description":"The prospective order","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["polymarket"],"default":"polymarket"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"credential_id":{"type":"string","format":"uuid"},"condition_id":{"type":"string","minLength":1},"token_id":{"type":"string","pattern":"^\\d+$"},"action":{"type":"string","enum":["buy","sell"]},"price_usd":{"type":"string","pattern":"^0\\.\\d{1,6}$"},"size_shares":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"client_order_id":{"type":"string","format":"uuid"},"state":{"type":"object","properties":{"market_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"realized_loss_today_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"total_open_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"}},"default":{"market_exposure_usd":"0","realized_loss_today_usd":"0","total_open_exposure_usd":"0"}}},"required":["wallet","credential_id","condition_id","token_id","action","price_usd","size_shares"]}}}},"responses":{"201":{"description":"Transmitted — venue order id + status","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["kalshi","polymarket"]},"order_id":{"type":"string"},"status":{"type":"string"},"cost_usd":{"type":"string"},"fee_usd":{"type":"string"},"policy_version":{"type":"integer"}},"required":["venue","order_id","status","cost_usd","fee_usd","policy_version"]}}}},"402":{"description":"Prepaid balance cannot cover the order fee","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"POLICY_VIOLATION, or EXECUTION_DISABLED — this environment, this wallet, or this venue is switched off","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy / no active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"CONFLICT — an order with this client_order_id was already attempted (#252). Nothing was transmitted now; GET /v1/pm/orders says whether the original attempt rested.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"The venue refused the order","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"429":{"description":"RATE_LIMITED — the PLATFORM-wide aggregate order cap for this venue is spent, not your per-wallet budget (#194). Nothing was transmitted. Retry per Retry-After; the budget refills continuously. Cancels are never subject to it.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"UNAVAILABLE — credential sealing is unconfigured, the venue is misconfigured, the vendor kill switch could not be read (#232), or the server-side exposure floor could not be established (#251: position projection unreadable, or the market's position identities unresolvable). Nothing was transmitted in any case; cancels are unaffected.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED — the request budget was spent waiting on the venue. No order was transmitted on this attempt (#193).","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}},"delete":{"tags":["prediction-markets"],"summary":"Cancel every resting order for the credential (optionally one market)","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"credential_id","in":"query"},{"schema":{"type":"string"},"required":false,"name":"market","in":"query"}],"responses":{"200":{"description":"Cancelled; ids as the venue reported them","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["kalshi","polymarket"]},"cancelled":{"type":"integer"},"order_ids":{"type":"array","items":{"type":"string"}},"failed_order_ids":{"type":"array","items":{"type":"string"}},"complete":{"type":"boolean"}},"required":["venue","cancelled","order_ids","complete"]}}}},"403":{"description":"EXECUTION_DISABLED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"The venue refused","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED — the budget ran out reading the resting book, before any cancel was transmitted. A run that starts and then runs out returns 200 with complete:false instead (#193).","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/orders/prepare":{"post":{"tags":["prediction-markets"],"summary":"Prepare a client-signed Polymarket order (returns EIP-712 to sign)","description":"The first half of the client-signed flow (#353), for Polymarket credentials you store WITHOUT a signer key. Runs every risk check the hosted route runs — jurisdiction, execution gates, the ledger-derived exposure floor (#124), your policy, the platform ceiling — then reserves the exposure and debits the fee on a durable 'prepared' order and returns the EXACT Polymarket V2 order struct plus its ready-to-sign EIP-712 payload. Sign `typed_data` with your own eth_signTypedData_v4 tooling (the same key that derived your stored CLOB creds) and POST the signature to /v1/pm/orders/submit before `expires_at`. If you never submit, the prepared order is swept and its hold + fee are released. Cofferline never receives your signer key.","security":[{"Bearer":[]}],"requestBody":{"description":"The prospective order","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["polymarket"],"default":"polymarket"},"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"credential_id":{"type":"string","format":"uuid"},"condition_id":{"type":"string","minLength":1},"token_id":{"type":"string","pattern":"^\\d+$"},"action":{"type":"string","enum":["buy","sell"]},"price_usd":{"type":"string","pattern":"^0\\.\\d{1,6}$"},"size_shares":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$"},"client_order_id":{"type":"string","format":"uuid"},"state":{"type":"object","properties":{"market_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"realized_loss_today_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"},"total_open_exposure_usd":{"type":"string","pattern":"^\\d+(\\.\\d{1,6})?$","default":"0"}},"default":{"market_exposure_usd":"0","realized_loss_today_usd":"0","total_open_exposure_usd":"0"}}},"required":["wallet","credential_id","condition_id","token_id","action","price_usd","size_shares"]}}}},"responses":{"201":{"description":"Prepared — sign typed_data and submit","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["polymarket"]},"prepare_id":{"type":"string","format":"uuid"},"client_order_id":{"type":"string"},"typed_data":{"type":"object","properties":{"domain":{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"},"chainId":{"type":"integer"},"verifyingContract":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"}},"required":["name","version","chainId","verifyingContract"]},"types":{"type":"object","additionalProperties":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"}},"required":["name","type"]}}},"primaryType":{"type":"string"},"message":{"type":"object","additionalProperties":{}}},"required":["domain","types","primaryType","message"]},"order":{"type":"object","additionalProperties":{}},"cost_usd":{"type":"string"},"fee_usd":{"type":"string"},"policy_version":{"type":"integer"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","format":"date-time"}]}},"required":["venue","prepare_id","client_order_id","typed_data","order","cost_usd","fee_usd","policy_version","expires_at"]}}}},"400":{"description":"Not a client-signed credential, or venue misconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"402":{"description":"Prepaid balance cannot cover the order fee","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"403":{"description":"POLICY_VIOLATION or EXECUTION_DISABLED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No policy / no active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"CONFLICT — this client_order_id is already claimed","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"UNAVAILABLE — sealing unconfigured, venue/floor unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/orders/submit":{"post":{"tags":["prediction-markets"],"summary":"Submit a signed client-signed Polymarket order","description":"The second half of the client-signed flow (#353). Provide the `prepare_id` from /v1/pm/orders/prepare and your EIP-712 signature over the returned `typed_data`. Cofferline verifies the signature recovers to your declared signer, then relays the order to the CLOB under your trade-only credentials through the SAME coordinator admission the hosted path uses. A prepared order that already expired, or one whose signature does not recover to the declared signer, is refused and nothing is transmitted.","security":[{"Bearer":[]}],"requestBody":{"description":"The prepared order id + signature","content":{"application/json":{"schema":{"type":"object","properties":{"prepare_id":{"type":"string","format":"uuid"},"signature":{"type":"string","pattern":"^0x[0-9a-fA-F]{130}$"}},"required":["prepare_id","signature"]}}}},"responses":{"201":{"description":"Transmitted — venue order id + status","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["kalshi","polymarket"]},"order_id":{"type":"string"},"status":{"type":"string"},"cost_usd":{"type":"string"},"fee_usd":{"type":"string"},"policy_version":{"type":"integer"}},"required":["venue","order_id","status","cost_usd","fee_usd","policy_version"]}}}},"400":{"description":"Signature does not recover to the declared signer","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No prepared order with this id (expired, submitted, or unknown)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"409":{"description":"The prepared order is no longer awaiting a signature","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"The venue refused the order","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"429":{"description":"RATE_LIMITED — platform aggregate cap for the venue","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"UNAVAILABLE — credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED — nothing was transmitted","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/orders/{venue}/{order_id}":{"delete":{"tags":["prediction-markets"],"summary":"Cancel a resting prediction-market order","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","enum":["polymarket"]},"required":true,"name":"venue","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"order_id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"credential_id","in":"query"}],"responses":{"200":{"description":"Cancelled (venue-reported status)","content":{"application/json":{"schema":{"type":"object","properties":{"venue":{"type":"string","enum":["kalshi","polymarket"]},"order_id":{"type":"string"},"status":{"type":"string"}},"required":["venue","order_id","status"]}}}},"403":{"description":"EXECUTION_DISABLED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"The venue refused the cancel","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED — the cancel was not transmitted (#193)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/onboarding/{address}":{"get":{"tags":["prediction-markets"],"summary":"Polymarket trade-readiness: live approval status + missing calldata","description":"Reads the six on-chain V2 grants (pUSD allowance and CTF operator approval for the V2 CTF Exchange, V2 Neg Risk Exchange, and Neg Risk Adapter) plus live pUSD/USDC.e balances for the given funds-holding wallet, and returns owner-signable calldata for any missing grants — and for the USDC.e→pUSD wrap when raw USDC.e is present (the autonomous replacement for the venue UI's confirm-funds step). Non-custodial: submitting them is your own transaction. Geo-gated like every prediction-market surface.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":true,"name":"address","in":"path"}],"responses":{"200":{"description":"Live approval statuses","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PmOnboarding"}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Polygon RPC unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/funder/{owner}":{"get":{"tags":["prediction-markets"],"summary":"Resolve an owner EOA to its Polymarket funder Safe candidates","description":"Looks up every Polygon Safe the owner controls via the Safe Transaction Service, reads each candidate's six V2 trade grants and pUSD/USDC.e collateral, and names the likeliest funder (most grants set, then most pUSD). Use when the venue UI is unavailable or the agent never had one. Geo-gated like every Polymarket surface.","security":[{"Bearer":[]}],"parameters":[{"schema":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"required":true,"name":"owner","in":"path"}],"responses":{"200":{"description":"Funder candidates, best guess first","content":{"application/json":{"schema":{"type":"object","properties":{"owner":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$"},"funder":{"type":["string","null"]},"candidates":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string"},"grants_set":{"type":"integer","minimum":0,"maximum":6},"pusd":{"type":"string"},"usdce_unwrapped":{"type":"string"}},"required":["address","grants_set","pusd","usdce_unwrapped"]}}},"required":["owner","funder","candidates"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Safe Transaction Service or Polygon RPC unavailable","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/fills/sync":{"post":{"tags":["prediction-markets"],"summary":"Journal venue fills into the wallet's ledger (idempotent)","description":"Pages the credential's fills newest-first and journals each unseen fill as a balanced double-entry group under the given wallet, stamped with the wallet's active policy hash. Re-running never double-books — the venue fill/trade id is the settlement identity. Feeds the server-side exposure floor. Polymarket journals CLOB trades (resolution redemptions are on-chain CTF events, outside this reader).","security":[{"Bearer":[]}],"requestBody":{"description":"Which credential's fills, into which wallet's books","content":{"application/json":{"schema":{"type":"object","properties":{"wallet":{"type":"string","pattern":"^0x[0-9a-fA-F]{40}$","description":"The treasury wallet whose books receive the fills"},"credential_id":{"type":"string","format":"uuid"}},"required":["wallet","credential_id"]}}}},"responses":{"200":{"description":"Sync outcome","content":{"application/json":{"schema":{"type":"object","properties":{"journaled":{"type":"integer"},"skipped":{"type":"integer"},"settlements_journaled":{"type":"integer"},"complete":{"type":"boolean"}},"required":["journaled","skipped","settlements_journaled","complete"]}}}},"404":{"description":"No policy / no active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Credential sealing unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}},"/v1/pm/wrap":{"post":{"tags":["prediction-markets"],"summary":"Wrap the funder Safe's USDC.e into pUSD (platform-relayed, no user gas)","description":"For Safe-type Polymarket credentials: signs approve(CollateralOnramp) + wrap() as Safe transactions with the sealed trade signer (the Safe owner) and relays them through the platform executor, which pays gas. The autonomous, API-only equivalent of the venue UI's confirm-funds step. Wraps the full unwrapped USDC.e balance unless amount_base_units narrows it.","security":[{"Bearer":[]}],"requestBody":{"description":"Which credential's funder to wrap, and optionally how much","content":{"application/json":{"schema":{"type":"object","properties":{"credential_id":{"type":"string","format":"uuid"},"amount_base_units":{"type":"string","pattern":"^\\d+$"}},"required":["credential_id"]}}}},"responses":{"200":{"description":"Wrap executed","content":{"application/json":{"schema":{"type":"object","properties":{"wrapped_base_units":{"type":"string"},"txs":{"type":"array","items":{"type":"string"}},"collateral":{"type":"object","properties":{"pusd":{"type":"string"},"usdce_unwrapped":{"type":"string"}},"required":["pusd","usdce_unwrapped"]}},"required":["wrapped_base_units","txs","collateral"]}}}},"403":{"description":"EXECUTION_DISABLED — account-level platform switch","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"404":{"description":"No active credential","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"422":{"description":"Not wrappable (wrong venue/type, nothing to wrap, or revert)","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"451":{"description":"JURISDICTION_BLOCKED","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"503":{"description":"Sealing or relay signer unconfigured","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}},"504":{"description":"DEADLINE_EXCEEDED — the request budget ran out BEFORE a broadcast, never during one (#193). The message names any transaction that did land; an approve without its wrap is safe to retry.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"remediation":{"type":"string"},"docs_url":{"type":"string"},"request_id":{"type":"string"},"next":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["GET","POST","PUT","DELETE"]},"path":{"type":"string"},"why":{"type":"string"}},"required":["method","path","why"]}}},"required":["code","message","remediation","docs_url","request_id"]}}}}}}}},"webhooks":{}}