{
  "openapi": "3.1.0",
  "info": {
    "title": "OffMarketSaaS Clearinghouse API",
    "version": "3.1.0",
    "description": "Verified dormant software asset clearinghouse, acquisition valuation calculator, peer benchmarks, diligence dossiers, MCP manifest, and x402 / sandbox-metered data feed."
  },
  "servers": [
    {
      "url": "https://offmarketsaas.com",
      "description": "offmarketsaas.com production edge"
    }
  ],
  "x-spoke-host": "offmarketsaas.com",
  "x-x402-protocol": {
    "network": "eip155:8453",
    "asset": "USDC",
    "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "requestHeaders": [
      "X-PAYMENT",
      "PAYMENT-SIGNATURE"
    ],
    "responseHeaders": [
      "PAYMENT-REQUIRED",
      "X-Payment-Response"
    ],
    "sandboxAuthHeader": "Authorization: Bearer shinn_sbx_..."
  },
  "security": [
    {
      "BearerSandboxAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerSandboxAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "shinn_sbx_...",
        "description": "Sandbox or provisioned spoke API token passed via `Authorization: Bearer shinn_sbx_...`. Issue a short-lived sandbox token at `/sandbox` or `/api/v1/sandbox/issue-token`."
      },
      "X402PaymentHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PAYMENT",
        "description": "Base Mainnet (eip155:8453) USDC signed x402 payment payload paired with server `PAYMENT-REQUIRED` challenge headers."
      }
    },
    "headers": {
      "PAYMENT-REQUIRED": {
        "description": "Base64/JSON x402 payment requirement returned with HTTP 402.",
        "schema": {
          "type": "string"
        }
      },
      "X-Payment-Response": {
        "description": "Signed x402 settlement receipt returned on paid HTTP 200 responses.",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "X402Challenge": {
        "type": "object",
        "required": [
          "error",
          "network",
          "asset",
          "amount_usdc"
        ],
        "properties": {
          "error": {
            "type": "string",
            "example": "payment_required"
          },
          "network": {
            "type": "string",
            "example": "eip155:8453"
          },
          "asset": {
            "type": "string",
            "example": "USDC"
          },
          "amount_usdc": {
            "type": "string",
            "example": "0.02"
          },
          "pay_to": {
            "type": "string"
          },
          "sandbox_url": {
            "type": "string",
            "example": "https://offmarketsaas.com/sandbox"
          }
        }
      },
      "CalculatorResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "host": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "valuation_band": {
            "type": "object"
          },
          "matches": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "CompareResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "host": {
            "type": "string"
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "DossierResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "host": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "BenchmarkResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "host": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "MeterPreviewResponse": {
        "type": "object",
        "required": [
          "ok",
          "host",
          "auth_mode",
          "x402"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "host": {
            "type": "string"
          },
          "auth_mode": {
            "type": "string",
            "example": "Authorization: Bearer shinn_sbx_..."
          },
          "remaining_credits": {
            "type": "integer"
          },
          "x402": {
            "$ref": "#/components/schemas/X402Challenge"
          }
        }
      },
      "McpDiscoveryManifest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "mcp_endpoint": {
            "type": "string"
          },
          "openapi_url": {
            "type": "string"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Live D1 health check",
        "description": "Returns worker health and live D1 catalog status.",
        "responses": {
          "200": {
            "description": "Health JSON"
          }
        }
      }
    },
    "/api-docs": {
      "get": {
        "operationId": "getApiDocs",
        "summary": "Interactive Developer SDK & OpenAPI Docs Hub",
        "description": "Human-friendly developer quickstart page with cURL, Python, TypeScript, and Claude Desktop / Cursor MCP integration snippets.",
        "responses": {
          "200": {
            "description": "Interactive HTML developer documentation page"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "summary": "OpenAPI 3.1.0 machine specification",
        "description": "Returns the live OpenAPI 3.1.0 JSON spec tailored to this hostname.",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1.0 JSON"
          }
        }
      }
    },
    "/.well-known/mcp.json": {
      "get": {
        "operationId": "getWellKnownMcp",
        "summary": "Model Context Protocol (MCP) discovery manifest",
        "description": "Returns Claude Desktop / Cursor MCP transport metadata and exposed tool definitions.",
        "responses": {
          "200": {
            "description": "MCP discovery JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpDiscoveryManifest"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calculator": {
      "get": {
        "operationId": "getV1Calculator",
        "summary": "Interactive SaaS exit valuation calculator and D1 pond search",
        "description": "Computes dormant SaaS acquisition multiples and returns matching D1 assets.",
        "security": [
          {
            "BearerSandboxAuth": []
          },
          {
            "X402PaymentHeader": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Package, repo, or vertical keyword"
          },
          {
            "name": "arr",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            },
            "description": "Estimated annual recurring revenue (USD)"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "html"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Valuation JSON or interactive HTML",
            "headers": {
              "X-Payment-Response": {
                "$ref": "#/components/headers/X-Payment-Response"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorResponse"
                }
              }
            }
          },
          "402": {
            "description": "x402 Base USDC challenge when unauthenticated quota is exhausted",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PAYMENT-REQUIRED"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Challenge"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/compare": {
      "get": {
        "operationId": "getV1Compare",
        "summary": "Programmatic competitor comparison matrix JSON",
        "description": "Compares OffMarketSaaS verified dormant asset signals against manual sourcing channels.",
        "security": [
          {
            "BearerSandboxAuth": []
          },
          {
            "X402PaymentHeader": []
          }
        ],
        "parameters": [
          {
            "name": "competitor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Comparison JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompareResponse"
                }
              }
            }
          },
          "402": {
            "description": "x402 Base USDC payment challenge",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PAYMENT-REQUIRED"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Challenge"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dossiers": {
      "get": {
        "operationId": "getV1Dossiers",
        "summary": "Structured acquisition diligence dossiers",
        "description": "Returns entity/asset diligence dossier summaries with provenance and signal checks.",
        "security": [
          {
            "BearerSandboxAuth": []
          },
          {
            "X402PaymentHeader": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dossiers JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DossierResponse"
                }
              }
            }
          },
          "402": {
            "description": "x402 Base USDC payment challenge",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PAYMENT-REQUIRED"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Challenge"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/benchmarks": {
      "get": {
        "operationId": "getV1Benchmarks",
        "summary": "Dormant asset & exit multiple benchmarks",
        "description": "Returns live percentile benchmarks across verified micro-SaaS and open-source supply chains.",
        "security": [
          {
            "BearerSandboxAuth": []
          },
          {
            "X402PaymentHeader": []
          }
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Benchmarks JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BenchmarkResponse"
                }
              }
            }
          },
          "402": {
            "description": "x402 Base USDC payment challenge",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PAYMENT-REQUIRED"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Challenge"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meter-preview": {
      "get": {
        "operationId": "getV1MeterPreview",
        "summary": "Sandbox token & x402 Base USDC metering preview",
        "description": "Inspects `Authorization: Bearer shinn_sbx_...` quota status and returns x402 Base USDC (`eip155:8453`) headers and pricing preview.",
        "security": [
          {
            "BearerSandboxAuth": []
          },
          {
            "X402PaymentHeader": []
          }
        ],
        "responses": {
          "200": {
            "description": "Metering & x402 preview JSON",
            "headers": {
              "X-Payment-Response": {
                "$ref": "#/components/headers/X-Payment-Response"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterPreviewResponse"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required preview",
            "headers": {
              "PAYMENT-REQUIRED": {
                "$ref": "#/components/headers/PAYMENT-REQUIRED"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Challenge"
                }
              }
            }
          }
        }
      }
    },
    "/api/cohort-buyer-digest": {
      "get": {
        "operationId": "getCohortBuyerDigest",
        "summary": "Signed Micro-PE 97%-vetted cohort buyer digest",
        "description": "Returns verified buyer-ready cohort digest records.",
        "responses": {
          "200": {
            "description": "Signed JSON digest"
          }
        }
      }
    },
    "/api/items": {
      "get": {
        "operationId": "listItems",
        "summary": "Query verified masked catalog items",
        "description": "Queries masked dormant software catalog records from D1.",
        "responses": {
          "200": {
            "description": "JSON list"
          }
        }
      }
    },
    "/api/risk/summary": {
      "get": {
        "operationId": "getRiskSummary",
        "summary": "Supply-chain abandonware summary",
        "description": "Returns aggregated package abandonware risk counters.",
        "responses": {
          "200": {
            "description": "Summary JSON"
          }
        }
      }
    },
    "/api/privacy/consent": {
      "get": {
        "operationId": "getPrivacyConsent",
        "summary": "GDPR consent policy",
        "description": "Returns current privacy consent configuration.",
        "responses": {
          "200": {
            "description": "Policy JSON"
          }
        }
      },
      "post": {
        "operationId": "savePrivacyConsent",
        "summary": "Save GDPR consent choice",
        "description": "Stores visitor privacy consent preferences.",
        "responses": {
          "200": {
            "description": "Saved JSON"
          }
        }
      }
    },
    "/api/panopticon/status": {
      "get": {
        "operationId": "getPanopticonStatus",
        "summary": "Panopticon hook status",
        "description": "Returns edge telemetry hook health.",
        "responses": {
          "200": {
            "description": "Status JSON"
          }
        }
      }
    }
  }
}