---
title: "Get Kg Graph"
method: GET
path: "/api/v1/kg/debug/graph"
tags: ["v1", "KG Debug"]
---

# Get Kg Graph

`GET /api/v1/kg/debug/graph`

## Request

- Base URL: `https://api.jeevyfabrication.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.jeevyfabrication.com/api/v1/kg/debug/graph`
- Auth: none declared

Return active nodes + edges for the KG visualizer.

shop_id comes from the session via kg_read_shop_id (agents.md rule #7 —
never from a request argument). Sibling to GET /kg/debug/node/{id}; it does
NOT touch any existing read path.

Two scopes, same response shape:
  - ``deliverable_id`` given: ``kg_active_edges.deliverable_id`` is the
    scope. Nodes in scope = the set of nodes referenced (from_node/
    to_node) by those active edges, fetched from ``kg_active_nodes`` (which
    excludes retired nodes) by id-set. An unknown deliverable returns
    empty lists.
  - ``deliverable_id`` omitted (kg-debugger-view task, 2026-07-02): the
    WHOLE shop's active KG — mirrors /internal/kg/graph's shop-wide query
    (``list_all_active`` / ``list_active_for_shop``, same node/edge caps),
    behind user-auth instead of service-auth. Requested so jeevy's view
    can match khimaira's shop-wide monitor (Joseph, live comparison).

Read-only. Nodes carry only observation_count (a count, not a fact value), so
no financial-fact payload is exposed at this endpoint — node observations are
fetched separately via the single-node endpoint, which already gates them.

CACHING (kg-debugger-view task, 2026-07-02): served from an in-process
per-shop snapshot cache (TTL _GRAPH_CACHE_TTL_SECONDS) unless ``reload``
is set. ``meta.cached``/``meta.age_seconds`` tell the caller whether this
is a fresh query or a cached snapshot, and how stale it is.

## Query parameters

- `deliverable_id` string, nullable: Deliverable UUID — scope to one deliverable's subgraph. Omit to load the WHOLE shop's active KG (may be large).
- `reload` boolean: Bypass the server-side snapshot cache and recompute.

## Response `200`

Successful Response

- KgGraphResponse: Standard response envelope for GET /kg/debug/graph.
  - `data` KgGraphData, required: Full node-edge graph for one deliverable scope.
    - `nodes` KgGraphNode[], required
      - `id` string, required
      - `node_type` string, required
      - `canonical_key` string, required
      - `display_name` string, nullable
      - `observation_count` integer
      - `owner_user_id` integer, nullable
      - `owner_name` string, nullable
    - `edges` KgGraphEdge[], required
      - `id` string, required
      - `from` string, required
      - `to` string, required
      - `link_type` string, required
      - `confidence` number, nullable
      - `owner_user_id` integer, nullable
      - `owner_name` string, nullable
  - `meta` KgGraphMeta, nullable: Snapshot metadata for GET /kg/debug/graph (kg-debugger-view task, 2026-07-02). The shop-wide graph query is expensive enough (paginated past PostgREST's 1000-row cap) that every load re-running it is bad UX — cached=True means this response came from the server-side snapshot cache rather than a fresh query. age_seconds drives the frontend's "~Nm old — reload?" hint (mirrors khimaira's monitor). Pass ?reload=true to force a fresh query.
    - `cached` boolean, required
    - `cached_at` string, required
    - `age_seconds` number, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api.md) - [All operations](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api/llms.txt) - [OpenAPI document](https://skmtc.dev/jeevyfabrication/apis/bom-generation-api/revisions/ad9a01abeac9?raw)
