{
  "openapi": "3.1.0",
  "info": {
    "title": "Smoke Run public API",
    "version": "1.0.0",
    "description": "Read-only, from-outside revenue-path teardown of public websites, with a confidence label on every finding. GET and HEAD only against the target; never submits a form, never completes a charge. Dollar figures are a conservative monthly floor and attach only to confirmed or likely findings. Human docs: docs/API.md in the repository.",
    "contact": {
      "url": "https://getsmokerun.com"
    }
  },
  "servers": [
    {
      "url": "https://getsmokerun.com"
    }
  ],
  "tags": [
    {
      "name": "teardown",
      "description": "Free, no-key teardown"
    },
    {
      "name": "mcp",
      "description": "Model Context Protocol servers (JSON-RPC 2.0)"
    },
    {
      "name": "v1",
      "description": "Bearer-key REST API"
    },
    {
      "name": "exposure",
      "description": "Am I exposed? self-check"
    },
    {
      "name": "billing",
      "description": "Run credits"
    }
  ],
  "paths": {
    "/api/mcp": {
      "post": {
        "tags": [
          "mcp"
        ],
        "operationId": "mcpJsonRpc",
        "summary": "Smoke Run MCP server (Streamable HTTP, JSON-RPC 2.0)",
        "description": "Methods: initialize, ping, tools/list, tools/call. Tools: run_revenue_check, get_money_system (free, no key, 5 per day without a key and 200 per day with one), get_latest_findings and list_checks (API key required). Every tool is read-only and carries MCP annotations and an outputSchema.",
        "security": [
          {},
          {
            "bearerKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              },
              "examples": {
                "run": {
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 1,
                    "method": "tools/call",
                    "params": {
                      "name": "run_revenue_check",
                      "arguments": {
                        "url": "https://example.com"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON-RPC response. A failed tool call is a result with isError true, not an HTTP error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted, no body."
          },
          "429": {
            "description": "Rate limited (JSON-RPC error -32000).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/chatgpt/mcp": {
      "post": {
        "tags": [
          "mcp"
        ],
        "operationId": "chatgptMcpJsonRpc",
        "summary": "Smoke Run ChatGPT app MCP server (anonymous)",
        "description": "Tools: run_smoke_run and get_money_system. The credentialed tenant tools are not exposed. GET and DELETE return 405.",
        "security": [
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON-RPC response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted, no body."
          },
          "400": {
            "description": "Parse error or batch request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/teardown": {
      "post": {
        "tags": [
          "teardown"
        ],
        "operationId": "teardown",
        "summary": "Run the free teardown and return a dollar proof",
        "security": [
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeardownRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A dollar proof. An internal failure still returns an inconclusive proof.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DollarProof"
                }
              }
            }
          },
          "400": {
            "description": "Body not JSON or url invalid. Inconclusive proof.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DollarProof"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (8 per minute per IP, best effort). Inconclusive proof.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DollarProof"
                }
              }
            }
          }
        }
      }
    },
    "/api/teardown/stream": {
      "get": {
        "tags": [
          "teardown"
        ],
        "operationId": "teardownStream",
        "summary": "Server-Sent Events feed of the same teardown",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 2048
            }
          },
          {
            "name": "monthlyVisitors",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          {
            "name": "monthlyOrders",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          {
            "name": "monthlyLeads",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          {
            "name": "aov",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          {
            "name": "closeRate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          },
          {
            "name": "adSpend",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "text/event-stream. Each event is `data: <json>` with a type of agent_start, page, link, check, finding, progress, system, error or done. The last event is done with the proof. A missing url or a throttled request returns a single done event.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "teardown"
        ],
        "operationId": "teardownStreamPost",
        "summary": "Same event stream, request body instead of query",
        "security": [
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeardownRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "text/event-stream. Each event is `data: <json>` with a type of agent_start, page, link, check, finding, progress, system, error or done. The last event is done with the proof. A missing url or a throttled request returns a single done event.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/exposure/check": {
      "post": {
        "tags": [
          "exposure"
        ],
        "operationId": "exposureCheck",
        "summary": "Am I exposed? Which Supabase tables answer an anonymous visitor",
        "security": [
          {}
        ],
        "description": "Passive and owner-submitted. Keeps only status codes, never row contents. Never uses a service_role key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  }
                },
                "required": [
                  "url"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The exposure result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExposureResult"
                }
              }
            }
          },
          "400": {
            "description": "Body not JSON or url missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (5 per minute per IP, best effort).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/checks": {
      "post": {
        "tags": [
          "v1"
        ],
        "operationId": "createCheck",
        "summary": "Run a read-only check for the key's account and store it",
        "security": [
          {
            "bearerKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  }
                },
                "required": [
                  "url"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The stored check.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "runId": {
                      "type": "string"
                    },
                    "proof": {
                      "$ref": "#/components/schemas/DollarProof"
                    }
                  },
                  "required": [
                    "runId",
                    "proof"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "20 per minute per key. retry-after header set.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Could not complete the check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "v1"
        ],
        "operationId": "listChecks",
        "summary": "Recent checks for the key's account",
        "security": [
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "name": "siteUrl",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Check summaries, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CheckSummary"
                      }
                    }
                  },
                  "required": [
                    "checks"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "120 per minute per key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Could not load checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/checks/{id}": {
      "get": {
        "tags": [
          "v1"
        ],
        "operationId": "getCheck",
        "summary": "One stored run and its rebuilt dollar proof",
        "security": [
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The run and proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "run": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "proof": {
                      "$ref": "#/components/schemas/DollarProof"
                    }
                  },
                  "required": [
                    "run",
                    "proof"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No check with that id for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "120 per minute per key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Could not load the check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/money-system": {
      "get": {
        "tags": [
          "v1"
        ],
        "operationId": "getMoneySystem",
        "summary": "Detected revenue stack of a public site",
        "security": [
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 2048
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The funnel map.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MoneySystemResult"
                }
              }
            }
          },
          "400": {
            "description": "url missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "60 per minute per key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Could not read that site.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/checkout": {
      "post": {
        "tags": [
          "billing"
        ],
        "operationId": "agentCheckout",
        "summary": "Open a hosted Stripe Checkout for run credits or Agent Unlimited",
        "security": [
          {}
        ],
        "description": "The api_key in the body identifies the account that receives the purchase. The buyer pays on Stripe's hosted page. credits_300 is $10, credits_2000 is $40, credits_10000 is $150, agent_unlimited is $39 per month with a fair-use limit of 2000 runs per month.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": {
                    "type": "string",
                    "enum": [
                      "credits_300",
                      "credits_2000",
                      "credits_10000",
                      "agent_unlimited"
                    ]
                  },
                  "api_key": {
                    "type": "string",
                    "minLength": 8
                  }
                },
                "required": [
                  "sku",
                  "api_key"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A hosted Checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "API key not recognized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Could not start checkout.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer sk_live_... An account key. Keys are stored only as a SHA-256 hash and are bound to one account."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Confidence": {
        "type": "string",
        "enum": [
          "confirmed",
          "likely",
          "unverifiable_from_outside"
        ],
        "description": "confirmed: reproduced from outside (every real-browser re-check agreed). likely: inferred from the public page. unverifiable_from_outside: only a connected check can confirm it; never carries a dollar figure."
      },
      "Finding": {
        "type": "object",
        "properties": {
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "warning",
              "ok"
            ]
          },
          "whatBroke": {
            "type": "string"
          },
          "where": {
            "type": "string"
          },
          "evidence": {
            "type": "string"
          },
          "estMonthlyLoss": {
            "type": "number",
            "description": "Present only when confidence is confirmed or likely."
          },
          "fix": {
            "type": "string"
          },
          "confidence": {
            "$ref": "#/components/schemas/Confidence"
          }
        },
        "required": [
          "severity",
          "whatBroke",
          "where",
          "evidence"
        ]
      },
      "DollarProof": {
        "type": "object",
        "properties": {
          "siteUrl": {
            "type": "string"
          },
          "headline": {
            "type": "string"
          },
          "dollarsAtRisk": {
            "type": "number",
            "description": "Conservative monthly floor over confirmed and likely findings only."
          },
          "window": {
            "type": "string"
          },
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "siteUrl",
          "headline",
          "dollarsAtRisk",
          "window",
          "findings",
          "generatedAt"
        ]
      },
      "TeardownRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "hints": {
            "type": "object",
            "properties": {
              "monthlyVisitors": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000000.0
              },
              "monthlyOrders": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000000.0
              },
              "monthlyLeads": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000000.0
              },
              "aov": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 10000000.0
              },
              "closeRate": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1
              },
              "adSpend": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000000.0
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "url"
        ]
      },
      "CheckSummary": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "siteUrl": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "healthy",
              "at_risk",
              "broken",
              "inconclusive"
            ]
          },
          "dollarsAtRisk": {
            "type": "number"
          },
          "mode": {
            "type": "string",
            "enum": [
              "monitor",
              "teardown"
            ]
          },
          "startedAt": {
            "type": "string"
          },
          "finishedAt": {
            "type": "string"
          }
        },
        "required": [
          "runId",
          "siteUrl",
          "status",
          "dollarsAtRisk",
          "mode",
          "startedAt",
          "finishedAt"
        ]
      },
      "MoneySystemResult": {
        "type": "object",
        "properties": {
          "siteUrl": {
            "type": "string"
          },
          "detected": {
            "type": "boolean"
          },
          "map": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "form",
                    "payment",
                    "crm",
                    "email",
                    "booking",
                    "analytics"
                  ]
                },
                "title": {
                  "type": "string"
                },
                "detected": {
                  "type": "boolean"
                },
                "detail": {
                  "type": "string"
                },
                "paidProof": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "title",
                "detected",
                "detail",
                "paidProof"
              ]
            }
          }
        },
        "required": [
          "siteUrl",
          "detected",
          "map"
        ]
      },
      "ExposureResult": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "blocked",
              "unreachable",
              "no_supabase",
              "checked"
            ]
          },
          "siteUrl": {
            "type": "string"
          },
          "projectHost": {
            "type": "string"
          },
          "serviceKeyInPublicCode": {
            "type": "boolean"
          },
          "tablesListed": {
            "type": "boolean"
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "anonReadable": {
                  "type": "boolean"
                },
                "emptyAnswer": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "anonReadable"
              ]
            }
          },
          "readableCount": {
            "type": "integer"
          },
          "summary": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "siteUrl",
          "serviceKeyInPublicCode",
          "tablesListed",
          "tables",
          "readableCount",
          "summary"
        ]
      },
      "JsonRpcRequest": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer"
            ]
          },
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "jsonrpc",
          "method"
        ]
      },
      "JsonRpcResponse": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "result": {
            "type": "object",
            "additionalProperties": true
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "jsonrpc",
          "id"
        ]
      }
    }
  }
}
