{
  "openapi": "3.1.0",
  "info": {
    "title": "Torque API v1",
    "version": "7",
    "description": "Versioned Platform API for Torque Intelligence, Assistant, and wallet Actions. Business integrators use Bearer sk_live_…; wallet Actions require smart wallet JWT. Intelligence schema manifest v7.",
    "contact": {
      "name": "Torque",
      "url": "https://torque.fi"
    }
  },
  "servers": [
    {
      "url": "https://app.torque.fi",
      "description": "Production"
    },
    {
      "url": "http://localhost:3000",
      "description": "Local development"
    }
  ],
  "tags": [
    {
      "name": "Health"
    },
    {
      "name": "Capabilities"
    },
    {
      "name": "Business"
    },
    {
      "name": "Wallet"
    },
    {
      "name": "Intelligence"
    },
    {
      "name": "Opportunities"
    },
    {
      "name": "Assistant"
    },
    {
      "name": "Actions"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Liveness probe",
        "responses": {
          "200": {
            "description": "API is up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/capabilities": {
      "get": {
        "tags": [
          "Capabilities"
        ],
        "summary": "Capability manifest",
        "responses": {
          "200": {
            "description": "Capability map for clients and docs generators",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapabilitiesManifest"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/openapi": {
      "get": {
        "tags": [
          "Capabilities"
        ],
        "summary": "OpenAPI 3.1 document for Torque API v1",
        "responses": {
          "200": {
            "description": "This specification",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/business/me": {
      "get": {
        "tags": [
          "Business"
        ],
        "summary": "Business profile for API key",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Business associated with Bearer sk_live_…",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessMeResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Business inactive",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wallet/me": {
      "get": {
        "tags": [
          "Wallet"
        ],
        "summary": "Smart wallet session identity",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "responses": {
          "200": {
            "description": "JWT-linked user and wallet addresses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WalletMeResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/feed": {
      "get": {
        "tags": [
          "Intelligence"
        ],
        "summary": "Primary Intelligence feed",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "walletAddress",
            "in": "query",
            "required": false,
            "description": "optional — personalization",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chainId",
            "in": "query",
            "required": false,
            "description": "optional — action deep links (default 8453)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "lanes",
            "in": "query",
            "required": false,
            "description": "optional — comma-separated: timely,desk,outlook",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kinds",
            "in": "query",
            "required": false,
            "description": "optional — comma-separated: signal,angle,brief,outlook",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "optional — default 12, max 24",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "includeBrief",
            "in": "query",
            "required": false,
            "description": "optional — 1 for hero brief item",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "force",
            "in": "query",
            "required": false,
            "description": "optional — 1 to force live angle reroll (cooldown)",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligenceFeedResponseV1"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "429": {
            "description": "Cooldown — retry after retryAfterMs in error.details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                },
                "examples": {
                  "cooldown": {
                    "value": {
                      "error": {
                        "code": "COOLDOWN",
                        "message": "Cooldown",
                        "details": {
                          "retryAfterMs": 15000
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Intelligence temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/trade-angles": {
      "get": {
        "tags": [
          "Intelligence"
        ],
        "summary": "Trade angles (desk lane view)",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "walletAddress",
            "in": "query",
            "required": false,
            "description": "optional — personalize to user profile / outlook",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "force",
            "in": "query",
            "required": false,
            "description": "optional — 1 to force live reroll (cooldown applies)",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradeAnglesResponseV1"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "429": {
            "description": "Cooldown — retry after retryAfterMs in error.details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                },
                "examples": {
                  "cooldown": {
                    "value": {
                      "error": {
                        "code": "COOLDOWN",
                        "message": "Cooldown",
                        "details": {
                          "retryAfterMs": 15000
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Intelligence temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/happening-now": {
      "get": {
        "tags": [
          "Intelligence"
        ],
        "summary": "Happening now (timely signals view)",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "chainId",
            "in": "query",
            "required": false,
            "description": "optional — completion action deep links (default Base)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HappeningNowResponseV1"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "429": {
            "description": "Cooldown — retry after retryAfterMs in error.details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                },
                "examples": {
                  "cooldown": {
                    "value": {
                      "error": {
                        "code": "COOLDOWN",
                        "message": "Cooldown",
                        "details": {
                          "retryAfterMs": 15000
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Intelligence temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/market-outlook": {
      "get": {
        "tags": [
          "Intelligence"
        ],
        "summary": "Stored market outlook for wallet",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "walletAddress",
            "in": "query",
            "required": true,
            "description": "required — stored outlook row",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MarketOutlookResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "429": {
            "description": "Cooldown — retry after retryAfterMs in error.details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                },
                "examples": {
                  "cooldown": {
                    "value": {
                      "error": {
                        "code": "COOLDOWN",
                        "message": "Cooldown",
                        "details": {
                          "retryAfterMs": 15000
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Intelligence temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/brief": {
      "get": {
        "tags": [
          "Intelligence"
        ],
        "summary": "Single brief item",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BriefViewResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "429": {
            "description": "Cooldown — retry after retryAfterMs in error.details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                },
                "examples": {
                  "cooldown": {
                    "value": {
                      "error": {
                        "code": "COOLDOWN",
                        "message": "Cooldown",
                        "details": {
                          "retryAfterMs": 15000
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Intelligence temporarily unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/opportunities/yield": {
      "get": {
        "tags": [
          "Opportunities"
        ],
        "summary": "Yield Spotlight market rates + personalized idle-cash ideas",
        "description": "Yield Spotlight market APY rows + optional personalized idle-cash ideas (same data as home widget).",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "walletAddress",
            "in": "query",
            "required": false,
            "description": "Optional — personalize with cross-chain idle balances",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "minIdleUsd",
            "in": "query",
            "required": false,
            "description": "Optional — minimum idle USD per asset group (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "maxPersonalized",
            "in": "query",
            "required": false,
            "description": "Optional — max personalized rows (default 4, max 12)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Yield market rows and optional personalized ideas",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/YieldOpportunitiesResponseV1"
                }
              }
            }
          },
          "503": {
            "description": "Enso yield data not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/opportunities/lending": {
      "get": {
        "tags": [
          "Opportunities"
        ],
        "summary": "Lend/Borrow catalog supply APY and borrow APR",
        "description": "Lend/Borrow catalog supply APY and borrow APR rows (same data as Lend & Borrow Markets UI).",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "chainId",
            "in": "query",
            "required": false,
            "description": "Optional — filter to one chain",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "tokenFilter",
            "in": "query",
            "required": false,
            "description": "Optional — asset/bucket filter (USD, ETH, …)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "protocol",
            "in": "query",
            "required": false,
            "description": "Optional — protocol hint (aave, morpho, kamino, …)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Optional — max rows (default 24, max 48)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lending market rows with optional lend/borrow actions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LendingOpportunitiesResponseV1"
                }
              }
            }
          },
          "503": {
            "description": "Lending catalog unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/assistant/chat": {
      "post": {
        "tags": [
          "Assistant"
        ],
        "summary": "Torque Intelligence chat",
        "description": "Conversational Torque Intelligence (Gemini + tools). Tool calls can return confirmable payloads (functionResults) for the client to sign.",
        "security": [
          {
            "businessApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "stream",
            "in": "query",
            "required": false,
            "description": "Set to true for SSE streaming",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssistantChatPostBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON reply or text/event-stream when stream=true",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssistantChatResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE lines: data: {JSON AssistantChatStreamEvent}"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing business API key (programmatic callers)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "402": {
            "description": "Free-tier assistant credits exhausted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssistantCreditsError"
                }
              }
            }
          },
          "500": {
            "description": "Assistant error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/trade/swap": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Build unsigned EVM swap route (Enso)",
        "description": "Enso; fromAddress forced to JWT-linked EVM wallet.",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/trade/swap/solana": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Build Jupiter Ultra Solana swap order",
        "description": "Jupiter Ultra order; taker forced to JWT-linked Solana pubkey.",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/transfer/evm": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "EVM token transfer",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/transfer/solana": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Solana SPL/SOL transfer",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/transfer/btc": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Custodial BTC send from deposit",
        "description": "Custodial send from user deposit (smart-wallet JWT).",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/lend/evm": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "EVM lend/supply via Enso delegate bundle",
        "description": "EVM supply/redeem via Enso delegate bundle (same-network or with a destination network).",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/borrow/evm": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "EVM borrow via Enso bundle",
        "description": "EVM deposit + borrow via Enso bundle.",
        "security": [
          {
            "smartWalletJwt": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned route or transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionRouteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing smart wallet JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — wallet mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          },
          "503": {
            "description": "Routing or configuration error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TorqueV1Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "businessApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_live_…",
        "description": "Merchant identity, programmatic Torque Intelligence (`GET /api/v1/intelligence/**`), and server-side assistant chat."
      },
      "smartWalletJwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "RS256 JWT issued for the email smart-wallet session (same value as in-app smartWalletAuthJWT). Verified with JWT_PUBLIC_KEY / JWT_ISSUER."
      }
    },
    "schemas": {
      "TorqueV1Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "AssistantCreditsError": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "assistant_credits_exhausted"
            ]
          },
          "message": {
            "type": "string"
          },
          "upgrade": {
            "type": "boolean"
          },
          "remaining": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "resetAt": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "IntelligenceItemV1": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "title",
          "summary",
          "symbols"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signal",
              "angle",
              "brief",
              "outlook"
            ]
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "horizon": {
            "type": "string",
            "enum": [
              "24h",
              "swing",
              "structural"
            ]
          },
          "symbols": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bias": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "Long",
              "Short",
              "Watch",
              null
            ]
          },
          "relevanceScore": {
            "type": "number"
          },
          "levels": {
            "type": "object",
            "properties": {
              "last": {
                "type": "number"
              },
              "invalidation": {
                "type": "number"
              },
              "target": {
                "type": "number"
              }
            }
          },
          "source": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "tape",
                  "social",
                  "desk",
                  "insight",
                  "finnhub",
                  "other"
                ]
              },
              "label": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "label",
                "href"
              ],
              "properties": {
                "label": {
                  "type": "string"
                },
                "href": {
                  "type": "string"
                },
                "torqueUrl": {
                  "type": "string",
                  "format": "uri"
                },
                "chainId": {
                  "type": "integer"
                },
                "iconSymbol": {
                  "type": "string"
                },
                "subtitle": {
                  "type": "string"
                },
                "apyPercent": {
                  "type": "number"
                },
                "aprPercent": {
                  "type": "number"
                },
                "opportunityType": {
                  "type": "string",
                  "enum": [
                    "lend",
                    "borrow",
                    "trade",
                    "perp",
                    "other"
                  ]
                },
                "protocol": {
                  "type": "string"
                },
                "idleUsd": {
                  "type": "number"
                },
                "estimatedAnnualUsd": {
                  "type": "number"
                }
              }
            }
          },
          "dedupeKey": {
            "type": "string"
          },
          "ingestedAtMs": {
            "type": "integer"
          },
          "resolution": {
            "type": "object",
            "properties": {
              "tier": {
                "type": "string",
                "enum": [
                  "pool",
                  "live",
                  "emergency"
                ]
              },
              "ageMs": {
                "type": "integer"
              }
            }
          }
        }
      },
      "IntelligenceFeedMetaV1": {
        "type": "object",
        "required": [
          "manifestVersion",
          "generatedAtMs",
          "personalized"
        ],
        "properties": {
          "manifestVersion": {
            "type": "integer"
          },
          "generatedAtMs": {
            "type": "integer"
          },
          "bundleIngestedAtMs": {
            "type": "integer"
          },
          "personalized": {
            "type": "boolean"
          },
          "walletAddress": {
            "type": "string"
          },
          "chainId": {
            "type": "integer"
          },
          "dedupedCount": {
            "type": "integer"
          }
        }
      },
      "IntelligenceFeedResponseV1": {
        "type": "object",
        "required": [
          "meta",
          "items"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/IntelligenceFeedMetaV1"
          },
          "brief": {
            "$ref": "#/components/schemas/IntelligenceItemV1"
          },
          "lanes": {
            "type": "object",
            "additionalProperties": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntelligenceItemV1"
            }
          }
        }
      },
      "TradeAnglesResponseV1": {
        "type": "object",
        "required": [
          "ideas",
          "meta"
        ],
        "properties": {
          "ideas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntelligenceItemV1"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/IntelligenceFeedMetaV1"
          }
        }
      },
      "HappeningNowResponseV1": {
        "type": "object",
        "required": [
          "items",
          "ingestedAtMs"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntelligenceItemV1"
            }
          },
          "ingestedAtMs": {
            "type": [
              "integer",
              "null"
            ]
          },
          "meta": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "BriefViewResponse": {
        "type": "object",
        "properties": {
          "brief": {
            "$ref": "#/components/schemas/IntelligenceItemV1"
          }
        }
      },
      "MarketOutlookResponse": {
        "type": "object",
        "properties": {
          "item": {
            "$ref": "#/components/schemas/IntelligenceItemV1"
          },
          "meta": {
            "$ref": "#/components/schemas/IntelligenceFeedMetaV1"
          }
        }
      },
      "YieldMarketOpportunityV1": {
        "type": "object",
        "required": [
          "symbol",
          "lendSymbol",
          "apyPercent",
          "chainId",
          "protocol",
          "action"
        ],
        "properties": {
          "symbol": {
            "type": "string"
          },
          "lendSymbol": {
            "type": "string"
          },
          "apyPercent": {
            "type": "number"
          },
          "chainId": {
            "type": "integer"
          },
          "protocol": {
            "type": [
              "string",
              "null"
            ]
          },
          "action": {
            "$ref": "#/components/schemas/IntelligenceActionV1"
          }
        }
      },
      "PersonalizedYieldIdeaV1": {
        "type": "object",
        "required": [
          "symbol",
          "lendSymbol",
          "apyPercent",
          "chainId",
          "protocol",
          "idleUsd",
          "estimatedAnnualUsd",
          "action"
        ],
        "properties": {
          "symbol": {
            "type": "string"
          },
          "lendSymbol": {
            "type": "string"
          },
          "apyPercent": {
            "type": "number"
          },
          "chainId": {
            "type": "integer"
          },
          "protocol": {
            "type": [
              "string",
              "null"
            ]
          },
          "idleUsd": {
            "type": "number"
          },
          "estimatedAnnualUsd": {
            "type": "number"
          },
          "action": {
            "$ref": "#/components/schemas/IntelligenceActionV1"
          }
        }
      },
      "YieldOpportunitiesResponseV1": {
        "type": "object",
        "required": [
          "meta",
          "markets"
        ],
        "properties": {
          "meta": {
            "type": "object",
            "required": [
              "generatedAtMs",
              "personalized"
            ],
            "properties": {
              "generatedAtMs": {
                "type": "integer"
              },
              "personalized": {
                "type": "boolean"
              },
              "walletAddress": {
                "type": "string"
              }
            }
          },
          "markets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/YieldMarketOpportunityV1"
            }
          },
          "personalized": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PersonalizedYieldIdeaV1"
            }
          }
        }
      },
      "LendingMarketOpportunityV1": {
        "type": "object",
        "required": [
          "displayName",
          "productBucket",
          "symbol",
          "chainId",
          "chainName",
          "protocol",
          "supplyApyPercent",
          "borrowAprPercent",
          "tvlUsd"
        ],
        "properties": {
          "displayName": {
            "type": "string"
          },
          "productBucket": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "chainId": {
            "type": "integer"
          },
          "chainName": {
            "type": "string"
          },
          "protocol": {
            "type": "string"
          },
          "protocolSlug": {
            "type": "string"
          },
          "supplyApyPercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "borrowAprPercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "tvlUsd": {
            "type": [
              "number",
              "null"
            ]
          },
          "lendAction": {
            "$ref": "#/components/schemas/IntelligenceActionV1"
          },
          "borrowAction": {
            "$ref": "#/components/schemas/IntelligenceActionV1"
          }
        }
      },
      "LendingOpportunitiesResponseV1": {
        "type": "object",
        "required": [
          "meta",
          "markets"
        ],
        "properties": {
          "meta": {
            "type": "object",
            "required": [
              "generatedAtMs",
              "reserveCount"
            ],
            "properties": {
              "generatedAtMs": {
                "type": "integer"
              },
              "reserveCount": {
                "type": "integer"
              },
              "chainId": {
                "type": "integer"
              },
              "tokenFilter": {
                "type": "string"
              },
              "protocol": {
                "type": "string"
              }
            }
          },
          "markets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LendingMarketOpportunityV1"
            }
          }
        }
      },
      "IntelligenceActionV1": {
        "type": "object",
        "required": [
          "label",
          "href"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "href": {
            "type": "string"
          },
          "torqueUrl": {
            "type": "string",
            "format": "uri"
          },
          "chainId": {
            "type": "integer"
          },
          "iconSymbol": {
            "type": "string"
          },
          "subtitle": {
            "type": "string"
          },
          "apyPercent": {
            "type": "number"
          },
          "aprPercent": {
            "type": "number"
          },
          "opportunityType": {
            "type": "string",
            "enum": [
              "lend",
              "borrow",
              "trade",
              "perp",
              "other"
            ]
          },
          "protocol": {
            "type": "string"
          },
          "idleUsd": {
            "type": "number"
          },
          "estimatedAnnualUsd": {
            "type": "number"
          }
        }
      },
      "AssistantChatPostBody": {
        "type": "object",
        "required": [
          "messages"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role"
              ],
              "properties": {
                "role": {
                  "type": "string"
                },
                "content": {}
              },
              "additionalProperties": true
            }
          },
          "context": {
            "type": "object",
            "properties": {
              "walletAddress": {
                "type": "string"
              },
              "solanaWalletAddress": {
                "type": "string"
              },
              "chainId": {
                "type": "integer"
              },
              "localCurrency": {
                "type": "string"
              },
              "authJWT": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "conversationId": {
            "type": "string"
          }
        }
      },
      "AssistantChatResponse": {
        "type": "object",
        "properties": {
          "content": {},
          "functionResults": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "toolName": {
                  "type": "string"
                },
                "result": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "suggestions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "AssistantChatStreamEvent": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "const": "delta"
              },
              "text": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "const": "correction"
              },
              "text": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "const": "done"
              },
              "functionResults": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "toolName": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "const": "error"
              },
              "message": {
                "type": "string"
              }
            }
          }
        ]
      },
      "BusinessMeResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "logo": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          }
        }
      },
      "WalletMeResponse": {
        "type": "object",
        "properties": {
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": "string"
          },
          "evmWalletAddress": {
            "type": [
              "string",
              "null"
            ]
          },
          "solanaWalletAddress": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "ok",
          "api"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "api": {
            "type": "string",
            "enum": [
              "torque-v1"
            ]
          },
          "convexConfigured": {
            "type": "boolean"
          }
        }
      },
      "CapabilitiesManifest": {
        "type": "object",
        "description": "Machine-readable capability map (same payload as GET /api/v1/capabilities).",
        "additionalProperties": true
      },
      "ActionRouteResponse": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "route": {
            "type": "object",
            "additionalProperties": true
          },
          "tx": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "JsonObject": {
        "type": "object",
        "additionalProperties": true
      }
    }
  },
  "x-torque-manifest-version": 7,
  "x-torque-intelligence-schema-version": 7
}
