{
  "openapi": "3.1.0",
  "info": {
    "title": "SRIFT API",
    "version": "2.0.0",
    "summary": "Zero-config, zero-token P2P E2EE file transfer + chat for any AI agent or automation.",
    "description": "Two API surfaces:\n\n  1. **Local daemon** at `http://127.0.0.1:3822` (recommended for AI agents — fully token-less).\n  2. **Public signaling** at `https://srift.app` (used by browser clients).\n\nFor AI agents, use the local daemon endpoints (everything under /quick-share, /session/*, /send, /receive, /chat/*, /mcp). Documentation: https://srift.app/AGENTS.md",
    "contact": { "email": "support@sripto.tech" },
    "license": { "name": "MIT" }
  },
  "servers": [
    { "url": "http://127.0.0.1:3822", "description": "Local daemon (zero-auth, recommended for AI agents)" },
    { "url": "https://srift.app", "description": "Public signaling server (browser clients)" }
  ],
  "tags": [
    { "name": "agent", "description": "Zero-config endpoints designed for AI agents" },
    { "name": "session", "description": "Session lifecycle" },
    { "name": "transfer", "description": "File transfer (P2P with fallback)" },
    { "name": "chat", "description": "E2EE chat" },
    { "name": "mcp", "description": "Model Context Protocol transport" },
    { "name": "monitor", "description": "Progress + state monitoring" },
    { "name": "discovery", "description": "Discovery / health" }
  ],
  "paths": {
    "/quick-share": {
      "post": {
        "tags": ["agent", "transfer"],
        "summary": "ONE-SHOT: ensure session + seed file + return share URL",
        "description": "Primary entry point for AI agents. If no session is active, creates one. Then seeds the given file. Returns a share URL the recipient can open in any browser.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["filePath"],
                "properties": {
                  "filePath": { "type": "string", "description": "Absolute path to the file" },
                  "sessionName": { "type": "string", "description": "Optional label" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "sessionId": { "type": "string" },
                    "fileId": { "type": "string" },
                    "shareUrl": { "type": "string", "format": "uri" },
                    "protocol": { "type": "string", "enum": ["webtorrent", "websocket"] },
                    "fileName": { "type": "string" },
                    "fileSize": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/status": { "get": { "tags": ["session", "monitor"], "summary": "Get session + transfers + pending join requests", "responses": { "200": { "description": "OK" } } } },
    "/state": { "get": { "tags": ["monitor"], "summary": "Raw .srift-state.json snapshot", "responses": { "200": { "description": "OK" } } } },
    "/session/start": {
      "post": {
        "tags": ["session"],
        "summary": "Create a new session (you become host)",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "sessionName": { "type": "string" }, "roomSecret": { "type": "string", "description": "Optional shared secret for stronger E2EE — never sent to server" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/session/join": {
      "post": {
        "tags": ["session"],
        "summary": "Request to join an existing session",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["sessionId"], "properties": { "sessionId": { "type": "string", "description": "7-character session ID" }, "username": { "type": "string" }, "roomSecret": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/session/approve": {
      "post": {
        "tags": ["session"], "summary": "Host-only: approve a pending guest",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["tempUserId"], "properties": { "tempUserId": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/session/reject": {
      "post": {
        "tags": ["session"], "summary": "Host-only: reject a pending guest",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["tempUserId"], "properties": { "tempUserId": { "type": "string" }, "reason": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/session/kick": {
      "post": {
        "tags": ["session"], "summary": "Host-only: disconnect a peer",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["userId"], "properties": { "userId": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/session/close": { "post": { "tags": ["session"], "summary": "Close active session and flush keys", "responses": { "200": { "description": "OK" } } } },
    "/send": {
      "post": {
        "tags": ["transfer"], "summary": "Offer a file to the connected peer",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["filePath"], "properties": { "filePath": { "type": "string" }, "protocol": { "type": "string", "enum": ["webtorrent", "websocket"] } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/receive": {
      "post": {
        "tags": ["transfer"], "summary": "Accept an inbound file offer",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["fileId"], "properties": { "fileId": { "type": "string" }, "saveDir": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/chat/send": {
      "post": {
        "tags": ["chat"], "summary": "Send an E2EE chat message",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["message"], "properties": { "message": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/chat/history": { "get": { "tags": ["chat"], "summary": "Read decrypted chat log", "responses": { "200": { "description": "OK" } } } },
    "/api/v1/monitor/events": {
      "get": {
        "tags": ["monitor"], "summary": "SSE event stream",
        "description": "Server-sent events. Event types: `connection_state`, `join_request`, `file_offer`, `transfer_progress`, `chat_received`.",
        "responses": { "200": { "description": "text/event-stream" } }
      }
    },
    "/mcp": {
      "post": { "tags": ["mcp"], "summary": "MCP JSON-RPC over Streamable HTTP (spec 2025-06-18)", "responses": { "200": { "description": "JSON-RPC response" } } },
      "get": { "tags": ["mcp"], "summary": "MCP SSE event stream (server→client notifications)", "responses": { "200": { "description": "text/event-stream" } } }
    },
    "/mcp/sse": { "get": { "tags": ["mcp"], "summary": "Legacy MCP SSE transport (open stream, then POST /mcp/messages)", "responses": { "200": { "description": "text/event-stream" } } } },
    "/mcp/messages": { "post": { "tags": ["mcp"], "summary": "Legacy MCP transport — POST JSON-RPC messages", "responses": { "200": { "description": "JSON-RPC response" } } } },
    "/create-session": {
      "post": {
        "tags": ["session"], "summary": "Public signaling: create session (used by browser clients)",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "username": { "type": "string" }, "name": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/join-session": {
      "post": {
        "tags": ["session"], "summary": "Public signaling: request join (used by browser clients)",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": ["sessionId"], "properties": { "sessionId": { "type": "string" }, "username": { "type": "string" } } } } } },
        "responses": { "200": { "description": "OK" } }
      }
    },
    "/healthz": { "get": { "tags": ["discovery"], "summary": "Liveness probe", "responses": { "200": { "description": "OK" } } } },
    "/readyz": { "get": { "tags": ["discovery"], "summary": "Readiness probe (includes DB check)", "responses": { "200": { "description": "OK" } } } },
    "/.well-known/mcp/server-card.json": { "get": { "tags": ["discovery", "mcp"], "summary": "MCP server card", "responses": { "200": { "description": "OK" } } } },
    "/.well-known/ai-plugin.json": { "get": { "tags": ["discovery"], "summary": "OpenAI plugin manifest", "responses": { "200": { "description": "OK" } } } },
    "/.well-known/agent.json": { "get": { "tags": ["discovery"], "summary": "Google A2A agent card", "responses": { "200": { "description": "OK" } } } },
    "/.well-known/agent-skills/index.json": { "get": { "tags": ["discovery"], "summary": "AGNTCY skills registry", "responses": { "200": { "description": "OK" } } } }
  },
  "components": { "securitySchemes": {} },
  "security": [],
  "externalDocs": { "description": "Full agent manual", "url": "https://srift.app/AGENTS.md" }
}
