{ "openapi": "3.1.0", "info": { "title": "LLMtxt API", "version": "2026.4.6", "description": "LLMtxt — agent-first document storage, compression, versioning, and multi-agent collaboration. Auth: Bearer API key (`Authorization: Bearer `) or session cookie (`llmtxt_session`). Read routes on public documents are unauthenticated.", "contact": { "name": "LLMtxt Support", "url": "https://llmtxt.my" }, "license": { "name": "MIT", "url": "https://opensource.org/licenses/MIT" }, "x-logo": { "url": "https://llmtxt.my/favicon.svg" } }, "tags": [ { "name": "documents", "description": "Core document storage and retrieval" }, { "name": "versions", "description": "Version management and diffing" }, { "name": "lifecycle", "description": "Document lifecycle state machine and approvals" }, { "name": "disclosure", "description": "Progressive disclosure — sections, TOC, search" }, { "name": "crdt", "description": "Real-time CRDT collaboration (Loro)" }, { "name": "realtime", "description": "WebSocket real-time event streams" }, { "name": "presence", "description": "Agent presence and awareness" }, { "name": "leases", "description": "Section write leases for turn-taking" }, { "name": "scratchpad", "description": "Agent scratchpad for ephemeral notes" }, { "name": "bft", "description": "Byzantine fault-tolerant consensus voting" }, { "name": "a2a", "description": "Agent-to-agent messaging" }, { "name": "events", "description": "Document and global event streams" }, { "name": "blobs", "description": "Binary blob attachments (content-addressed)" }, { "name": "export", "description": "Document export in multiple formats" }, { "name": "collections", "description": "Document collection management" }, { "name": "retrieval", "description": "Semantic retrieval and similarity" }, { "name": "semantic", "description": "Semantic diff and consensus" }, { "name": "search", "description": "Full-text and cross-document search" }, { "name": "cross-doc", "description": "Cross-document links and graph" }, { "name": "merge", "description": "Three-way merge and patch application" }, { "name": "signed-urls", "description": "Temporary signed URLs for unauthenticated access" }, { "name": "webhooks", "description": "Webhook event delivery" }, { "name": "access-control", "description": "Document ACL and role management" }, { "name": "organizations", "description": "Organization and member management" }, { "name": "api-keys", "description": "API key lifecycle management" }, { "name": "agent-keys", "description": "Ed25519 agent key registration and revocation" }, { "name": "agents", "description": "Well-known agent registry" }, { "name": "auth", "description": "Authentication — session management" }, { "name": "schemas", "description": "Predefined validation schemas" }, { "name": "health", "description": "Liveness, readiness, and Prometheus metrics" }, { "name": "system", "description": "Cache management and system utilities" } ], "paths": { "/api/compress": { "post": { "operationId": "postCompress", "summary": "Compress and store a document. Accepts plaintext, JSON, or Markdown. Auto-detects format when `format` is omitted. Returns a slug that uniquely identifies the stored document.", "description": "Compress and store a document. Accepts plaintext, JSON, or Markdown. Auto-detects format when `format` is omitted. Returns a slug that uniquely identifies the stored document.", "tags": [ "documents" ], "parameters": [], "responses": { "201": { "description": "Document stored successfully", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "format": { "type": "string", "enum": [ "json", "text", "markdown" ] }, "tokenCount": { "type": "integer" }, "compressionRatio": { "type": "number" }, "originalSize": { "type": "integer" }, "compressedSize": { "type": "integer" } } } } } }, "400": { "description": "Validation failed — invalid body or unknown schema", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "413": { "description": "Content too large (exceeds limit)", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "429": { "description": "Write rate limit exceeded", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}": { "get": { "operationId": "wsDocumentStream", "summary": "WebSocket endpoint for legacy real-time document event streaming.", "description": "WebSocket endpoint for legacy real-time document event streaming.", "tags": [ "realtime" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier (WebSocket upgrade)", "schema": { "type": "string" }, "required": true } ], "responses": { "101": { "description": "WebSocket upgrade — real-time document event stream" }, "401": { "description": "Unauthenticated (WS close code 4401)" } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] }, "put": { "operationId": "putDocument", "summary": "Update a document (creates a new version). Increments `currentVersion`, stores the new compressed content as a version record, updates contributors, and invalidates cache.", "description": "Update a document (creates a new version). Increments `currentVersion`, stores the new compressed content as a version record, updates contributors, and invalidates cache.", "tags": [ "documents" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "New version created", "content": { "application/json": { "schema": { "type": "object", "properties": { "slug": { "type": "string" }, "versionNumber": { "type": "integer" }, "tokenCount": { "type": "integer" }, "compressionRatio": { "type": "number" } } } } } }, "403": { "description": "Write access denied", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "423": { "description": "Document is locked (LOCKED state)", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "429": { "description": "Write rate limit exceeded", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/decompress": { "post": { "operationId": "postDecompress", "summary": "Decompress a document body via POST. Alternative to GET when the slug must be sent as a body parameter.", "description": "Decompress a document body via POST. Alternative to GET when the slug must be sent as a body parameter.", "tags": [ "documents" ], "parameters": [], "responses": { "200": { "description": "Document decompressed", "content": { "application/json": { "schema": { "type": "object", "properties": { "content": { "type": "string" }, "format": { "type": "string" }, "tokenCount": { "type": "integer" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/validate": { "post": { "operationId": "postValidate", "summary": "Validate content against a predefined schema without storing it.", "description": "Validate content against a predefined schema without storing it.", "tags": [ "documents" ], "parameters": [], "responses": { "200": { "description": "Content is valid", "content": { "application/json": { "schema": { "type": "object", "properties": { "valid": { "type": "boolean", "enum": [ true ] } } } } } }, "400": { "description": "Validation failed with detailed errors", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/mine": { "get": { "operationId": "getDocumentsMine", "summary": "List all documents owned by the authenticated user.", "description": "List all documents owned by the authenticated user.", "tags": [ "documents" ], "parameters": [], "responses": { "200": { "description": "List of owned documents", "content": { "application/json": { "schema": { "type": "object", "properties": { "documents": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "format": { "type": "string" }, "tokenCount": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "state": { "type": "string" } } } }, "total": { "type": "integer" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/schemas": { "get": { "operationId": "getSchemas", "summary": "List available predefined validation schemas.", "description": "List available predefined validation schemas.", "tags": [ "schemas" ], "parameters": [], "responses": { "200": { "description": "Available schema names", "content": { "application/json": { "schema": { "type": "object", "properties": { "schemas": { "type": "array", "items": { "type": "string" } } } } } } } } } }, "/api/schemas/{name}": { "get": { "operationId": "getSchema", "summary": "Get a specific predefined schema by name.", "description": "Get a specific predefined schema by name.", "tags": [ "schemas" ], "parameters": [ { "name": "name", "in": "path", "description": "Schema name (e.g., `prompt-v1`)", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "JSON schema object", "content": { "application/json": { "schema": { "type": "object" } } } }, "404": { "description": "Schema not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/stats/cache": { "get": { "operationId": "getStatsCache", "summary": "Get cache statistics (hit/miss counts, size).", "description": "Get cache statistics (hit/miss counts, size).", "tags": [ "system" ], "parameters": [], "responses": { "200": { "description": "Cache statistics", "content": { "application/json": { "schema": { "type": "object", "properties": { "hits": { "type": "integer" }, "misses": { "type": "integer" }, "size": { "type": "integer" } } } } } } } } }, "/api/cache": { "delete": { "operationId": "deleteCache", "summary": "Invalidate all cached documents.", "description": "Invalidate all cached documents.", "tags": [ "system" ], "parameters": [], "responses": { "200": { "description": "Cache cleared", "content": { "application/json": { "schema": { "type": "object", "properties": { "cleared": { "type": "integer" } } } } } }, "401": { "description": "Authentication required (admin only)", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/llms.txt": { "get": { "operationId": "getLlmsTxt", "summary": "Serve the llms.txt autodiscovery file.", "description": "Serve the llms.txt autodiscovery file.", "tags": [ "system" ], "parameters": [], "responses": { "200": { "description": "Plain text llms.txt autodiscovery file", "content": { "text/plain": { "schema": { "type": "string" } } } } } } }, "/api/documents/{slug}/versions": { "get": { "operationId": "getDocumentVersions", "summary": "List all versions of a document.", "description": "List all versions of a document.", "tags": [ "versions" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Version list", "content": { "application/json": { "schema": { "type": "object", "properties": { "versions": { "type": "array", "items": { "type": "object", "properties": { "versionNumber": { "type": "integer" }, "tokenCount": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "createdBy": { "type": "string" }, "changelog": { "type": "string" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/versions/{num}": { "get": { "operationId": "getDocumentVersion", "summary": "Get a specific version of a document.", "description": "Get a specific version of a document.", "tags": [ "versions" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "num", "in": "path", "description": "Version number (1-based)", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Specific version content", "content": { "application/json": { "schema": { "type": "object", "properties": { "content": { "type": "string" }, "versionNumber": { "type": "integer" }, "tokenCount": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" }, "createdBy": { "type": "string" } } } } } }, "404": { "description": "Document or version not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/diff": { "get": { "operationId": "getDocumentDiff", "summary": "Get a two-way diff between two versions of a document.", "description": "Get a two-way diff between two versions of a document.", "tags": [ "versions" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Two-way diff between versions", "content": { "application/json": { "schema": { "type": "object", "properties": { "diff": { "type": "array", "items": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "add", "remove", "equal" ] }, "content": { "type": "string" }, "lineNumber": { "type": "integer" } } } }, "fromVersion": { "type": "integer" }, "toVersion": { "type": "integer" } } } } } }, "400": { "description": "Invalid version numbers", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document or version not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/multi-diff": { "get": { "operationId": "getDocumentMultiDiff", "summary": "Get a multi-way diff across N versions (N ≥ 2). Uses LCS-based alignment to produce a consensus view of divergent versions.", "description": "Get a multi-way diff across N versions (N ≥ 2). Uses LCS-based alignment to produce a consensus view of divergent versions.", "tags": [ "versions" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Multi-way LCS-aligned diff", "content": { "application/json": { "schema": { "type": "object", "properties": { "lines": { "type": "array", "items": { "type": "object", "properties": { "type": { "type": "string" }, "content": { "type": "string" }, "versions": { "type": "array", "items": { "type": "integer" } } } } }, "versions": { "type": "array", "items": { "type": "integer" } } } } } } }, "400": { "description": "Fewer than 2 versions specified", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document or version not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/batch-versions": { "post": { "operationId": "postBatchVersions", "summary": "Create multiple versions in a single atomic batch. Each entry in the batch becomes a separate version record in order.", "description": "Create multiple versions in a single atomic batch. Each entry in the batch becomes a separate version record in order.", "tags": [ "versions" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Batch versions created", "content": { "application/json": { "schema": { "type": "object", "properties": { "created": { "type": "integer" }, "latestVersion": { "type": "integer" } } } } } }, "400": { "description": "Invalid batch payload", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/transition": { "post": { "operationId": "postDocumentTransition", "summary": "Transition a document through its lifecycle state machine. Valid transitions: DRAFT→REVIEW, REVIEW→APPROVED, REVIEW→REJECTED, APPROVED→LOCKED, LOCKED→DRAFT (unlock).", "description": "Transition a document through its lifecycle state machine. Valid transitions: DRAFT→REVIEW, REVIEW→APPROVED, REVIEW→REJECTED, APPROVED→LOCKED, LOCKED→DRAFT (unlock).", "tags": [ "lifecycle" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "State transitioned", "content": { "application/json": { "schema": { "type": "object", "properties": { "slug": { "type": "string" }, "state": { "type": "string", "enum": [ "DRAFT", "REVIEW", "APPROVED", "LOCKED", "REJECTED" ] }, "previousState": { "type": "string" } } } } } }, "400": { "description": "Invalid transition", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "403": { "description": "Insufficient permissions", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/documents/{slug}/approve": { "post": { "operationId": "postDocumentApprove", "summary": "Submit an approval vote for a document in REVIEW state.", "description": "Submit an approval vote for a document in REVIEW state.", "tags": [ "lifecycle" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Approval recorded", "content": { "application/json": { "schema": { "type": "object", "properties": { "approvalId": { "type": "string" }, "agentId": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "409": { "description": "Already approved by this agent", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/reject": { "post": { "operationId": "postDocumentReject", "summary": "Submit a rejection for a document in REVIEW state.", "description": "Submit a rejection for a document in REVIEW state.", "tags": [ "lifecycle" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Document rejected", "content": { "application/json": { "schema": { "type": "object", "properties": { "slug": { "type": "string" }, "state": { "type": "string", "enum": [ "REJECTED" ] } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/approvals": { "get": { "operationId": "getDocumentApprovals", "summary": "Get approval records for a document.", "description": "Get approval records for a document.", "tags": [ "lifecycle" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Approval records", "content": { "application/json": { "schema": { "type": "object", "properties": { "approvals": { "type": "array", "items": { "type": "object", "properties": { "agentId": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "comment": { "type": "string" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/contributors": { "get": { "operationId": "getDocumentContributors", "summary": "Get contributor statistics for a document.", "description": "Get contributor statistics for a document.", "tags": [ "lifecycle" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Contributor statistics", "content": { "application/json": { "schema": { "type": "object", "properties": { "contributors": { "type": "array", "items": { "type": "object", "properties": { "agentId": { "type": "string" }, "versionsAuthored": { "type": "integer" }, "netTokens": { "type": "integer" }, "firstContribution": { "type": "string", "format": "date-time" }, "lastContribution": { "type": "string", "format": "date-time" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/agents/keys": { "post": { "operationId": "postAgentKey", "summary": "Register an Ed25519 public key for an agent. The key is validated as a valid Ed25519 point before storage. A SHA-256 fingerprint (first 16 hex chars) is returned for identification.", "description": "Register an Ed25519 public key for an agent. The key is validated as a valid Ed25519 point before storage. A SHA-256 fingerprint (first 16 hex chars) is returned for identification.", "tags": [ "agent-keys" ], "parameters": [], "responses": { "201": { "description": "Agent key registered", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "fingerprint": { "type": "string" }, "pubkey_hex": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "400": { "description": "Invalid Ed25519 public key", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] }, "get": { "operationId": "getAgentKeys", "summary": "List all active (non-revoked) Ed25519 keys for the authenticated user.", "description": "List all active (non-revoked) Ed25519 keys for the authenticated user.", "tags": [ "agent-keys" ], "parameters": [], "responses": { "200": { "description": "Agent key list", "content": { "application/json": { "schema": { "type": "object", "properties": { "keys": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "fingerprint": { "type": "string" }, "pubkey_hex": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/agents/keys/{id}": { "delete": { "operationId": "deleteAgentKey", "summary": "Revoke (soft-delete) an agent key by ID. Sets `revoked_at` timestamp; the key is excluded from all future lookups.", "description": "Revoke (soft-delete) an agent key by ID. Sets `revoked_at` timestamp; the key is excluded from all future lookups.", "tags": [ "agent-keys" ], "parameters": [ { "name": "id", "in": "path", "description": "Key record ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Key revoked", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "revokedAt": { "type": "string", "format": "date-time" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Key not found or belongs to another user", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/keys": { "post": { "operationId": "postApiKey", "summary": "Create a new API key for programmatic access.", "description": "Create a new API key for programmatic access.", "tags": [ "api-keys" ], "parameters": [], "responses": { "201": { "description": "API key created — key value shown once", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "key": { "type": "string" }, "name": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "expiresAt": { "type": "string", "format": "date-time", "nullable": true } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] }, "get": { "operationId": "getApiKeys", "summary": "List all active API keys for the authenticated user.", "description": "List all active API keys for the authenticated user.", "tags": [ "api-keys" ], "parameters": [], "responses": { "200": { "description": "API key list", "content": { "application/json": { "schema": { "type": "object", "properties": { "keys": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "expiresAt": { "type": "string", "format": "date-time", "nullable": true }, "lastUsed": { "type": "string", "format": "date-time", "nullable": true } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/keys/{id}": { "delete": { "operationId": "deleteApiKey", "summary": "Delete (revoke) an API key by ID.", "description": "Delete (revoke) an API key by ID.", "tags": [ "api-keys" ], "parameters": [ { "name": "id", "in": "path", "description": "API key ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "API key deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Key not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/keys/{id}/rotate": { "post": { "operationId": "postApiKeyRotate", "summary": "Rotate an API key — atomically replaces the secret.", "description": "Rotate an API key — atomically replaces the secret.", "tags": [ "api-keys" ], "parameters": [ { "name": "id", "in": "path", "description": "API key ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "New key value — shown once", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "key": { "type": "string" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Key not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/health": { "get": { "operationId": "getHealth", "summary": "Liveness probe — no I/O, always 200 when process is alive.", "description": "Liveness probe — no I/O, always 200 when process is alive.", "tags": [ "health" ], "parameters": [], "responses": { "200": { "description": "Service is alive", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "ok" ] }, "version": { "type": "string" }, "ts": { "type": "string", "format": "date-time" } } } } } } } } }, "/api/ready": { "get": { "operationId": "getReady", "summary": "Readiness probe — pings the database before returning 200.", "description": "Readiness probe — pings the database before returning 200.", "tags": [ "health" ], "parameters": [], "responses": { "200": { "description": "Service is ready", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "ok" ] }, "version": { "type": "string" }, "ts": { "type": "string", "format": "date-time" } } } } } }, "503": { "description": "Database unavailable", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/metrics": { "get": { "operationId": "getMetrics", "summary": "Prometheus metrics endpoint (prom-client). Protected by `METRICS_TOKEN` env var when set.", "description": "Prometheus metrics endpoint (prom-client). Protected by `METRICS_TOKEN` env var when set.", "tags": [ "health" ], "parameters": [], "responses": { "200": { "description": "Prometheus text metrics", "content": { "text/plain": { "schema": { "type": "string" } } } }, "401": { "description": "Invalid or missing token", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/documents/{slug}/overview": { "get": { "operationId": "getDocumentOverview", "summary": "Get a structural overview of a document (section list, stats).", "description": "Get a structural overview of a document (section list, stats).", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Document structure overview", "content": { "application/json": { "schema": { "type": "object", "properties": { "slug": { "type": "string" }, "sectionCount": { "type": "integer" }, "tokenCount": { "type": "integer" }, "format": { "type": "string" }, "sections": { "type": "array", "items": { "type": "string" } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/sections": { "get": { "operationId": "getDocumentSections", "summary": "Get all sections of a document.", "description": "Get all sections of a document.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "All document sections", "content": { "application/json": { "schema": { "type": "object", "properties": { "sections": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "content": { "type": "string" }, "tokenCount": { "type": "integer" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/toc": { "get": { "operationId": "getDocumentToc", "summary": "Get the table of contents for a document.", "description": "Get the table of contents for a document.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Table of contents", "content": { "application/json": { "schema": { "type": "object", "properties": { "toc": { "type": "array", "items": { "type": "object", "properties": { "heading": { "type": "string" }, "level": { "type": "integer" }, "anchor": { "type": "string" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/sections/{name}": { "get": { "operationId": "getDocumentSection", "summary": "Get a named section from a document.", "description": "Get a named section from a document.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "name", "in": "path", "description": "Section heading identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Named section content", "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "content": { "type": "string" }, "tokenCount": { "type": "integer" } } } } } }, "404": { "description": "Document or section not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/search": { "get": { "operationId": "getDocumentSearch", "summary": "Full-text search within a document.", "description": "Full-text search within a document.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Search results within document", "content": { "application/json": { "schema": { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object", "properties": { "section": { "type": "string" }, "excerpt": { "type": "string" }, "score": { "type": "number" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/raw": { "get": { "operationId": "getDocumentRaw", "summary": "Fetch a document's raw (unformatted) content.", "description": "Fetch a document's raw (unformatted) content.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Raw document content", "content": { "text/plain": { "schema": { "type": "string" } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/batch": { "post": { "operationId": "postDocumentBatch", "summary": "Batch-fetch multiple sections from a document.", "description": "Batch-fetch multiple sections from a document.", "tags": [ "disclosure" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Batch section results", "content": { "application/json": { "schema": { "type": "object", "properties": { "sections": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "content": { "type": "string" }, "tokenCount": { "type": "integer" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/sections/{sid}/crdt-state": { "get": { "operationId": "getSectionCrdtState", "summary": "Get the current CRDT state for a document section (HTTP fallback).", "description": "Get the current CRDT state for a document section (HTTP fallback).", "tags": [ "crdt" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "CRDT state (base64-encoded)", "content": { "application/json": { "schema": { "type": "object", "properties": { "state": { "type": "string", "description": "base64-encoded CRDT state vector" } } } } } }, "404": { "description": "Document or section not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/sections/{sid}/crdt-update": { "post": { "operationId": "postSectionCrdtUpdate", "summary": "Apply a CRDT update to a document section (HTTP fallback for WebSocket).", "description": "Apply a CRDT update to a document section (HTTP fallback for WebSocket).", "tags": [ "crdt" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "CRDT update applied", "content": { "application/json": { "schema": { "type": "object", "properties": { "applied": { "type": "boolean" } } } } } }, "400": { "description": "Invalid update payload", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document or section not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/documents/{slug}/sections/{sid}/collab": { "get": { "operationId": "wsDocumentSectionCollab", "summary": "WebSocket endpoint for real-time CRDT collaboration on a document section. Subprotocol: `yjs-sync-v1`. Auth via `?token=` query param or session cookie. Unauthenticated connections are closed with code 4401.", "description": "WebSocket endpoint for real-time CRDT collaboration on a document section. Subprotocol: `yjs-sync-v1`. Auth via `?token=` query param or session cookie. Unauthenticated connections are closed with code 4401.", "tags": [ "crdt" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "101": { "description": "WebSocket upgrade — CRDT collaboration session" }, "401": { "description": "Unauthenticated (WS close code 4401)" }, "403": { "description": "Forbidden — insufficient role (WS close code 4403)" } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/v1/documents/{slug}/presence": { "get": { "operationId": "getDocumentPresence", "summary": "Get all agents currently active in a document (within the last 30 seconds).", "description": "Get all agents currently active in a document (within the last 30 seconds).", "tags": [ "presence" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Active agents in document", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "agentId": { "type": "string" }, "section": { "type": "string" }, "cursorOffset": { "type": "integer" }, "lastSeen": { "type": "string", "format": "date-time" } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/documents/{slug}/sections/{sid}/lease": { "post": { "operationId": "postSectionLease", "summary": "Acquire an exclusive write lease on a document section.", "description": "Acquire an exclusive write lease on a document section.", "tags": [ "leases" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Lease acquired", "content": { "application/json": { "schema": { "type": "object", "properties": { "leaseId": { "type": "string" }, "agentId": { "type": "string" }, "expiresAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "409": { "description": "Section already leased by another agent", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "get": { "operationId": "getSectionLease", "summary": "Get the current lease holder for a document section.", "description": "Get the current lease holder for a document section.", "tags": [ "leases" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Current lease holder (or null)", "content": { "application/json": { "schema": { "type": "object", "properties": { "leaseId": { "type": "string", "nullable": true }, "agentId": { "type": "string" }, "expiresAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "delete": { "operationId": "deleteSectionLease", "summary": "Release a lease on a document section.", "description": "Release a lease on a document section.", "tags": [ "leases" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Lease released", "content": { "application/json": { "schema": { "type": "object", "properties": { "released": { "type": "boolean" } } } } } }, "404": { "description": "Lease not found or not owned by caller", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "patch": { "operationId": "patchSectionLease", "summary": "Renew (heartbeat) a lease on a document section.", "description": "Renew (heartbeat) a lease on a document section.", "tags": [ "leases" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "sid", "in": "path", "description": "Section identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Lease renewed", "content": { "application/json": { "schema": { "type": "object", "properties": { "leaseId": { "type": "string" }, "expiresAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Lease not found or expired", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/documents/{slug}/scratchpad": { "post": { "operationId": "postDocumentScratchpad", "summary": "Write to an agent's scratchpad within a document.", "description": "Write to an agent's scratchpad within a document.", "tags": [ "scratchpad" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Scratchpad entry created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "agentId": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "get": { "operationId": "getDocumentScratchpad", "summary": "Read all scratchpad entries for a document (optionally filtered by agent).", "description": "Read all scratchpad entries for a document (optionally filtered by agent).", "tags": [ "scratchpad" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Scratchpad entries", "content": { "application/json": { "schema": { "type": "object", "properties": { "entries": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "agentId": { "type": "string" }, "content": { "type": "string" }, "section": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/documents/{slug}/scratchpad/stream": { "get": { "operationId": "getDocumentScratchpadStream", "summary": "Server-sent events stream of new scratchpad entries.", "description": "Server-sent events stream of new scratchpad entries.", "tags": [ "scratchpad" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "SSE stream of scratchpad entries", "content": { "text/event-stream": { "schema": { "type": "string" } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/documents/{slug}/bft/vote": { "post": { "operationId": "postBftVote", "summary": "Submit a BFT consensus vote for a document section.", "description": "Submit a BFT consensus vote for a document section.", "tags": [ "bft" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "BFT vote submitted", "content": { "application/json": { "schema": { "type": "object", "properties": { "voteId": { "type": "string" }, "status": { "type": "string", "enum": [ "pending", "consensus", "byzantine" ] } } } } } }, "400": { "description": "Invalid vote payload", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/bft/status": { "get": { "operationId": "getBftStatus", "summary": "Get BFT consensus status for a document.", "description": "Get BFT consensus status for a document.", "tags": [ "bft" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "BFT consensus status", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string", "enum": [ "pending", "consensus", "byzantine" ] }, "votes": { "type": "integer" }, "quorum": { "type": "integer" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/chain": { "get": { "operationId": "getDocumentChain", "summary": "Get the BFT hash chain for audit verification.", "description": "Get the BFT hash chain for audit verification.", "tags": [ "bft" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "BFT hash chain for audit", "content": { "application/json": { "schema": { "type": "object", "properties": { "chain": { "type": "array", "items": { "type": "object", "properties": { "blockIndex": { "type": "integer" }, "hash": { "type": "string" }, "prevHash": { "type": "string" }, "agentId": { "type": "string" }, "timestamp": { "type": "string", "format": "date-time" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/agents/{id}/inbox": { "post": { "operationId": "postAgentInbox", "summary": "Send a message to an agent's inbox.", "description": "Send a message to an agent's inbox.", "tags": [ "a2a" ], "parameters": [ { "name": "id", "in": "path", "description": "Agent identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Message queued", "content": { "application/json": { "schema": { "type": "object", "properties": { "messageId": { "type": "string" }, "queued": { "type": "boolean" } } } } } }, "404": { "description": "Agent not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "get": { "operationId": "getAgentInbox", "summary": "Read messages from an agent's inbox (poll).", "description": "Read messages from an agent's inbox (poll).", "tags": [ "a2a" ], "parameters": [ { "name": "id", "in": "path", "description": "Agent identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Agent inbox messages", "content": { "application/json": { "schema": { "type": "object", "properties": { "messages": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "from": { "type": "string" }, "content": { "type": "string" }, "replyTo": { "type": "string" }, "ts": { "type": "string", "format": "date-time" } } } }, "count": { "type": "integer" } } } } } }, "404": { "description": "Agent not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/events": { "get": { "operationId": "getDocumentEvents", "summary": "Get the event log for a document (paginated).", "description": "Get the event log for a document (paginated).", "tags": [ "events" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Document event log", "content": { "application/json": { "schema": { "type": "object", "properties": { "events": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" }, "agentId": { "type": "string" }, "ts": { "type": "string", "format": "date-time" }, "payload": { "type": "object" } } } }, "total": { "type": "integer" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/events/stream": { "get": { "operationId": "getDocumentEventsStream", "summary": "Subscribe to document events as a server-sent event stream.", "description": "Subscribe to document events as a server-sent event stream.", "tags": [ "events" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "SSE stream of document events", "content": { "text/event-stream": { "schema": { "type": "string" } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/v1/subscribe": { "get": { "operationId": "getSubscribe", "summary": "Subscribe to global document events via SSE.", "description": "Subscribe to global document events via SSE.", "tags": [ "events" ], "parameters": [], "responses": { "200": { "description": "SSE stream of global events", "content": { "text/event-stream": { "schema": { "type": "string" } } } } } } }, "/api/signed-urls": { "post": { "operationId": "postSignedUrl", "summary": "Generate a time-limited signed URL for unauthenticated document access.", "description": "Generate a time-limited signed URL for unauthenticated document access.", "tags": [ "signed-urls" ], "parameters": [], "responses": { "201": { "description": "Signed URL generated", "content": { "application/json": { "schema": { "type": "object", "properties": { "url": { "type": "string", "format": "uri" }, "expiresAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/merge": { "post": { "operationId": "postDocumentMerge", "summary": "Three-way merge two document versions with a common ancestor.", "description": "Three-way merge two document versions with a common ancestor.", "tags": [ "merge" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Merged document", "content": { "application/json": { "schema": { "type": "object", "properties": { "merged": { "type": "string" }, "conflicts": { "type": "integer" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "409": { "description": "Unresolvable conflict detected", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/patch": { "post": { "operationId": "postDocumentPatch", "summary": "Apply a patch to a document.", "description": "Apply a patch to a document.", "tags": [ "merge" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Patch applied", "content": { "application/json": { "schema": { "type": "object", "properties": { "versionNumber": { "type": "integer" }, "applied": { "type": "boolean" } } } } } }, "400": { "description": "Patch failed to apply cleanly", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/search": { "post": { "operationId": "postSearch", "summary": "Cross-document semantic search.", "description": "Cross-document semantic search.", "tags": [ "search" ], "parameters": [], "responses": { "200": { "description": "Cross-document search results", "content": { "application/json": { "schema": { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object", "properties": { "slug": { "type": "string" }, "excerpt": { "type": "string" }, "score": { "type": "number" }, "format": { "type": "string" } } } } } } } } } } } }, "/api/documents/{slug}/links": { "get": { "operationId": "getDocumentLinks", "summary": "List outgoing links from a document.", "description": "List outgoing links from a document.", "tags": [ "cross-doc" ], "parameters": [ { "name": "slug", "in": "path", "description": "Source document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Outgoing document links", "content": { "application/json": { "schema": { "type": "object", "properties": { "links": { "type": "array", "items": { "type": "object", "properties": { "targetSlug": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "post": { "operationId": "postDocumentLink", "summary": "Create a link between two documents.", "description": "Create a link between two documents.", "tags": [ "cross-doc" ], "parameters": [ { "name": "slug", "in": "path", "description": "Source document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Link created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "sourceSlug": { "type": "string" }, "targetSlug": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "404": { "description": "Source or target document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/links/{linkId}": { "delete": { "operationId": "deleteDocumentLink", "summary": "Delete a link between documents.", "description": "Delete a link between documents.", "tags": [ "cross-doc" ], "parameters": [ { "name": "slug", "in": "path", "description": "Source document identifier", "schema": { "type": "string" }, "required": true }, { "name": "linkId", "in": "path", "description": "Link record ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Link deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "deleted": { "type": "boolean" } } } } } }, "404": { "description": "Link not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/graph": { "get": { "operationId": "getGraph", "summary": "Get the cross-document relationship graph.", "description": "Get the cross-document relationship graph.", "tags": [ "cross-doc" ], "parameters": [], "responses": { "200": { "description": "Cross-document relationship graph", "content": { "application/json": { "schema": { "type": "object", "properties": { "nodes": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" } } } }, "edges": { "type": "array", "items": { "type": "object", "properties": { "source": { "type": "string" }, "target": { "type": "string" }, "label": { "type": "string" } } } } } } } } } } } }, "/api/documents/{slug}/semantic-diff": { "post": { "operationId": "postDocumentSemanticDiff", "summary": "Compute a semantic (embedding-based) diff between two versions.", "description": "Compute a semantic (embedding-based) diff between two versions.", "tags": [ "semantic" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Semantic diff results", "content": { "application/json": { "schema": { "type": "object", "properties": { "sections": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "similarity": { "type": "number" }, "changed": { "type": "boolean" } } } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/semantic-similarity": { "get": { "operationId": "getDocumentSemanticSimilarity", "summary": "Compute semantic similarity between two documents.", "description": "Compute semantic similarity between two documents.", "tags": [ "semantic" ], "parameters": [ { "name": "slug", "in": "path", "description": "Source document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Cosine similarity score", "content": { "application/json": { "schema": { "type": "object", "properties": { "similarity": { "type": "number" } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/semantic-consensus": { "post": { "operationId": "postDocumentSemanticConsensus", "summary": "Run a semantic consensus check across multiple agent versions.", "description": "Run a semantic consensus check across multiple agent versions.", "tags": [ "semantic" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Semantic consensus result", "content": { "application/json": { "schema": { "type": "object", "properties": { "consensus": { "type": "boolean" }, "score": { "type": "number" }, "divergentAgents": { "type": "array", "items": { "type": "string" } } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/.well-known/agents/{id}": { "get": { "operationId": "getWellKnownAgent", "summary": "Get the well-known agent descriptor for a registered agent.", "description": "Get the well-known agent descriptor for a registered agent.", "tags": [ "agents" ], "parameters": [ { "name": "id", "in": "path", "description": "Agent identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Agent descriptor", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "capabilities": { "type": "array", "items": { "type": "string" } }, "protocols": { "type": "array", "items": { "type": "string" } }, "publicKey": { "type": "string" } } } } } }, "404": { "description": "Agent not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/webhooks": { "post": { "operationId": "postWebhook", "summary": "Register a new webhook endpoint.", "description": "Register a new webhook endpoint.", "tags": [ "webhooks" ], "parameters": [], "responses": { "201": { "description": "Webhook registered", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "events": { "type": "array", "items": { "type": "string" } }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "400": { "description": "Invalid URL or event types", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] }, "get": { "operationId": "getWebhooks", "summary": "List all webhooks for the authenticated user.", "description": "List all webhooks for the authenticated user.", "tags": [ "webhooks" ], "parameters": [], "responses": { "200": { "description": "Webhook list", "content": { "application/json": { "schema": { "type": "object", "properties": { "webhooks": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "events": { "type": "array", "items": { "type": "string" } }, "createdAt": { "type": "string", "format": "date-time" }, "lastDelivery": { "type": "string", "format": "date-time", "nullable": true } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/webhooks/{id}": { "delete": { "operationId": "deleteWebhook", "summary": "Delete a webhook by ID.", "description": "Delete a webhook by ID.", "tags": [ "webhooks" ], "parameters": [ { "name": "id", "in": "path", "description": "Webhook ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Webhook deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "deleted": { "type": "boolean" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Webhook not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/documents/{slug}/access": { "get": { "operationId": "getDocumentAccess", "summary": "Get the access control list (ACL) for a document.", "description": "Get the access control list (ACL) for a document.", "tags": [ "access-control" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Document ACL", "content": { "application/json": { "schema": { "type": "object", "properties": { "roles": { "type": "array", "items": { "type": "object", "properties": { "userId": { "type": "string" }, "role": { "type": "string", "enum": [ "viewer", "editor", "admin" ] } } } }, "visibility": { "type": "string", "enum": [ "public", "private" ] } } } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "post": { "operationId": "postDocumentAccess", "summary": "Grant a role to a user on a document.", "description": "Grant a role to a user on a document.", "tags": [ "access-control" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Role granted", "content": { "application/json": { "schema": { "type": "object", "properties": { "userId": { "type": "string" }, "role": { "type": "string" }, "grantedAt": { "type": "string", "format": "date-time" } } } } } }, "403": { "description": "Only document owners can grant roles", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/documents/{slug}/access/{userId}": { "delete": { "operationId": "deleteDocumentAccess", "summary": "Revoke a user's role on a document.", "description": "Revoke a user's role on a document.", "tags": [ "access-control" ], "parameters": [ { "name": "slug", "in": "path", "description": "Document identifier", "schema": { "type": "string" }, "required": true }, { "name": "userId", "in": "path", "description": "User ID to revoke", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Role revoked", "content": { "application/json": { "schema": { "type": "object", "properties": { "revoked": { "type": "boolean" } } } } } }, "404": { "description": "Role not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/organizations": { "post": { "operationId": "postOrganization", "summary": "Create a new organization.", "description": "Create a new organization.", "tags": [ "organizations" ], "parameters": [], "responses": { "201": { "description": "Organization created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] }, "get": { "operationId": "getOrganizations", "summary": "List organizations the authenticated user belongs to.", "description": "List organizations the authenticated user belongs to.", "tags": [ "organizations" ], "parameters": [], "responses": { "200": { "description": "Organization list", "content": { "application/json": { "schema": { "type": "object", "properties": { "organizations": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "role": { "type": "string" } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/organizations/{slug}": { "get": { "operationId": "getOrganization", "summary": "Get an organization by slug.", "description": "Get an organization by slug.", "tags": [ "organizations" ], "parameters": [ { "name": "slug", "in": "path", "description": "Organization slug", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Organization details", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "members": { "type": "array", "items": { "type": "object", "properties": { "userId": { "type": "string" }, "role": { "type": "string", "enum": [ "member", "admin" ] } } } } } } } } }, "404": { "description": "Organization not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/organizations/{slug}/members": { "post": { "operationId": "postOrganizationMember", "summary": "Add a member to an organization.", "description": "Add a member to an organization.", "tags": [ "organizations" ], "parameters": [ { "name": "slug", "in": "path", "description": "Organization slug", "schema": { "type": "string" }, "required": true } ], "responses": { "201": { "description": "Member added", "content": { "application/json": { "schema": { "type": "object", "properties": { "userId": { "type": "string" }, "role": { "type": "string" } } } } } }, "403": { "description": "Only org admins can add members", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/organizations/{slug}/members/{userId}": { "delete": { "operationId": "deleteOrganizationMember", "summary": "Remove a member from an organization.", "description": "Remove a member from an organization.", "tags": [ "organizations" ], "parameters": [ { "name": "slug", "in": "path", "description": "Organization slug", "schema": { "type": "string" }, "required": true }, { "name": "userId", "in": "path", "description": "User ID to remove", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "Member removed", "content": { "application/json": { "schema": { "type": "object", "properties": { "removed": { "type": "boolean" } } } } } }, "403": { "description": "Only org admins can remove members", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } }, "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ] } }, "/api/documents/{slug}/blobs": { "post": { "operationId": "attachBlob", "summary": "Attach a binary blob to a document.", "description": "Upload a raw binary file and attach it to a document. Auth required. Max 100 MB.", "tags": [ "blobs" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "name", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Attachment filename" }, { "name": "contentType", "in": "query", "required": false, "schema": { "type": "string" }, "description": "MIME type override" } ], "requestBody": { "required": true, "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } } }, "responses": { "201": { "description": "Blob attached", "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "hash": { "type": "string" }, "size": { "type": "integer" }, "contentType": { "type": "string" }, "attachedAt": { "type": "string", "format": "date-time" } } } } } }, "400": { "description": "Invalid blob name or payload", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "403": { "description": "Write access denied", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "413": { "description": "Blob too large (max 100 MB)", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "get": { "operationId": "listBlobs", "summary": "List blob attachments for a document (metadata only).", "tags": [ "blobs" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Blob list", "content": { "application/json": { "schema": { "type": "object", "properties": { "blobs": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "hash": { "type": "string" }, "size": { "type": "integer" }, "contentType": { "type": "string" }, "attachedAt": { "type": "string", "format": "date-time" } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/blobs/{name}": { "get": { "operationId": "downloadBlob", "summary": "Download a named blob attachment with hash verification.", "tags": [ "blobs" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "name", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Blob bytes", "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Blob not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "500": { "description": "Blob corrupted — hash mismatch", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "delete": { "operationId": "detachBlob", "summary": "Detach (soft-delete) a named blob from a document.", "tags": [ "blobs" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "name", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Blob detached", "content": { "application/json": { "schema": { "type": "object", "properties": { "detached": { "type": "boolean" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "403": { "description": "Write access denied", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Blob not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/blobs/{hash}": { "get": { "operationId": "fetchBlobByHash", "summary": "Fetch blob bytes by content-addressed SHA-256 hash.", "description": "Sync pull endpoint for P2P mesh. Requires read access to at least one document referencing the hash.", "tags": [ "blobs" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "hash", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^[0-9a-f]{64}$" } } ], "responses": { "200": { "description": "Blob bytes", "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "403": { "description": "No document referencing this hash readable by caller", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Blob not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/documents/{slug}/export": { "get": { "operationId": "exportDocument", "summary": "Export a document in one of four canonical formats.", "tags": [ "export" ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "format", "in": "query", "required": false, "schema": { "type": "string", "enum": [ "markdown", "json", "text", "llmtxt" ], "default": "llmtxt" } } ], "responses": { "200": { "description": "Exported document content", "content": { "text/markdown": { "schema": { "type": "string" } }, "application/json": { "schema": { "type": "object" } }, "text/plain": { "schema": { "type": "string" } } } }, "404": { "description": "Document not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/collections": { "post": { "operationId": "createCollection", "summary": "Create a named collection of documents.", "tags": [ "collections" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "slug": { "type": "string" }, "description": { "type": "string" } } } } } }, "responses": { "201": { "description": "Collection created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "get": { "operationId": "listCollections", "summary": "List all collections accessible to the authenticated user.", "tags": [ "collections" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [], "responses": { "200": { "description": "Collection list", "content": { "application/json": { "schema": { "type": "object", "properties": { "collections": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "documentCount": { "type": "integer" }, "createdAt": { "type": "string", "format": "date-time" } } } } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/collections/{slug}": { "get": { "operationId": "getCollection", "summary": "Get a collection and its document list.", "tags": [ "collections" ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Collection details", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "slug": { "type": "string" }, "name": { "type": "string" }, "documents": { "type": "array", "items": { "type": "object" } } } } } } }, "404": { "description": "Collection not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "delete": { "operationId": "deleteCollection", "summary": "Delete a collection (documents are not deleted).", "tags": [ "collections" ], "security": [ { "ApiKeyAuth": [] }, { "SessionCookie": [] } ], "parameters": [ { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Collection deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "deleted": { "type": "boolean" } } } } } }, "401": { "description": "Authentication required", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } }, "404": { "description": "Collection not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } } }, "/api/retrieval": { "post": { "operationId": "retrieveDocuments", "summary": "Semantic retrieval — find documents relevant to a query.", "tags": [ "retrieval" ], "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "query" ], "properties": { "query": { "type": "string" }, "limit": { "type": "integer", "default": 10 }, "threshold": { "type": "number", "description": "Minimum similarity score (0–1)" } } } } } }, "responses": { "200": { "description": "Retrieval results", "content": { "application/json": { "schema": { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object", "properties": { "slug": { "type": "string" }, "score": { "type": "number" }, "excerpt": { "type": "string" } } } } } } } } } } } }, "/api/auth/session": { "get": { "operationId": "getSession", "summary": "Get the current authenticated session.", "tags": [ "auth" ], "security": [ { "SessionCookie": [] } ], "parameters": [], "responses": { "200": { "description": "Session info", "content": { "application/json": { "schema": { "type": "object", "properties": { "userId": { "type": "string" }, "email": { "type": "string", "format": "email" }, "createdAt": { "type": "string", "format": "date-time" } } } } } }, "401": { "description": "Not authenticated", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" }, "statusCode": { "type": "integer" } }, "required": [ "error" ] } } } } } }, "delete": { "operationId": "signOut", "summary": "Sign out and invalidate the current session.", "tags": [ "auth" ], "security": [ { "SessionCookie": [] } ], "parameters": [], "responses": { "200": { "description": "Signed out", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" } } } } } } } } } }, "components": { "schemas": { "User": { "type": "object" }, "NewUser": { "type": "object" }, "Session": { "type": "object" }, "NewSession": { "type": "object" }, "Document": { "type": "object" }, "NewDocument": { "type": "object" }, "Version": { "type": "object" }, "NewVersion": { "type": "object" }, "StateTransition": { "type": "object" }, "NewStateTransition": { "type": "object" }, "Approval": { "type": "object" }, "NewApproval": { "type": "object" }, "Contributor": { "type": "object" }, "NewContributor": { "type": "object" }, "SignedUrlToken": { "type": "object" }, "NewSignedUrlToken": { "type": "object" }, "VersionAttribution": { "type": "object" }, "NewVersionAttribution": { "type": "object" }, "ApiKey": { "type": "object" }, "NewApiKey": { "type": "object" }, "AuditLog": { "type": "object" }, "NewAuditLog": { "type": "object" }, "DocumentRole": { "type": "object" }, "NewDocumentRole": { "type": "object" }, "Organization": { "type": "object" }, "NewOrganization": { "type": "object" }, "OrgMember": { "type": "object" }, "NewOrgMember": { "type": "object" }, "DocumentOrg": { "type": "object" }, "NewDocumentOrg": { "type": "object" }, "PendingInvite": { "type": "object" }, "NewPendingInvite": { "type": "object" }, "Webhook": { "type": "object" }, "NewWebhook": { "type": "object" }, "DocumentLink": { "type": "object" }, "NewDocumentLink": { "type": "object" }, "Collection": { "type": "object" }, "NewCollection": { "type": "object" }, "CollectionDocument": { "type": "object" }, "NewCollectionDocument": { "type": "object" }, "SectionCrdtState": { "type": "object" }, "NewSectionCrdtState": { "type": "object" }, "SectionCrdtUpdate": { "type": "object" }, "NewSectionCrdtUpdate": { "type": "object" }, "DocumentEvent": { "type": "object" }, "NewDocumentEvent": { "type": "object" }, "AgentPubkey": { "type": "object" }, "NewAgentPubkey": { "type": "object" }, "AgentSignatureNonce": { "type": "object" }, "NewAgentSignatureNonce": { "type": "object" }, "InsertUser": { "type": "object" }, "SelectUser": { "type": "object" }, "InsertSession": { "type": "object" }, "SelectSession": { "type": "object" }, "InsertDocument": { "type": "object" }, "SelectDocument": { "type": "object" }, "InsertVersion": { "type": "object" }, "SelectVersion": { "type": "object" }, "InsertStateTransition": { "type": "object" }, "SelectStateTransition": { "type": "object" }, "InsertApproval": { "type": "object" }, "SelectApproval": { "type": "object" }, "InsertContributor": { "type": "object" }, "SelectContributor": { "type": "object" }, "InsertSignedUrlToken": { "type": "object" }, "SelectSignedUrlToken": { "type": "object" }, "InsertVersionAttribution": { "type": "object" }, "SelectVersionAttribution": { "type": "object" }, "InsertApiKey": { "type": "object" }, "SelectApiKey": { "type": "object" }, "InsertAuditLog": { "type": "object" }, "SelectAuditLog": { "type": "object" }, "InsertDocumentRole": { "type": "object" }, "SelectDocumentRole": { "type": "object" }, "InsertOrganization": { "type": "object" }, "SelectOrganization": { "type": "object" }, "InsertOrgMember": { "type": "object" }, "SelectOrgMember": { "type": "object" }, "InsertDocumentOrg": { "type": "object" }, "SelectDocumentOrg": { "type": "object" }, "InsertPendingInvite": { "type": "object" }, "SelectPendingInvite": { "type": "object" }, "InsertWebhook": { "type": "object" }, "SelectWebhook": { "type": "object" }, "InsertDocumentLink": { "type": "object" }, "SelectDocumentLink": { "type": "object" }, "InsertCollection": { "type": "object" }, "SelectCollection": { "type": "object" }, "InsertCollectionDocument": { "type": "object" }, "SelectCollectionDocument": { "type": "object" }, "SectionLease": { "type": "object" }, "NewSectionLease": { "type": "object" }, "AgentInboxMessage": { "type": "object" }, "NewAgentInboxMessage": { "type": "object" }, "SectionEmbedding": { "type": "object" }, "NewSectionEmbedding": { "type": "object" }, "InsertSectionCrdtState": { "type": "object" }, "SelectSectionCrdtState": { "type": "object" }, "InsertSectionCrdtUpdate": { "type": "object" }, "SelectSectionCrdtUpdate": { "type": "object" }, "InsertDocumentEvent": { "type": "object" }, "SelectDocumentEvent": { "type": "object" }, "InsertAgentPubkey": { "type": "object" }, "SelectAgentPubkey": { "type": "object" }, "InsertAgentSignatureNonce": { "type": "object" }, "SelectAgentSignatureNonce": { "type": "object" }, "DocumentEventLogType": { "oneOf": [ { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" } ] }, "AppendDocumentEventInput": { "type": "object", "properties": { "documentId": { "type": "string", "description": "FK → documents.slug (the public-facing identifier)." }, "eventType": { "oneOf": [ { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" }, { "type": "object" } ] }, "actorId": { "type": "string", "description": "Actor/user/agent that triggered this event." }, "payloadJson": { "type": "object", "additionalProperties": {}, "description": "Event-specific payload. Must be JSON-serialisable." }, "idempotencyKey": { "type": "string", "description": "Optional idempotency key from the Idempotency-Key request header." } }, "required": [ "documentId", "eventType", "actorId", "payloadJson", "idempotencyKey" ] }, "AppendDocumentEventRow": { "type": "object", "properties": { "id": { "type": "string" }, "documentId": { "type": "string" }, "seq": { "type": "object" }, "eventType": { "type": "string" }, "actorId": { "type": "string" }, "payloadJson": {}, "idempotencyKey": { "type": "string" }, "createdAt": { "type": "object" }, "prevHash": { "type": "object" } }, "required": [ "id", "documentId", "seq", "eventType", "actorId", "payloadJson", "idempotencyKey", "createdAt", "prevHash" ] }, "AppendDocumentEventResult": { "type": "object", "properties": { "event": { "type": "object", "description": "The inserted (or pre-existing) event row." }, "duplicated": { "type": "boolean", "description": "true when the idempotency key matched an existing row; no insert occurred." } }, "required": [ "event", "duplicated" ] }, "ChainValidationResult": { "type": "object", "properties": { "valid": { "type": "boolean" }, "checkedRows": { "type": "number" }, "firstBrokenSeq": { "type": "object" }, "error": { "type": "string" } }, "required": [ "valid", "checkedRows", "firstBrokenSeq", "error" ] }, "DocumentEventRow": { "type": "object", "properties": { "id": { "type": "string" }, "documentId": { "type": "string" }, "seq": { "type": "object" }, "eventType": { "type": "string" }, "actorId": { "type": "string" }, "payloadJson": {}, "idempotencyKey": { "type": "string" }, "createdAt": { "type": "object" } }, "required": [ "id", "documentId", "seq", "eventType", "actorId", "payloadJson", "idempotencyKey", "createdAt" ] }, "SectionDelta": { "type": "object", "properties": { "added": { "type": "array", "items": { "type": "string" } }, "modified": { "type": "array", "items": { "type": "object" } }, "deleted": { "type": "array", "items": { "type": "string" } }, "fromSeq": { "type": "number" }, "toSeq": { "type": "number" } }, "required": [ "added", "modified", "deleted", "fromSeq", "toSeq" ] }, "EmbeddingProvider": { "type": "object", "properties": { "dimensions": { "type": "number", "description": "Dimensionality of produced vectors." }, "model": { "type": "string", "description": "Model name for logging/observability." } }, "required": [ "dimensions", "model" ] }, "OpenAIEmbeddingProvider": { "description": "OpenAI `text-embedding-3-small` provider. Handles: - Batching (≤ 2 048 inputs per request) - Exponential back-off on 429 / 5xx responses - Result reordering by the index returned in the API response", "type": "object", "properties": { "dimensions": { "type": "object" }, "model": { "type": "object" } }, "required": [ "dimensions", "model" ] }, "LocalEmbeddingProvider": { "description": "Lightweight TF-IDF vectorizer for offline / dev use. Delegates to `crates/llmtxt-core::tfidf::tfidf_embed_batch_wasm` via the `llmtxt` WASM binding (audit item #15 fix). The algorithm is identical to the previous TypeScript implementation: 1. Tokenise into lowercase word unigrams + bigrams. 2. Build global vocabulary, compute TF, IDF (smooth), project via FNV-1a. 3. L2-normalise. This is intentionally approximate — sufficient for testing and development, NOT a replacement for neural embeddings in production.", "type": "object", "properties": { "dimensions": { "type": "object" }, "model": { "type": "object" } }, "required": [ "dimensions", "model" ] }, "PresenceEntry": { "type": "object", "properties": { "section": { "type": "string" }, "cursorOffset": { "type": "number" }, "lastSeen": { "type": "number" } }, "required": [ "section", "cursorOffset", "lastSeen" ] }, "PresenceRecord": { "type": "object", "properties": { "agentId": { "type": "string" }, "section": { "type": "string" }, "cursorOffset": { "type": "number" }, "lastSeen": { "type": "number" } }, "required": [ "agentId", "section", "cursorOffset", "lastSeen" ] }, "PresenceRegistry": { "type": "object", "properties": { "registry": { "type": "object", "description": "MapdocId, MapagentId, PresenceEntry" } }, "required": [ "registry" ] }, "PersistResult": { "type": "object", "properties": { "seq": { "type": "object" }, "newState": { "type": "object" } }, "required": [ "seq", "newState" ] }, "Lease": { "type": "object", "properties": { "id": { "type": "string" }, "docId": { "type": "string" }, "sectionId": { "type": "string" }, "holderAgentId": { "type": "string" }, "acquiredAt": { "type": "object" }, "expiresAt": { "type": "object" }, "reason": { "type": "string" } }, "required": [ "id", "docId", "sectionId", "holderAgentId", "acquiredAt", "expiresAt", "reason" ] }, "ScratchpadMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Server-assigned stream message ID (e.g. \"1700000000000-0\")." }, "agentId": { "type": "string", "description": "Agent identifier of the sender." }, "content": { "type": "string", "description": "Message content body." }, "contentType": { "type": "string", "description": "MIME content type (default: \"text/plain\")." }, "threadId": { "type": "string", "description": "Optional thread identifier for reply chains." }, "sigHex": { "type": "string", "description": "Optional Ed25519 signature over canonical message bytes." }, "timestampMs": { "type": "number", "description": "Unix ms timestamp of the message." } }, "required": [ "id", "agentId", "content", "contentType", "threadId", "sigHex", "timestampMs" ] }, "PublishOptions": { "type": "object", "properties": { "agentId": { "type": "string" }, "content": { "type": "string" }, "contentType": { "type": "string" }, "threadId": { "type": "string" }, "sigHex": { "type": "string" } }, "required": [ "agentId", "content", "contentType", "threadId", "sigHex" ] }, "ReadOptions": { "type": "object", "properties": { "threadId": { "type": "string", "description": "Only return messages in this thread." }, "lastId": { "type": "string", "description": "Return messages after this stream ID (exclusive)." }, "limit": { "type": "number", "description": "Maximum number of messages to return. Default 100." } }, "required": [ "threadId", "lastId", "limit" ] }, "TestDbContext": { "type": "object", "properties": { "db": {}, "sqlite": {}, "provider": { "oneOf": [ { "type": "object" }, { "type": "object" } ], "description": "Provider in use for this context." }, "cleanup": { "type": "object", "description": "Cleanup — drops the test schema (PG) or closes the connection (SQLite)." } }, "required": [ "db", "sqlite", "provider", "cleanup" ] } }, "securitySchemes": { "ApiKeyAuth": { "type": "http", "scheme": "bearer", "description": "API key issued by POST /api/keys. Pass as `Authorization: Bearer llmtxt_`." }, "SessionCookie": { "type": "apiKey", "in": "cookie", "name": "llmtxt_session", "description": "Session cookie set by the auth provider (Better Auth / OAuth)." }, "AgentSignature": { "type": "apiKey", "in": "header", "name": "X-Agent-Signature", "description": "Ed25519 signature of the request. Used together with X-Agent-Pubkey-Id, X-Agent-Nonce, X-Agent-Timestamp." } } }, "servers": [ { "url": "https://api.llmtxt.my", "description": "Production" }, { "url": "http://localhost:3000", "description": "Local dev" } ] }