Context API reference
One boundary for LLM context.
The MatrixArk context API is a single request-time surface. Send raw events and lightweight hints; MatrixArk extracts, compiles, and stores context, then returns a token-budgeted ContextPack you can drop straight into a prompt — and replay later by id. You never model hash keys, indexes, or storage routing yourself.
The API has three verbs that mirror the context lifecycle: ingest an event, build a context pack for a prompt, and replay a pack by id. Extraction, freshness, permission checks, and storage routing happen behind the boundary.
POST /v1/context/events
{
"tenant": "company_a",
"source": "cursor",
"scope_hint": { "team": "platform", "project": "project_1" },
"kind": "tool_result",
"content": "Alice approved another GPU batch up to $80k until June 30.",
"source_ref": "s3://company-a/tools/purchase-approval-913.json",
"observed_at": "2026-06-14T16:20:00Z"
}
# 202 Accepted
{ "event_id": "evt_5f31a9", "status": "extracting" }
POST /v1/context/packs
{
"tenant": "company_a",
"raw_query": "Can we buy another GPU batch this week?",
"hints": { "team": "platform", "project": "project_1", "max_prompt_tokens": 1200 },
"as_of": "2026-06-14T18:00:00Z"
}
# 200 OK -> a replayable manifest, not a raw blob
{
"context_pack_id": "pack_7731c0",
"as_of": "2026-06-14T18:00:00Z",
"sections": [
{ "id": "sec_latest_approval", "text": "GPU batch approved to $80k, valid until 2026-06-30.",
"source_ref": "s3://company-a/tools/purchase-approval-913.json", "valid": true },
{ "id": "sec_open_spend", "text": "Committed spend this quarter: $61k of $80k." }
],
"blocked": [
{ "id": "evt_2201", "reason": "stale: superseded by approval-913" }
],
"token_estimate": 940,
"replay_id": "pack_7731c0"
}
GET /v1/context/packs/pack_7731c0
# 200 OK -> the exact context the model saw, plus why each item was chosen
{
"context_pack_id": "pack_7731c0",
"as_of": "2026-06-14T18:00:00Z",
"included": ["sec_latest_approval", "sec_open_spend"],
"blocked": [{ "id": "evt_2201", "reason": "stale: superseded by approval-913" }],
"query": "Can we buy another GPU batch this week?",
"token_estimate": 940
}
Request and response shape
Simple inputs at the edge; bounded, auditable context on the way out.
Requests stay forgiving
Every call carries a tenant and either an event to ingest or a raw query to answer. Scope hints (team, project, matter, ticket) are optional; MatrixArk extracts scope, entities, time, validity, and permissions and compiles them into TemporalStore records. You do not send hash keys, index names, or timestamp layouts.
Responses stay bounded
A ContextPack is a compact manifest: included section ids and text, blocked records with reasons, source refs, a token estimate against your max_prompt_tokens budget, and a replay_id. Nothing is an unbounded scan — time windows are validated and result counts are capped so serving stays low-latency.