{
  "openapi": "3.1.0",
  "info": {
    "title": "AlphaBotPro Trading API",
    "version": "1.0.0",
    "description": "REST access to AlphaBotPro trading signals, War Room analysis, MT5 Expert Advisors and AI stock detections. Public discovery endpoints need no key; data feeds require a Bearer API key. Unentitled paid requests return HTTP 402 with crypto payment instructions (x402).",
    "termsOfService": "https://alphabotpro.cloud/terms",
    "contact": { "name": "AlphaBotPro", "url": "https://alphabotpro.cloud/api" }
  },
  "servers": [{ "url": "https://mcp.alphabotpro.cloud" }],
  "security": [{ "bearerAuth": [] }],
  "paths": {
    "/v1/mcp/catalog": {
      "get": {
        "summary": "Public catalog",
        "description": "List public offerings with sample payloads and the tier required. No authentication.",
        "security": [],
        "responses": { "200": { "description": "Catalog list" } }
      }
    },
    "/v1/api/signals": {
      "get": {
        "summary": "Latest trading signals",
        "description": "Latest 50 XAUUSD/BTCUSD signals. Requires the 'signals' entitlement.",
        "x-payment-info": {
          "intent": "session",
          "method": ["crypto"],
          "amount": 49,
          "currency": "USD",
          "endpoint": "https://mcp.alphabotpro.cloud/v1/api/checkout/crypto",
          "verify": "https://mcp.alphabotpro.cloud/v1/api/checkout/verify"
        },
        "responses": {
          "200": { "description": "Signals" },
          "401": { "description": "Missing or invalid key" },
          "402": { "description": "Payment required — no entitlement" }
        }
      }
    },
    "/v1/api/warroom": {
      "get": {
        "summary": "War Room analysis",
        "description": "Latest 20 published market briefings. Requires the 'warroom' entitlement.",
        "x-payment-info": {
          "intent": "session",
          "method": ["crypto"],
          "amount": 49,
          "currency": "USD",
          "endpoint": "https://mcp.alphabotpro.cloud/v1/api/checkout/crypto",
          "verify": "https://mcp.alphabotpro.cloud/v1/api/checkout/verify"
        },
        "responses": { "200": { "description": "Analyses" }, "402": { "description": "Payment required" } }
      }
    },
    "/v1/api/expert-advisors": {
      "get": {
        "summary": "Expert Advisor catalog",
        "description": "Public MT5 EA metadata (name, slug, price, features).",
        "security": [],
        "responses": { "200": { "description": "EA list" } }
      }
    },
    "/v1/api/ea/{slug}/download": {
      "get": {
        "summary": "Request an EA download link",
        "description": "Returns a single-use, 15-minute download link. Requires the 'ea_download' entitlement (Agent tier).",
        "parameters": [{ "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Download URL" }, "402": { "description": "Payment required" }, "404": { "description": "Unknown EA" } }
      }
    },
    "/v1/api/stocks": {
      "get": {
        "summary": "AI stock detections",
        "description": "AI Council stock detections with action signal and confidence. Requires the 'stocks' entitlement.",
        "x-payment-info": {
          "intent": "session",
          "method": ["crypto"],
          "amount": 149,
          "currency": "USD",
          "endpoint": "https://mcp.alphabotpro.cloud/v1/api/checkout/crypto",
          "verify": "https://mcp.alphabotpro.cloud/v1/api/checkout/verify"
        },
        "responses": { "200": { "description": "Detections" }, "402": { "description": "Payment required" } }
      }
    },
    "/v1/api/checkout/crypto": {
      "post": {
        "summary": "Create a crypto invoice",
        "description": "Create a payment invoice for a tier. Returns wallet, amount and a payment_reference_id.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "properties": {
              "tier": { "type": "string", "enum": ["mcp_signals", "mcp_agent", "mcp_enterprise"] },
              "network": { "type": "string", "enum": ["TRON", "Polygon", "Base"] },
              "asset": { "type": "string", "enum": ["USDT", "USDC"] },
              "owner_type": { "type": "string", "enum": ["human", "agent"] },
              "robot_id": { "type": "string" }
            },
            "required": ["tier"]
          } } }
        },
        "responses": { "200": { "description": "Invoice with payment instructions" } }
      }
    },
    "/v1/api/checkout/verify": {
      "post": {
        "summary": "Verify payment and receive key",
        "description": "Verify an on-chain payment by reference. On success, returns a provisioned API key (shown once).",
        "security": [],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "properties": {
              "payment_reference_id": { "type": "string" },
              "tx_hash": { "type": "string" }
            },
            "required": ["payment_reference_id"]
          } } }
        },
        "responses": { "200": { "description": "{ status, api_key }" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "description": "API key in the format abp_<env>_<publicId>_<secret>" }
    }
  }
}
