MatrixArk Contact

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.

1. Ingest an event
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" }
2. Build a token-budgeted ContextPack
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"
}
3. Replay a pack by id
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.

Related

Serving core TemporalStore The time-aware engine that stores and serves what this API compiles. Enterprise MatrixKV Transactional metadata — permissions and approvals the pack references. Enterprise MatrixDB Hot context state and cache metadata behind the serving path.