Context & Profiles API
Two related surfaces: context bundles (the token-budgeted, provenance-bearing payload you put in a prompt) and profiles (the non-temporal “who is this subject” snapshot).
Context bundle
POST /api/v1/projects/{projectId}/lattice/context
Aggregate a subject’s profile + active patterns + predictions + memories + observations into one token-budgeted bundle. Every claim carries source ids so any inference can be traced.
{
"subject": { "kind": "customer", "externalId": "acct-42" },
"include": ["profile", "patterns", "predictions", "memories", "observations"],
"maxTokens": 2000,
"memoryLimit": 20,
"predictionLimit": 10,
"excludeCategories": ["medical"]
}include— which of the five sections to build. Omit for all five.maxTokens— hard cap; sections truncate to fit (200–16000, default 2000).excludeCategories— min-necessary access: drop categories from the bundle (e.g. keep medical / HR / PII out of a sales-context query against the same project).
The response carries profile, patterns[], predictions[], memories[],
observations[], a provenance block (memory / pattern / observation ids),
tokensEstimate, a truncated[] list of dropped sections, and a guidance
directive to place at the top of the prompt so the model treats the bundle as
already-known.
Batch context
POST /api/v1/projects/{projectId}/lattice/context/batch
Build bundles for many subjects (≤500) in one call — the bulk-load path that replaces N round-trips. The same options apply to every subject; bundles are returned in request order.
{
"subjects": [
{ "kind": "customer", "externalId": "acct-42" },
{ "kind": "customer", "externalId": "acct-43" }
],
"maxTokens": 1500
}Batch context is the endpoint to reach for when loading memory for hundreds of customers at once (e.g. a campaign build) — one call, not one per subject.
Profile
POST /api/v1/projects/{projectId}/lattice/profile
(also POST /api/v1/projects/{projectId}/memory-intelligence/profile)
The non-temporal counterpart to prediction — “who is this subject?” folded from their active behavior patterns.
{ "subject": { "kind": "customer", "externalId": "acct-42" } }Response:
{
"subject": { "kind": "customer", "externalId": "acct-42" },
"rfmSegment": "loyal_customer",
"recencyScore": 5, "frequencyScore": 4, "monetaryScore": 4,
"topEntity": "tonys-pizza",
"cadenceSummary": "every 7 days",
"risks": [
{ "kind": "declining_engagement", "description": "…", "severity": 0.6, "sourcePatternId": "mem_…" }
],
"contributingPatternIds": ["mem_…"],
"generatedAt": "2026-07-13T00:00:00Z",
"durationMs": 6
}risks are the active signals (declining engagement, at-risk RFM segments,
missed cadence) an agent should surface before a non-trivial action. Every field
traces back through contributingPatternIds.