Retrieve facts by intent
const url = 'https://example.com/v1/memory/retrieve';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"mode":"list","query":"example","type":"example","scope":{"tenantId":"example","userId":"example","orgId":"example","projectId":"example","threadId":"example","sessionId":"example"},"limit":1,"embeddingModel":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/memory/retrieve \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "mode": "list", "query": "example", "type": "example", "scope": { "tenantId": "example", "userId": "example", "orgId": "example", "projectId": "example", "threadId": "example", "sessionId": "example" }, "limit": 1, "embeddingModel": "example" }'Cross-history retrieval. Body is a RetrieveIntent shape mirroring the agent-side declarative retrieval. Semantic modes require an embedding provider bound on the deployment.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Caller-supplied idempotency key. Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1).
Request Bodyrequired
Section titled “Request Bodyrequired”Retrieval intent — mirrors RetrievalIntent from @kindgi/agents, widened for direct-HTTP use. mode: "list" returns a plain scoped list (no query). mode: "keyword" runs full-text search. mode: "semantic" runs vector similarity search — requires an embedding provider bound on the deployment; if unavailable, the route returns 400 bad-input. mode: "both" unions keyword + semantic results, dedup by fact id.
object
Required for keyword / semantic / both; ignored for list.
Fact scope object. tenantId is required; every optional key narrows the fact (userId, orgId, projectId, threadId, sessionId). Additional keys accepted for forward compatibility.
object
Responses
Section titled “Responses”Retrieval results.
object
object
object
FactId.
Fact type identifier (pack-defined; a few are framework-standard).
Fact scope object. tenantId is required; every optional key narrows the fact (userId, orgId, projectId, threadId, sessionId). Additional keys accepted for forward compatibility.
object
Monotonic version within (scope, id). Supersession increments.
Free-form structured payload.
blob://<provider>/<bucket>/<key> when the payload is stored externally.
object
object
object
object
FactId of the predecessor when this row supersedes another.
Relevance score. Keyword mode returns an implementation-defined rank (higher = better). Semantic mode returns cosine similarity in [-1, 1] (higher = better). Absent for list mode.
Example
{ "results": [ { "fact": { "source": { "kind": "http-api", "refresh": { "strategy": "on-read" } } } } ]}Malformed intent, or semantic mode requested and no embedding provider is bound.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Idempotency-Key was reused with a different body, or resource-state conflict.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Server error (unmapped domain code or framework crash).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}