{ "openapi": "3.0.3", "info": { "title": "Agent Memory API", "version": "1.0.0-phase4", "description": "Universal AI Agent Memory platform, phases 1-4: memories with revisions and verification, sessions with checkpoints, Markdown/text document ingestion with chunk locators, lexical search and recall, health. Authenticate with `Authorization: Bearer `; the tenant is derived from the key. Anything the caller cannot see is reported as 404. Phase 3: POST /context assembles a budgeted task briefing. Retrieval is hybrid (lexical + embeddings via a local Ollama model and a Qdrant index) and degrades to lexical with a warning. Relevance scores are ranking signals: negated bm25 when lexical, reciprocal-rank-fusion values when hybrid. Learning loop: experiences (POST /sessions/{id}/events), candidates proposed with POST /learn and reviewed by another principal (POST /candidates/{id}/review), evidence (GET /memories/{id}/sources) and feedback on retrieval results (POST /feedback, using the query_id of recall/search/context). Phase 4: HTML ingestion (format html), entities and typed, evidence-backed relationships between entities, memories and documents (POST /relate, reviewed like candidates) and bounded traversal (POST /graph/traverse) that never reveals what the caller cannot read." }, "servers": [ { "url": "/api/v1" } ], "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } }, "schemas": { "Error": { "type": "object", "properties": { "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "string" } }, "request_id": { "type": "string" } } } } }, "RememberRequest": { "type": "object", "required": [ "namespace_id", "type", "title", "content" ], "properties": { "namespace_id": { "type": "string", "format": "uuid" }, "type": { "type": "string", "enum": [ "working", "episodic", "semantic", "procedural", "preference", "decision", "constraint", "lesson", "hypothesis", "goal", "solution" ] }, "title": { "type": "string", "maxLength": 200 }, "content": { "type": "string", "maxLength": 100000 }, "summary": { "type": "string", "maxLength": 2000, "nullable": true }, "tags": { "type": "array", "items": { "type": "string", "maxLength": 64 }, "maxItems": 32 }, "attributes": { "type": "object", "description": "Free-form JSON object, max 16 KB" }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 }, "importance": { "type": "number", "minimum": 0, "maximum": 1 } } }, "RememberResponse": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "revision": { "type": "integer" }, "status": { "type": "string" }, "verification_status": { "type": "string" }, "indexing_status": { "type": "string", "example": "not_indexed" }, "duplicate": { "type": "boolean", "description": "true when an identical active memory already existed (HTTP 200)" } } }, "Memory": { "type": "object", "properties": { "id": { "type": "string" }, "namespace_id": { "type": "string" }, "type": { "type": "string" }, "status": { "type": "string", "enum": [ "active", "retired", "superseded" ] }, "current_revision": { "type": "integer" }, "revision": { "type": "integer" }, "verification_status": { "type": "string", "enum": [ "unverified", "verified", "disputed", "rejected" ] }, "title": { "type": "string" }, "summary": { "type": "string", "nullable": true }, "content": { "type": "string" }, "attributes": { "type": "object", "nullable": true }, "tags": { "type": "array", "items": { "type": "string" } }, "confidence": { "type": "number", "nullable": true }, "importance": { "type": "number", "nullable": true }, "change_reason": { "type": "string", "nullable": true }, "created_by": { "type": "string" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" } } }, "IngestRequest": { "type": "object", "required": [ "namespace_id", "content" ], "properties": { "namespace_id": { "type": "string", "format": "uuid" }, "title": { "type": "string", "maxLength": 200, "description": "Optional for html: defaults to the page . Required for markdown and text." }, "content": { "type": "string", "maxLength": 262144 }, "format": { "type": "string", "enum": [ "markdown", "text", "html" ], "default": "markdown", "description": "markdown (default), text or html. html is converted to Markdown before it is stored (script, style, comments, nav and other invisible content removed; headings, lists, tables and pre kept; entities decoded) and the document is stored with format markdown; the response then has source_format html. Nothing referenced by the page is fetched." }, "source_uri": { "type": "string", "maxLength": 500, "description": "Identifier only; never fetched. The same source_uri in a namespace is one document." }, "async": { "type": "boolean", "default": false, "description": "true: store the job and answer 202 at once; the worker processes it (poll GET /jobs/{id}). false: processed inside the request (201 new revision, 200 unchanged)." } } }, "JobQueued": { "type": "object", "properties": { "job": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "type": { "type": "string" }, "state": { "type": "string", "enum": [ "queued" ] } } }, "status_url": { "type": "string" } } }, "Job": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "type": { "type": "string", "enum": [ "ingest" ] }, "state": { "type": "string", "enum": [ "queued", "running", "succeeded", "failed" ] }, "attempts": { "type": "integer" }, "max_attempts": { "type": "integer" }, "auto_retry": { "type": "boolean", "description": "true when the worker will retry this failed job by itself" }, "document_id": { "type": "string", "nullable": true }, "error_code": { "type": "string", "nullable": true, "description": "internal_error (retried automatically), invalid_payload, namespace_not_found, forbidden, interrupted" }, "error_message": { "type": "string", "nullable": true }, "created_at": { "type": "string" }, "updated_at": { "type": "string" } } }, "IngestResponse": { "type": "object", "properties": { "job": { "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" }, "state": { "type": "string" } } }, "document_id": { "type": "string" }, "revision": { "type": "integer" }, "chunk_count": { "type": "integer" }, "unchanged": { "type": "boolean", "description": "true when identical text was already the current revision (no new chunks)" }, "indexing_status": { "type": "string", "example": "lexical_indexed" }, "source_format": { "type": "string", "enum": [ "html" ], "description": "Present when an adapter converted the input" } } }, "SearchRequest": { "type": "object", "required": [ "query" ], "properties": { "query": { "type": "string", "maxLength": 1000 }, "namespace_ids": { "type": "array", "items": { "type": "string", "format": "uuid" } }, "max_results": { "type": "integer", "minimum": 1, "maximum": 50 }, "detail_level": { "type": "string", "enum": [ "full", "snippet" ] } } }, "RecallRequest": { "type": "object", "required": [ "query" ], "properties": { "query": { "type": "string", "maxLength": 1000 }, "namespace_ids": { "type": "array", "items": { "type": "string", "format": "uuid" } }, "types": { "type": "array", "items": { "type": "string" } }, "tags": { "type": "array", "items": { "type": "string" } }, "max_results": { "type": "integer" }, "detail_level": { "type": "string", "enum": [ "full", "summary" ] }, "verification_filter": { "type": "string", "enum": [ "verified_only", "include_unverified" ], "default": "verified_only" } } }, "VerifyRequest": { "type": "object", "required": [ "result", "method", "revision" ], "properties": { "result": { "type": "string", "enum": [ "verified", "disputed", "rejected" ] }, "method": { "type": "string", "maxLength": 200 }, "notes": { "type": "string", "maxLength": 2000 }, "revision": { "type": "integer", "description": "Must be the current revision" } } }, "SaveStateRequest": { "type": "object", "required": [ "state" ], "properties": { "state": { "type": "object", "description": "Structured working state, max 64 KB" }, "expected_revision": { "type": "integer" } } }, "ContextRequest": { "type": "object", "required": [ "task" ], "properties": { "task": { "type": "string", "maxLength": 2000, "description": "What the agent is about to do; used as the lexical query for decisions, lessons, knowledge and references." }, "namespace_ids": { "type": "array", "items": { "type": "string" }, "description": "Restrict to these namespaces (intersected with what the caller can read)." }, "session_id": { "type": "string", "description": "Include the session's latest checkpoint as working_state. 404 when the session is not visible." }, "include": { "type": "array", "items": { "type": "string", "enum": [ "constraints", "preferences", "decisions", "lessons", "knowledge", "references", "working_state" ] }, "description": "Sections to assemble (default all). Constraints and conflicts are always included." }, "verification_filter": { "type": "string", "enum": [ "verified_only", "include_unverified" ], "default": "verified_only" }, "detail_level": { "type": "string", "enum": [ "full", "summary" ], "default": "full", "description": "summary returns the stored summary (or first 240 characters); constraints are always full." }, "max_context_tokens": { "type": "integer", "minimum": 100, "maximum": 32000, "default": 4000 }, "max_items": { "type": "integer", "minimum": 1, "maximum": 50, "default": 10, "description": "Per-section cap for conflicts, decisions, lessons, knowledge and unverified (preferences: 50)." }, "max_references": { "type": "integer", "minimum": 0, "maximum": 20, "default": 5 }, "format": { "type": "string", "enum": [ "structured" ], "default": "structured" } }, "example": { "task": "Implement a customer repository", "session_id": "<session id>", "include": [ "constraints", "decisions", "preferences", "lessons", "references", "working_state" ], "max_context_tokens": 4000 } }, "ContextResponse": { "type": "object", "description": "Sections in budget priority order: constraints (required), working_state, preferences, conflicts, decisions, lessons, knowledge, references, unverified. Memory items carry id, revision, type, namespace_id, title, content|summary, verification_status, content_trust (verified_memory|unverified_memory|disputed_memory), authority (policy for verified constraints), tags, confidence, importance, relevance_score (lexical matches), valid_until, provenance {created_by, updated_at} and token_estimate. References carry chunk/document ids, locator, content and content_trust untrusted_reference.", "properties": { "context_id": { "type": "string" }, "task": { "type": "string" }, "strategy": { "type": "string", "enum": [ "hybrid", "lexical" ], "description": "hybrid when semantic retrieval ran for every section; lexical (with a warning) when it is not configured or unavailable" }, "budget": { "type": "object", "properties": { "max_context_tokens": { "type": "integer" }, "used_tokens": { "type": "integer" }, "counting_method": { "type": "string", "example": "estimate_chars_div_4" }, "complete": { "type": "boolean", "description": "False when not every applicable constraint/preference could be considered; do not treat the briefing as complete." }, "truncated": { "type": "boolean", "description": "True when items were left out to fit the budget." } } }, "omitted": { "type": "object", "properties": { "over_budget": { "type": "integer" }, "over_limit": { "type": "integer" }, "duplicates": { "type": "integer" }, "unverified_excluded": { "type": "integer" } } }, "constraints": { "type": "array", "items": { "type": "object" } }, "working_state": { "type": "object", "nullable": true }, "preferences": { "type": "array", "items": { "type": "object" } }, "conflicts": { "type": "array", "items": { "type": "object" } }, "decisions": { "type": "array", "items": { "type": "object" } }, "lessons": { "type": "array", "items": { "type": "object" } }, "knowledge": { "type": "array", "items": { "type": "object" } }, "references": { "type": "array", "items": { "type": "object" } }, "unverified": { "type": "array", "items": { "type": "object" }, "description": "Only with verification_filter include_unverified." }, "warnings": { "type": "array", "items": { "type": "string" } }, "query_id": { "type": "string", "description": "Pass to POST /feedback to rate an included memory or reference" } } }, "EvidenceInput": { "type": "object", "required": [ "kind", "id" ], "properties": { "kind": { "type": "string", "enum": [ "experience", "chunk", "memory", "document" ] }, "id": { "type": "string", "format": "uuid" }, "role": { "type": "string", "enum": [ "supports", "contradicts", "context" ], "default": "supports" }, "excerpt": { "type": "string", "maxLength": 2000 } } }, "ExperienceRequest": { "type": "object", "required": [ "task", "outcome" ], "properties": { "task": { "type": "string", "maxLength": 2000 }, "outcome": { "type": "string", "enum": [ "success", "failure", "partial", "unknown" ] }, "problem": { "type": "string", "maxLength": 4000 }, "action": { "type": "string", "maxLength": 4000 }, "result": { "type": "string", "maxLength": 4000 }, "environment": { "type": "object", "description": "Free-form JSON object, max 16 KB" } } }, "Experience": { "type": "object", "properties": { "id": { "type": "string" }, "task": { "type": "string" }, "problem": { "type": "string" }, "action": { "type": "string" }, "result": { "type": "string" }, "outcome": { "type": "string" }, "recorded_by": { "type": "string" }, "created_at": { "type": "string" }, "environment": { "type": "object", "nullable": true } } }, "LearnRequest": { "type": "object", "required": [ "namespace_id", "type", "title", "content" ], "properties": { "namespace_id": { "type": "string", "format": "uuid" }, "type": { "type": "string" }, "title": { "type": "string", "maxLength": 200 }, "content": { "type": "string", "maxLength": 100000 }, "summary": { "type": "string", "maxLength": 2000 }, "tags": { "type": "array", "items": { "type": "string" }, "maxItems": 32 }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 }, "target_memory_id": { "type": "string", "format": "uuid", "description": "Propose a new revision of this memory (same namespace and type)" }, "base_revision": { "type": "integer", "description": "Required with target_memory_id: the revision the proposal is based on" }, "evidence": { "type": "array", "maxItems": 20, "items": { "$ref": "#/components/schemas/EvidenceInput" } } } }, "Candidate": { "type": "object", "properties": { "id": { "type": "string" }, "namespace_id": { "type": "string" }, "type": { "type": "string" }, "title": { "type": "string" }, "summary": { "type": "string", "nullable": true }, "content": { "type": "string", "description": "Detail only" }, "tags": { "type": "array", "items": { "type": "string" } }, "confidence": { "type": "number", "nullable": true }, "target_memory_id": { "type": "string", "nullable": true }, "base_revision": { "type": "integer", "nullable": true }, "state": { "type": "string", "enum": [ "proposed", "accepted", "rejected" ] }, "author": { "type": "string" }, "reviewer": { "type": "string", "nullable": true }, "review_notes": { "type": "string", "nullable": true }, "resulting_memory_id": { "type": "string", "nullable": true }, "resulting_revision": { "type": "integer", "nullable": true }, "created_at": { "type": "string" }, "reviewed_at": { "type": "string", "nullable": true }, "content_trust": { "type": "string", "enum": [ "proposed_knowledge" ] }, "evidence": { "type": "array", "items": { "$ref": "#/components/schemas/EvidenceItem" }, "description": "Detail only" } } }, "EvidenceItem": { "type": "object", "properties": { "kind": { "type": "string" }, "id": { "type": "string", "description": "Omitted when available is false" }, "revision": { "type": "integer", "nullable": true, "description": "Target revision pinned when the link was made" }, "available": { "type": "boolean", "description": "False when the target is gone or the caller cannot read it" }, "role": { "type": "string" }, "excerpt": { "type": "string", "nullable": true }, "content_trust": { "type": "string", "enum": [ "evidence", "untrusted_reference" ] } } }, "ReviewRequest": { "type": "object", "required": [ "decision" ], "properties": { "decision": { "type": "string", "enum": [ "accept", "reject" ] }, "notes": { "type": "string", "maxLength": 2000 }, "verify": { "type": "boolean", "default": false, "description": "Accept as verified (records a verification by the reviewer)" } } }, "Sources": { "type": "object", "properties": { "memory_id": { "type": "string" }, "revision": { "type": "integer" }, "current_revision": { "type": "integer" }, "from_candidate": { "type": "string", "nullable": true }, "evidence": { "type": "array", "items": { "$ref": "#/components/schemas/EvidenceItem" } }, "verifications": { "type": "array", "items": { "type": "object", "properties": { "method": { "type": "string" }, "result": { "type": "string" }, "notes": { "type": "string" }, "reviewer": { "type": "string" }, "created_at": { "type": "string" } } } } } }, "FeedbackRequest": { "type": "object", "required": [ "query_id", "result_id", "usefulness" ], "properties": { "query_id": { "type": "string", "description": "query_id returned by recall, search or context" }, "result_id": { "type": "string", "format": "uuid", "description": "Memory id or chunk id from that response" }, "usefulness": { "type": "string", "enum": [ "useful", "not_useful", "incorrect", "harmful" ] }, "comment": { "type": "string", "maxLength": 2000 } } }, "Feedback": { "type": "object", "properties": { "id": { "type": "string" }, "query_id": { "type": "string" }, "target_kind": { "type": "string", "enum": [ "memory", "chunk" ] }, "target_id": { "type": "string" }, "target_revision": { "type": "integer" }, "usefulness": { "type": "string" } } }, "ExportRequest": { "type": "object", "properties": { "namespace_ids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "description": "Limit the export to these namespaces (unreadable ones are skipped silently). Default: all readable namespaces." } } }, "Export": { "type": "object", "required": [ "format", "schema_version", "data", "integrity" ], "properties": { "format": { "type": "string", "enum": [ "agent-memory-export" ] }, "schema_version": { "type": "integer", "enum": [ 2 ], "description": "Imports accept versions 1 and 2." }, "exported_at": { "type": "string" }, "data": { "type": "object", "description": "namespaces [{path}], memories [{id, namespace, type, lifecycle_status, valid_from, valid_until, created_by, created_at, updated_at, current_revision, revisions[], verifications[]}], documents [{id, namespace, source_uri, format, title, current_revision, created_by, created_at, updated_at, revisions[{..., chunks[]}]}], entities [{id, namespace, type, canonical_key, name, aliases, description, properties, created_by, created_at, updated_at}] (version 2), relationships [{id, namespace, source_kind, source_id, target_kind, target_id, type, description, confidence, valid_from, valid_until, inferred, state, author, reviewer, review_notes, created_at, reviewed_at}] (version 2; only edges whose namespace and both endpoints are exported), evidence_links [{id, owner_kind (memory or relationship), owner_id, owner_revision, target_kind, target_id, target_revision, role, excerpt, created_by, created_at}]. Not exported: sessions, experiences, candidates, feedback, retrieval telemetry, audit events.", "properties": { "namespaces": { "type": "array", "items": { "type": "object" } }, "memories": { "type": "array", "items": { "type": "object" } }, "documents": { "type": "array", "items": { "type": "object" } }, "evidence_links": { "type": "array", "items": { "type": "object" } }, "entities": { "type": "array", "items": { "type": "object" } }, "relationships": { "type": "array", "items": { "type": "object" } } } }, "counts": { "type": "object", "additionalProperties": { "type": "integer" }, "description": "namespaces, memories, memory_revisions, verifications, documents, document_revisions, chunks, entities, relationships, relationships_omitted, evidence_links, evidence_links_omitted" }, "integrity": { "type": "object", "properties": { "algorithm": { "type": "string", "enum": [ "sha256" ] }, "digest": { "type": "string", "description": "Hex SHA-256 of the exact UTF-8 text of the data value as it appears in the document; any reformatting breaks it." } } } } }, "ImportResult": { "type": "object", "properties": { "imported": { "type": "object", "additionalProperties": { "type": "integer" }, "description": "namespaces, memories, memory_revisions, verifications, documents, document_revisions, chunks, entities, relationships, evidence_links, placeholder_principals (author ids unknown to this installation, created without keys or grants)" }, "indexing": { "type": "object", "properties": { "lexical": { "type": "string" }, "semantic": { "type": "string" } } } } }, "Grant": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "principal_id": { "type": "string", "format": "uuid" }, "namespace_id": { "type": "string", "format": "uuid" }, "path": { "type": "string" }, "permissions": { "type": "array", "items": { "type": "string", "enum": [ "read", "write", "delete", "verify", "admin" ] } }, "inherit": { "type": "boolean" }, "expires_at": { "type": "string", "nullable": true }, "created_at": { "type": "string", "example": "2026-12-05 18:00:00" } } }, "Me": { "type": "object", "properties": { "principal_id": { "type": "string", "format": "uuid" }, "tenant_id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "type": { "type": "string" }, "grants": { "type": "array", "items": { "$ref": "#/components/schemas/Grant" } } } }, "Namespace": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "path": { "type": "string" }, "parent_id": { "type": "string", "nullable": true }, "permissions": { "type": "array", "items": { "type": "string", "enum": [ "read", "write", "delete", "verify", "admin" ] } }, "created_at": { "type": "string", "example": "2026-12-05 18:00:00" } } }, "NamespaceRequest": { "type": "object", "required": [ "path" ], "properties": { "path": { "type": "string", "example": "/team/project-x", "description": "Lower-case a-z, 0-9, '-', '_' and '.' segments separated by '/' (upper case is folded)." } } }, "NamespaceCreated": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "path": { "type": "string" }, "parent_id": { "type": "string", "nullable": true }, "namespaces_created": { "type": "integer", "description": "1 plus the number of missing parents created" } } }, "Principal": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "type": { "type": "string", "enum": [ "human", "agent", "service" ] }, "status": { "type": "string", "enum": [ "active", "disabled", "imported" ] }, "created_at": { "type": "string", "example": "2026-12-05 18:00:00" } } }, "PrincipalRequest": { "type": "object", "required": [ "name", "type" ], "properties": { "name": { "type": "string", "maxLength": 200 }, "type": { "type": "string", "enum": [ "human", "agent", "service" ] } } }, "PrincipalUpdate": { "type": "object", "required": [ "status" ], "properties": { "status": { "type": "string", "enum": [ "active", "disabled" ] } } }, "ApiKeyCreated": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "key": { "type": "string", "description": "The secret, shown only in this response" }, "prefix": { "type": "string" }, "created_at": { "type": "string", "example": "2026-12-05 18:00:00" }, "note": { "type": "string" } } }, "PrincipalCreated": { "type": "object", "properties": { "principal": { "$ref": "#/components/schemas/Principal" }, "api_key": { "$ref": "#/components/schemas/ApiKeyCreated" } } }, "KeyCreated": { "type": "object", "properties": { "principal_id": { "type": "string", "format": "uuid" }, "api_key": { "$ref": "#/components/schemas/ApiKeyCreated" } } }, "PrincipalDetail": { "allOf": [ { "$ref": "#/components/schemas/Principal" }, { "type": "object", "properties": { "keys": { "type": "array", "nullable": true, "description": "null when the caller may not manage this principal", "items": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "prefix": { "type": "string" }, "status": { "type": "string" }, "created_at": { "type": "string", "example": "2026-12-05 18:00:00" }, "expires_at": { "type": "string", "nullable": true }, "last_used_at": { "type": "string", "nullable": true } } } }, "grants": { "type": "array", "items": { "$ref": "#/components/schemas/Grant" } } } } ] }, "GrantRequest": { "type": "object", "required": [ "principal_id", "namespace_id", "permissions" ], "properties": { "principal_id": { "type": "string", "format": "uuid" }, "namespace_id": { "type": "string", "format": "uuid" }, "permissions": { "type": "array", "items": { "type": "string", "enum": [ "read", "write", "delete", "verify", "admin" ] } }, "inherit": { "type": "boolean", "default": true }, "expires_at": { "type": "string", "description": "UTC, YYYY-MM-DD HH:MM:SS, in the future" } } }, "ConsolidationRequest": { "type": "object", "required": [ "namespace_id" ], "properties": { "namespace_id": { "type": "string", "format": "uuid", "description": "Experiences of this namespace only (not its descendants)" }, "since": { "type": "string", "example": "2026-12-01", "description": "Only experiences recorded at or after this UTC date/time" }, "min_size": { "type": "integer", "minimum": 2, "maximum": 50, "default": 2 }, "similarity": { "type": "number", "minimum": 0.1, "maximum": 0.95, "default": 0.35, "description": "Jaccard threshold over significant words; pairs must also share at least 2 words" }, "max_experiences": { "type": "integer", "minimum": 10, "maximum": 500, "default": 300, "description": "Most recent experiences considered" }, "propose": { "type": "boolean", "default": false } } }, "ConsolidationResult": { "type": "object", "properties": { "namespace_id": { "type": "string" }, "experiences_considered": { "type": "integer" }, "similarity": { "type": "number" }, "min_size": { "type": "integer" }, "candidates_created": { "type": "integer" }, "groups": { "type": "array", "items": { "type": "object", "properties": { "size": { "type": "integer" }, "sessions": { "type": "integer" }, "outcomes": { "type": "object", "properties": { "success": { "type": "integer" }, "failure": { "type": "integer" }, "partial": { "type": "integer" }, "unknown": { "type": "integer" } } }, "first_seen": { "type": "string" }, "last_seen": { "type": "string" }, "terms": { "type": "array", "items": { "type": "string" } }, "experience_ids": { "type": "array", "items": { "type": "string" }, "description": "Newest first" }, "already_cited": { "type": "integer", "description": "Members already cited as evidence by a candidate" }, "draft": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "lesson", "solution" ] }, "title": { "type": "string" }, "content": { "type": "string" } } }, "candidate_id": { "type": "string", "nullable": true } } } } } }, "NodeRef": { "type": "object", "required": [ "kind", "id" ], "properties": { "kind": { "type": "string", "enum": [ "entity", "memory", "document" ] }, "id": { "type": "string", "format": "uuid" } } }, "EntityRequest": { "type": "object", "required": [ "namespace_id", "type", "name" ], "properties": { "namespace_id": { "type": "string", "format": "uuid" }, "type": { "type": "string", "pattern": "^[a-z][a-z0-9_-]{0,39}$", "description": "Kind of entity, for example component, concept, person, tool." }, "name": { "type": "string", "maxLength": 200 }, "canonical_key": { "type": "string", "maxLength": 200, "description": "Unique per namespace and type; lower-cased with whitespace collapsed. Defaults to the name normalized the same way." }, "aliases": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 200 } }, "description": { "type": "string", "maxLength": 2000 }, "properties": { "type": "object", "description": "Free JSON object, at most 16 KB." } } }, "EntityUpdate": { "type": "object", "description": "Type, canonical key and namespace cannot change.", "properties": { "name": { "type": "string", "maxLength": 200 }, "aliases": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 200 } }, "description": { "type": "string", "maxLength": 2000 }, "properties": { "type": "object", "description": "Free JSON object, at most 16 KB." } } }, "Entity": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "namespace_id": { "type": "string", "format": "uuid" }, "type": { "type": "string" }, "canonical_key": { "type": "string" }, "name": { "type": "string" }, "aliases": { "type": "array", "items": { "type": "string" } }, "description": { "type": "string", "nullable": true }, "properties": { "type": "object" }, "created_by": { "type": "string" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" } } }, "RelateRequest": { "type": "object", "required": [ "namespace_id", "source", "target", "type", "evidence" ], "properties": { "namespace_id": { "type": "string", "format": "uuid", "description": "Namespace the edge belongs to (write permission needed)." }, "source": { "$ref": "#/components/schemas/NodeRef" }, "target": { "$ref": "#/components/schemas/NodeRef" }, "type": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]{1,39}$", "description": "Upper-cased on input. Examples: IS_A, PART_OF, DEPENDS_ON, IMPLEMENTS, CALLS, SOLVES, CONTRADICTS, SUPERSEDES, VERIFIED_BY, RELATES_TO." }, "description": { "type": "string", "maxLength": 2000 }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 }, "valid_from": { "type": "string", "example": "2027-01-31 18:00:00", "description": "UTC; the edge is followed only from this time." }, "valid_until": { "type": "string", "example": "2028-01-31 18:00:00", "description": "UTC; the edge is no longer followed from this time." }, "inferred": { "type": "boolean", "default": false, "description": "True for links derived by inference rather than stated by a source." }, "evidence": { "type": "array", "minItems": 1, "maxItems": 20, "items": { "$ref": "#/components/schemas/EvidenceInput" }, "description": "Required: graph assertions need evidence." } } }, "Relationship": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "namespace_id": { "type": "string", "format": "uuid" }, "source": { "$ref": "#/components/schemas/NodeRef" }, "target": { "$ref": "#/components/schemas/NodeRef" }, "type": { "type": "string" }, "description": { "type": "string", "nullable": true }, "confidence": { "type": "number", "nullable": true }, "valid_from": { "type": "string", "nullable": true }, "valid_until": { "type": "string", "nullable": true }, "inferred": { "type": "boolean" }, "state": { "type": "string", "enum": [ "proposed", "accepted", "rejected" ] }, "author": { "type": "string" }, "reviewer": { "type": "string", "nullable": true }, "review_notes": { "type": "string", "nullable": true }, "created_at": { "type": "string" }, "reviewed_at": { "type": "string", "nullable": true }, "evidence": { "type": "array", "items": { "$ref": "#/components/schemas/EvidenceItem" }, "description": "Only in GET /relationships/{id}." } } }, "RelationshipReviewRequest": { "type": "object", "required": [ "decision" ], "properties": { "decision": { "type": "string", "enum": [ "accept", "reject" ] }, "notes": { "type": "string", "maxLength": 2000 } } }, "TraverseRequest": { "type": "object", "required": [ "start" ], "properties": { "start": { "$ref": "#/components/schemas/NodeRef" }, "direction": { "type": "string", "enum": [ "out", "in", "both" ], "default": "both" }, "max_depth": { "type": "integer", "minimum": 1, "maximum": 3, "default": 2 }, "max_nodes": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50 }, "types": { "type": "array", "maxItems": 20, "items": { "type": "string" }, "description": "Only follow edges of these types." }, "include_proposed": { "type": "boolean", "default": false, "description": "Also follow proposed (not yet reviewed) edges." } } }, "GraphNode": { "type": "object", "properties": { "kind": { "type": "string", "enum": [ "entity", "memory", "document" ] }, "id": { "type": "string", "format": "uuid" }, "depth": { "type": "integer" }, "namespace_id": { "type": "string" }, "label": { "type": "string", "description": "Entity name, memory title or document title." }, "type": { "type": "string", "description": "Entity type or memory type." }, "status": { "type": "string", "description": "Memories: lifecycle status." }, "revision": { "type": "integer" }, "verification_status": { "type": "string" }, "content_trust": { "type": "string", "description": "Documents: untrusted_reference." } } }, "TraverseResult": { "type": "object", "properties": { "start": { "$ref": "#/components/schemas/NodeRef" }, "direction": { "type": "string" }, "max_depth": { "type": "integer" }, "nodes": { "type": "array", "items": { "$ref": "#/components/schemas/GraphNode" } }, "edges": { "type": "array", "items": { "$ref": "#/components/schemas/Relationship" } }, "truncated": { "type": "boolean", "description": "True when the node or edge limit cut the result short." } } } } }, "paths": { "/remember": { "post": { "summary": "Create a memory", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": false, "description": "Replays the stored response for an identical body; a different body with the same key is 409.", "schema": { "type": "string", "maxLength": 200 } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RememberRequest" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RememberResponse" } } } }, "200": { "description": "Exact duplicate (or idempotent replay of a 200)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RememberResponse" } } } }, "400": { "description": "Invalid JSON / body", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Idempotency-Key reused with a different body", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories": { "get": { "summary": "List memories (newest first)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "namespace_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "type", "in": "query", "schema": { "type": "string" } }, { "name": "status", "in": "query", "schema": { "type": "string", "enum": [ "active", "retired", "superseded", "all" ], "default": "active" } }, { "name": "verification_status", "in": "query", "schema": { "type": "string", "enum": [ "unverified", "verified", "disputed", "rejected" ] } }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 } }, { "name": "cursor", "in": "query", "description": "next_cursor from the previous page", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Page of memories", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Memory" } }, "next_cursor": { "type": "string", "nullable": true } } } } } }, "400": { "description": "Invalid cursor", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Invalid filter", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories/{id}": { "get": { "summary": "Get a memory (optionally an older revision)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "revision", "in": "query", "schema": { "type": "integer" } } ], "responses": { "200": { "description": "The memory", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Memory" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "patch": { "summary": "Correct a memory: creates the next revision, unverified", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "If-Match", "in": "header", "required": false, "description": "Current revision number (quoted ETag form accepted). Required unless expected_revision is in the body.", "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "title": { "type": "string" }, "summary": { "type": "string" }, "content": { "type": "string" }, "tags": { "type": "array", "items": { "type": "string" } }, "attributes": { "type": "object" }, "confidence": { "type": "number" }, "importance": { "type": "number" }, "change_reason": { "type": "string" }, "expected_revision": { "type": "integer" } } } } } }, "responses": { "200": { "description": "New revision", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RememberResponse" } } } }, "400": { "description": "Bad body / revision", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Memory is not active", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "412": { "description": "Stale revision (ETag header carries the current one)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "428": { "description": "If-Match missing", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "delete": { "summary": "Forget: permanently delete the memory and its revisions (needs delete permission)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Deleted" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories/{id}/retire": { "post": { "summary": "Retire: exclude from ordinary listing", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Retired" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories/{id}/versions": { "get": { "summary": "Revision history, newest first", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Revisions" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/sessions": { "post": { "summary": "Start a session", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": false, "description": "Replays the stored response for an identical body; a different body with the same key is 409.", "schema": { "type": "string", "maxLength": 200 } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "namespace_id", "objective" ], "properties": { "namespace_id": { "type": "string", "format": "uuid" }, "objective": { "type": "string", "maxLength": 2000 } } } } } }, "responses": { "201": { "description": "Started" }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Idempotency conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/sessions/{id}/state": { "get": { "summary": "Restore the latest checkpoint (revision 0 / state null when none)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Checkpoint; ETag = revision" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "put": { "summary": "Save a checkpoint (If-Match = current checkpoint revision, 0 for the first)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "If-Match", "in": "header", "required": false, "description": "Current revision number (quoted ETag form accepted). Required unless expected_revision is in the body.", "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SaveStateRequest" } } } }, "responses": { "200": { "description": "Saved; ETag = new revision" }, "409": { "description": "Session closed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "412": { "description": "Stale revision", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "428": { "description": "If-Match missing", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/sessions/{id}/complete": { "post": { "summary": "Complete a session", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": false, "content": { "application/json": { "schema": { "type": "object", "properties": { "outcome": { "type": "string", "maxLength": 4000 } } } } } }, "responses": { "200": { "description": "Completed" }, "409": { "description": "Already closed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories/{id}/verifications": { "post": { "summary": "Record a verification of the current revision (needs the verify permission)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VerifyRequest" } } } }, "responses": { "200": { "description": "Recorded; returns the new verification_status" }, "409": { "description": "Not the current revision", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/recall": { "post": { "summary": "Hybrid recall over active memories (FTS5/bm25 fused with vector similarity by reciprocal rank fusion; lexical only, with a warning, when the embedding provider is off or down). Unverified memories are hidden unless verification_filter=include_unverified", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RecallRequest" } } } }, "responses": { "200": { "description": "Ranked results with warnings" }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "description": " Feedback (POST /feedback) on a result's current revision adjusts its rank; such results carry feedback {useful, not_useful, incorrect_or_harmful} and demoted results are named in warnings." } }, "/ingestion/jobs": { "post": { "summary": "Ingest a Markdown/text document (chunked, indexed) Ingestion is a durable job: the input is stored first, so an interrupted or failed job is retried by the worker (at most 3 attempts) without duplicate chunks.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": false, "description": "Replays the stored response for an identical body; a different body with the same key is 409.", "schema": { "type": "string", "maxLength": 200 } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IngestRequest" } } } }, "responses": { "201": { "description": "Ingested (new document or new revision)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IngestResponse" } } } }, "200": { "description": "Unchanged or idempotent replay", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IngestResponse" } } } }, "400": { "description": "Invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Idempotency-Key reused with a different body", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error. When the job was already stored, its input is kept and the worker retries it (Location: the job)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "202": { "description": "Queued (async): job reference; the worker publishes the revision", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobQueued" } } } } } } }, "/jobs/{id}": { "get": { "summary": "Ingestion job state", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Job" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/jobs/{id}/retry": { "post": { "summary": "Requeue a failed job (attempts reset). Needs write permission on the job's namespace. Automatic retries cover internal errors only; use this after fixing the cause of another failure.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "202": { "description": "Queued", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobQueued" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or no write permission on the job's namespace", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "job_not_retryable: the job is not failed, or its input is no longer stored", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/documents/{id}": { "get": { "summary": "Document metadata (?include_content=true adds the normalized text)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "include_content", "in": "query", "schema": { "type": "boolean" } } ], "responses": { "200": { "description": "Document" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/chunks/{id}": { "get": { "summary": "One chunk with heading path and source locator (character offsets into the normalized document text)", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Chunk" }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/search": { "post": { "summary": "Hybrid search over current document chunks (lexical fused with vector similarity; lexical only, with a warning, when the embedding provider is off or down). Results are untrusted reference content", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SearchRequest" } } } }, "responses": { "200": { "description": "Ranked chunks with locators and content_trust" }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "description": " Feedback (POST /feedback) on a result's current revision adjusts its rank; such results carry feedback {useful, not_useful, incorrect_or_harmful} and demoted results are named in warnings." } }, "/health/live": { "get": { "summary": "Liveness", "responses": { "200": { "description": "Live" } } } }, "/health/ready": { "get": { "summary": "Readiness (database reachable)", "responses": { "200": { "description": "Ready" }, "503": { "description": "Unavailable" } } } }, "/metrics": { "get": { "summary": "Prometheus text metrics: API request counters and latency histogram per controller action (since process start), plus installation-wide counts (memories, candidates, jobs, embedding index, retrieval calls, feedback). Counts only. Enabled when the container has AMK_METRICS_TOKEN (16+ characters); send it as a bearer token. API keys are not accepted.", "tags": [ "health" ], "responses": { "200": { "description": "Metrics", "content": { "text/plain": { "schema": { "type": "string" } } } }, "401": { "description": "Missing or wrong metrics token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Metrics are disabled (no AMK_METRICS_TOKEN)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/context": { "post": { "summary": "Assemble a token-budgeted task briefing: constraints by scope, working state, preferences, conflicts, hybrid matches and reference passages", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ContextRequest" } } } }, "responses": { "200": { "description": "Briefing", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ContextResponse" } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "session_id not found or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed, unsupported_character (code points above U+FFFF), or context_budget_exceeded (the applicable constraints do not fit max_context_tokens; the error also carries required_tokens)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/sessions/{id}/events": { "post": { "summary": "Record an experience (task, problem, action, result, outcome) in an active session", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "Idempotency-Key", "in": "header", "required": false, "schema": { "type": "string", "maxLength": 200 }, "description": "Replays the stored response for a repeated request; 409 if reused with a different body." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ExperienceRequest" } } } }, "responses": { "201": { "description": "Recorded", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "session_id": { "type": "string" }, "outcome": { "type": "string" }, "created_at": { "type": "string" } } } } } }, "400": { "description": "Empty body, invalid JSON or invalid Idempotency-Key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Session not found, or no write permission on its namespace", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "session_not_active (completed session) or idempotency_conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed or unsupported_character", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "get": { "summary": "List the experiences of a session, oldest first (max 200)", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Experiences", "content": { "application/json": { "schema": { "type": "object", "properties": { "session_id": { "type": "string" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Experience" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Session not found or not readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/learn": { "post": { "summary": "Propose knowledge as a learning candidate (a new memory, or a new revision of target_memory_id at base_revision), with evidence", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": false, "schema": { "type": "string", "maxLength": 200 }, "description": "Replays the stored response for a repeated request; 409 if reused with a different body." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LearnRequest" } } } }, "responses": { "201": { "description": "Candidate proposed", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "state": { "type": "string", "enum": [ "proposed" ] }, "namespace_id": { "type": "string" }, "type": { "type": "string" }, "evidence_count": { "type": "integer" } } } } } }, "400": { "description": "Empty body, invalid JSON or invalid Idempotency-Key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Namespace not found or no write permission", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "idempotency_conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed (unknown type, bad target/base_revision, evidence that is unknown, in another tenant or not readable by the caller) or unsupported_character", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/candidates": { "get": { "summary": "List learning candidates in namespaces the caller can read, newest first", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "namespace_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "state", "in": "query", "schema": { "type": "string", "enum": [ "proposed", "accepted", "rejected" ] } }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } } ], "responses": { "200": { "description": "Candidates (without content)", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Candidate" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Bad state or namespace_id", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/candidates/{id}": { "get": { "summary": "One candidate with content and evidence", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Candidate", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Candidate" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/candidates/{id}/review": { "post": { "summary": "Accept or reject a proposed candidate. Needs verify permission; the author cannot review its own candidate without admin. Accepting creates the memory (an identical active memory is reused) or a new revision of the target, copies the evidence and, with verify true, records a verification by the reviewer.", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ReviewRequest" } } } }, "responses": { "200": { "description": "Reviewed", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "state": { "type": "string", "enum": [ "accepted", "rejected" ] }, "resulting_memory_id": { "type": "string" }, "resulting_revision": { "type": "integer" }, "verification_status": { "type": "string" }, "duplicate": { "type": "boolean" } } } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "self_review_not_allowed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Candidate not found or no verify permission", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "candidate_already_reviewed, stale_candidate (target memory changed since base_revision), target_memory_missing or target_memory_not_active", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/memories/{id}/sources": { "get": { "summary": "Evidence and verifications behind a memory revision. Evidence the caller cannot read is listed with available false and no id.", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "revision", "in": "query", "schema": { "type": "integer", "minimum": 1 }, "description": "Default: current revision" } ], "responses": { "200": { "description": "Sources", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Sources" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Memory not found or not readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "revision out of range", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/feedback": { "post": { "summary": "Rate one result of a recall, search or context call (by its query_id). One rating per principal, query and result; a new rating replaces the earlier one (200). Pinned to the revision that was returned.", "tags": [ "learning" ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FeedbackRequest" } } } }, "responses": { "200": { "description": "Updated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Feedback" } } } }, "201": { "description": "Recorded", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Feedback" } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "result_not_found: the result was not returned by that query, is gone, or is not readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/exports": { "post": { "summary": "Export every namespace the caller can read (or the namespace_ids given) as one canonical, integrity-protected JSON document. Evidence whose target the caller cannot read is left out and counted in counts.evidence_links_omitted. Sent as an attachment.", "tags": [ "portability" ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": false, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ExportRequest" } } } }, "responses": { "200": { "description": "The export document", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Export" } } } }, "400": { "description": "Invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed (namespace_ids is not an array of ids)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/imports": { "post": { "summary": "Import a document produced by POST /exports, unchanged (max 8 MiB). Needs admin on every target namespace, matched by path in the caller's tenant (they must exist). Ids, revisions, timestamps and principal ids are kept; content hashes and the lexical index are rebuilt and embeddings are queued. All or nothing.", "tags": [ "portability" ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Export" } } } }, "responses": { "201": { "description": "Imported", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ImportResult" } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "import_conflict: an id in the document already exists; nothing was imported", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "413": { "description": "body_too_large: more than 8 MiB", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed: wrong format, unsupported_schema_version, integrity_mismatch, a missing target namespace, no admin permission on it, or an invalid item; nothing was imported", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error; nothing was imported", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/me": { "get": { "summary": "The caller: principal, tenant and its grants.", "security": [ { "bearerAuth": [] } ], "responses": { "200": { "description": "Caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Me" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/namespaces": { "get": { "summary": "Namespaces the caller can read, with the caller's effective permissions on each.", "security": [ { "bearerAuth": [] } ], "responses": { "200": { "description": "Namespaces", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Namespace" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "summary": "Create a namespace (and missing parents). Needs an inheriting admin grant covering the new path; top-level namespaces are created with the CLI.", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NamespaceRequest" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NamespaceCreated" } } } }, "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "No inheriting admin grant covers the path", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "namespace_exists", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/principals": { "get": { "summary": "Principals of the caller's tenant. Needs admin on at least one namespace.", "security": [ { "bearerAuth": [] } ], "responses": { "200": { "description": "Principals", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Principal" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Caller is not an admin anywhere", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "summary": "Create a principal with one API key. The key is returned once (Cache-Control: no-store). Needs admin on at least one namespace; the new principal has no grants.", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrincipalRequest" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrincipalCreated" } } } }, "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Caller is not an admin anywhere", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/principals/{id}": { "get": { "summary": "A principal. Keys (prefix and state, never the key) are listed when the caller may manage the principal; grants are those on namespaces the caller administers (all of them for the caller itself).", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Principal", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrincipalDetail" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or the caller is not an admin and not this principal", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "patch": { "summary": "Disable or re-enable a principal. Needs admin on every namespace the principal has a grant on (inheriting where the grant inherits). A principal cannot change its own status.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrincipalUpdate" } } } }, "responses": { "200": { "description": "Updated", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Principal" } } } }, "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not manageable by the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed, or cannot_change_self", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/principals/{id}/keys": { "post": { "summary": "Issue another API key (returned once). Allowed for the caller's own principal, or for a principal the caller may manage (see PATCH /principals/{id}), so a key never gives more access than the caller has.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/KeyCreated" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not manageable by the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "principal_not_active", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/keys/{id}": { "delete": { "summary": "Revoke an API key (idempotent). Same rule as issuing keys.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Revoked", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "principal_id": { "type": "string" }, "status": { "type": "string", "enum": [ "revoked" ] } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or not manageable by the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/grants": { "get": { "summary": "Grants on namespaces the caller administers.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "namespace_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "principal_id", "in": "query", "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Grants", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Grant" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Caller is not an admin anywhere", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "summary": "Grant permissions on a namespace to an active principal of the tenant. Needs admin on the namespace; inherit (default true) needs admin that also covers its descendants. One grant per principal and namespace.", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GrantRequest" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Grant" } } } }, "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Namespace not found or caller lacks admin on it", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "grant_exists", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed, principal_not_found or inherit_not_allowed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/grants/{id}": { "delete": { "summary": "Remove a grant. Needs admin on its namespace; a principal cannot remove its own grants.", "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found or caller lacks admin on its namespace", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "cannot_change_self", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/consolidations": { "post": { "summary": "Group similar experiences of a namespace (deterministic word overlap, no generative model) and return a draft candidate per group. With propose true (needs write), every group with at least min_size experiences not yet cited by any candidate is filed as a proposed candidate tagged 'consolidated' that cites them as evidence; review it like any other candidate. Read permission is enough for a dry run.", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConsolidationRequest" } } } }, "responses": { "200": { "description": "Groups (largest first, at most 20)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConsolidationResult" } } } }, "400": { "description": "Body is not valid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "namespace_not_found (also without read, or without write when proposing)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "500": { "description": "Internal error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/entities": { "post": { "summary": "Create an entity (a named concept that relationships can connect). Needs write permission on the namespace.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EntityRequest" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Entity" } } } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Namespace not found or not writable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "An entity with this type and canonical key exists in the namespace (error.existing_id names it)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "get": { "summary": "List entities in readable namespaces.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "namespace_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "type", "in": "query", "schema": { "type": "string" } }, { "name": "q", "in": "query", "schema": { "type": "string", "maxLength": 200 }, "description": "Substring of the name, canonical key or an alias." }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } } ], "responses": { "200": { "description": "Entities", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Entity" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/entities/{id}": { "get": { "summary": "Fetch an entity.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Entity", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Entity" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "patch": { "summary": "Change the name, aliases, description or properties of an entity. Needs write permission.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EntityUpdate" } } } }, "responses": { "200": { "description": "Updated", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Entity" } } } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "delete": { "summary": "Delete an entity and every relationship touching it. Needs delete permission.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "deleted": { "type": "boolean" }, "id": { "type": "string" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/relate": { "post": { "summary": "Propose a typed, directed relationship between two entities, memories or documents. Needs write permission on the namespace and read permission on both endpoints; evidence is required. The edge stays proposed until reviewed. Supports Idempotency-Key.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "Idempotency-Key", "in": "header", "schema": { "type": "string", "maxLength": 200 } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RelateRequest" } } } }, "responses": { "201": { "description": "Proposed", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "state": { "type": "string", "enum": [ "proposed" ] }, "namespace_id": { "type": "string" }, "type": { "type": "string" }, "source": { "$ref": "#/components/schemas/NodeRef" }, "target": { "$ref": "#/components/schemas/NodeRef" }, "evidence_count": { "type": "integer" } } } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Namespace not found or not writable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "The same relationship is already proposed or accepted in the namespace (error.existing_id names it)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed, including an endpoint or evidence target that does not exist or cannot be read", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/relationships": { "get": { "summary": "List relationships visible to the caller: readable namespace and both endpoints readable.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "namespace_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }, { "name": "state", "in": "query", "schema": { "type": "string", "enum": [ "proposed", "accepted", "rejected" ] } }, { "name": "type", "in": "query", "schema": { "type": "string" } }, { "name": "node_kind", "in": "query", "schema": { "type": "string", "enum": [ "entity", "memory", "document" ] } }, { "name": "node_id", "in": "query", "schema": { "type": "string", "format": "uuid" }, "description": "With node_kind: only edges touching this node." }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } } ], "responses": { "200": { "description": "Relationships, newest first", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Relationship" } } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/relationships/{id}": { "get": { "summary": "Fetch a relationship with its evidence (evidence the caller cannot read is shown without its id).", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Relationship", "content": { "application/json": { "schema": { "type": "object", "properties": { "data": { "$ref": "#/components/schemas/Relationship" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "delete": { "summary": "Delete a relationship and its evidence. Needs delete permission on its namespace.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "Deleted", "content": { "application/json": { "schema": { "type": "object", "properties": { "deleted": { "type": "boolean" }, "id": { "type": "string" } } } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/relationships/{id}/review": { "post": { "summary": "Accept or reject a proposed relationship. Needs verify permission; the author cannot review its own relationship without admin.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RelationshipReviewRequest" } } } }, "responses": { "200": { "description": "Reviewed", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "state": { "type": "string", "enum": [ "accepted", "rejected" ] } } } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "self_review_not_allowed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found, or not visible to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "409": { "description": "Already reviewed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/graph/traverse": { "post": { "summary": "Bounded breadth-first exploration from one node. Follows accepted edges that are valid now (proposed ones on request), skips retired memories, and never returns a node or edge the caller cannot read. Limits: depth 3, 100 nodes, 300 edges.", "tags": [ "graph" ], "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TraverseRequest" } } } }, "responses": { "200": { "description": "Nodes and edges", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TraverseResult" } } } }, "400": { "description": "Empty body or invalid JSON", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Missing, invalid, revoked or expired API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Start node not found or not readable", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "422": { "description": "Validation failed", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } } } }