"description": "Universal AI Agent Memory platform, phases 1-3: memories with revisions and verification, sessions with checkpoints, Markdown/text document ingestion with chunk locators, lexical search and recall, health. Authenticate with `Authorization: Bearer <api key>`; 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)."
},
"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",
"title",
"content"
],
"properties": {
"namespace_id": {
"type": "string",
"format": "uuid"
},
"title": {
"type": "string",
"maxLength": 200
},
"content": {
"type": "string",
"maxLength": 262144
},
"format": {
"type": "string",
"enum": [
"markdown",
"text"
],
"default": "markdown"
},
"source_uri": {
"type": "string",
"maxLength": 500,
"description": "Identifier only; never fetched. The same source_uri in a namespace is one document."
}
}
},
"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"
}
}
},
"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)."
"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)",
"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",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/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"
},
"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"
}
}
}
}
}
}
},
"/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",