{
  "openapi": "3.0.3",
  "info": {
    "title": "3Dogs Nexus Decision Intelligence API",
    "version": "1.0.0",
    "description": "Public API for 3Dogs Nexus — adversarial multi-model decision intelligence. Submit a high-stakes business decision; a panel of 10-40+ AI models researches, debates, and returns a decisive recommendation with preserved dissent as a PDF report. Authentication is session-cookie based (create a session via /api/login). New accounts receive a 30-day free trial automatically. No OAuth token API yet — see https://3dogs.ai/auth.md",
    "contact": { "name": "Alan Finney", "email": "alan@3dogs.ai", "url": "https://3dogs.ai" },
    "termsOfService": "https://app.3dogs.ai/terms"
  },
  "servers": [ { "url": "https://app.3dogs.ai" } ],
  "components": {
    "securitySchemes": {
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "session",
        "description": "Flask signed session cookie obtained via POST /api/login. Include cookies on all authenticated requests."
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Service health",
        "description": "Public health/status endpoint. No authentication required.",
        "responses": { "200": { "description": "Service is up", "content": { "application/json": { "example": { "status": "ok", "timestamp": "2026-07-23T06:14:26Z" } } } } }
      }
    },
    "/api/signup": {
      "post": {
        "summary": "Create an account",
        "description": "Creates a new account with an automatic 30-day free trial (no confirmation code required). Agents may register on behalf of a user only with that user's explicit consent. Returns 409 if the email already has an account.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email", "password"], "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string", "minLength": 8 } } } } } },
        "responses": { "200": { "description": "Account created, session started; complete Terms acceptance at /onboard before first use" }, "409": { "description": "Account already exists — log in instead" } }
      }
    },
    "/api/login": {
      "post": {
        "summary": "Log in (start a session)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email", "password"], "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string" } } } } } },
        "responses": { "200": { "description": "Session cookie set" }, "401": { "description": "Invalid credentials" } }
      }
    },
    "/api/whoami": {
      "get": {
        "summary": "Current session identity",
        "responses": { "200": { "description": "Returns the logged-in email, or an anonymous indicator" } }
      }
    },
    "/intake": {
      "post": {
        "summary": "Submit a decision case",
        "description": "Starts a full multi-model adversarial analysis. Requires an active session and an active plan or trial. Write in ANY language — the analysis returns in English. The final report is delivered by email as a PDF and appears in the account dashboard; progress can be watched live at /watch?case=<case_id>. Analysis takes ~5-40+ minutes depending on mode.",
        "security": [ { "sessionCookie": [] } ],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["q1"], "properties": {
          "email": { "type": "string", "format": "email", "description": "Account email (matches the session)" },
          "q1": { "type": "string", "description": "The decision, in full — situation, options, constraints, numbers, deadlines. Any language, formulas, and pasted spreadsheet data are all accepted." },
          "q2": { "type": "string", "description": "Optional guided field (business background). Fields q2-q26 are optional structured intake prompts shown in guided mode; q1 alone is sufficient." },
          "mode": { "type": "string", "enum": ["", "direct", "deep"], "description": "\"\" = 3Dogs decides (adaptive, may ask clarifying questions), \"direct\" = no follow-up questions single-panel (~5 min), \"deep\" = forced 3-panel ensemble with clarification rounds (slow, most rigorous)" }
        } } } } },
        "responses": { "200": { "description": "Case accepted; returns case_id" }, "302": { "description": "Not authenticated — redirected to login" }, "402": { "description": "No active plan or trial" } }
      }
    },
    "/api/my-cases": {
      "get": {
        "summary": "List the account's cases",
        "description": "Returns the session account's cases with status, any pending clarification questions, PDF download links, and an account block (plan, days remaining).",
        "security": [ { "sessionCookie": [] } ],
        "responses": { "200": { "description": "Case list" } }
      }
    }
  }
}
