Skip to content

09 — API Plane

The contract clients integrate against: the graph, retrieval services, and agent tools exposed as APIs their systems and agents can consume. The design stance is conservative surface, strong guarantees: a small, versioned, tenant-scoped API set that stays stable — because enterprise integrations outlive implementation details.

Surfaces

Surface Purpose Versioning
REST (OpenAPI 3.1) primary integration surface; CRUD-style reads over entities, search, answers URL-versioned /v1/…
GraphQL flexible graph reads for client apps (subset autogenerated from active ontology) same version windows, additive-fields only
MCP server exposes the agent tool catalog to client agents/tools (Claude, custom runtimes) tools version-tagged with ontology version
Webhooks graph-change events to client systems event schema versioned per event type

REST /v1 (canonical surface)

GET  /v1/entities/{iri}                → entity card (typed properties + provenance summary)
GET  /v1/entities/{iri}/relationships  → typed edges (paginated, filterable by predicate)
GET  /v1/search                        → hybrid search (entities + documents)
POST /v1/search                        → structured query body
POST /v1/ask                           → agent-mediated answer with citations
POST /v1/ask/explain                   → re-generate citation/proof for a prior answer id
GET  /v1/documents/{iri}/renditions    → derived markdown / page images
GET  /v1/ontology/active               → current TBox (machine-readable, for client tooling)
GET  /v1/sources                       → data source registry + sync health
GET  /v1/audit                        → tenant audit export (paginated, date-ranged)

Design rules: - Read-only. v1 has no write endpoints (graph writes flow only through ingestion, 06). - Permission semantics identical to agent calls — same effective-identity resolution (07), and results always include grounding fields so any API consumer can cite like the agents do. - Pagination defined by opaque cursors everywhere; total-count semantics avoided on permission-filtered paths (counting visible-only is already supported; count columns that could reveal hidden existence are not returned). - Error surface: stable machine code strings + navigable docs; never branch on message text (matches our own practice with our vendors' APIs).

GraphQL

Served by KMap's own GraphQL-over-RDF gateway (spec: 09a): schemas are generated from the tenant's active ontology + SHACL shapes at ontology publish time, queries compile to permission-joined SPARQL plans through the single security kernel, and the security posture of every field is carried by the gateway's directive registry (@scope, @traversalScope, @tenantScoped, …). Schema versions track ontology versions exactly; breaking changes ride the ontology review gate and the 12-month overlap policy.

MCP server

Client agents get the same tool catalog (08), same permission semantics, same audit. Two provisions specific to it: - Client MCP principals can declare acting-for user identity per session; if not configured, the service account's (deliberately narrow) own permissions apply — never a tenant-wide "agent role." - Tool behavior is identical to internal agents so a client's own agent stack and our hosted agents yield the same answers to the same question (verifiable in the acceptance test — an anti-drift property clients can test for).

Webhook events (v1 schema)

entity.created | entity.updated | entity.deleted
relationship.created | relationship.deleted
drift.detected             (source schema drift, links ontology proposals)
ontology.proposed | ontology.committed
conflict.detected          (cross-source fact disagreement)
sync.completed | sync.failed

Each event: tenant, occurred-at, entity/event IRI, which ABox partition, ontology version. Retries with backoff and a dead-letter visibility in the admin console. Signature: HMAC with per-endpoint secret + timestamp window.

Cross-cutting API standards

  • Auth: OAuth2 client-credentials for machine clients, with the option of on-behalf-of user tokens (RFC 7523-style exchange) so a client's app acts as a user — inheriting that user's permissions. API keys live in the vault, rotate with zero downtime (dual-valid window), and are per-client-app, never per-developer.
  • Tenant routing: every token binds a tenant; cross-tenant requests fail closed.
  • Rate limits & quotas: per app, per endpoint class; 429 with Retry-After; budget-protected tiers (an app can't exhaust a tenant's agent budget).
  • Versioning policy: additive changes land any release; breaking changes are new URL versions with a 12-month supported overlap minimum; a machine-readable changelog ships with SDK releases.
  • Metering: per-call usage tagged by app/person/tool lands in the control store; feeds both billing and the client's own usage dashboards.
  • Observability: request-id propagation; client-visible status/latency per source in the registry; incident comms tied to the same partition IRIs the client saw in results.

SDKs (v1 cut)

Python and TypeScript, generated from the OpenAPI spec (not hand-rolled): - entity cards, search, ask(+citations) helpers that render grounding links, - webhook verification helpers, - MCP starter configs for client agent stacks.

Go/Java deferred to v1.5 (enterprise shops ask often; not launcher-v1 scope).

Sandbox posture

Every production tenant can spin a sandbox: - a one-shot snapshot copy of (a subset of) the tenant graph with masked test users (07 fixtures), - isolated from production ingestion, resettable, - rate-ceilinged for agent workloads - the near-Beta surface for their integrations before production cutover.

Explicit non-goals in v1

  • No streaming/push graph replicas (v1.5 candidate — high support burden).
  • No client-initiated graph writes (review-gated ontology + ingestion is the entire write path).
  • No anonymous/public API tier; every principal is authenticated and permission-resolved.
  • No hosted widget/UI SDK yet (08 admin console covers sharing; embeddable components are v1.5+ if design partners ask).