---
title: "get_workspace_stats"
method: GET
path: "/v1/workspaces/{workspace_id}/stats"
tags: ["workspaces"]
---

# get_workspace_stats

`GET /v1/workspaces/{workspace_id}/stats`

## Request

- Base URL: `https://ndi-api.nace.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://ndi-api.nace.ai/v1/workspaces/{workspace_id}/stats`
- Auth: API key in header `X-API-Key`
- TypeScript: <https://skmtc.dev/nace/apis/ndi-service/docs/v1/workspaces/:workspace_id/stats/get.ts> (a function with typed inputs; its response is checked against the schema)

Compute workspace content statistics. Cost class: fast.

Returns file counts, byte totals, ingestion timestamps, and expiry
information — enough for a caller to determine whether the workspace needs
ingestion or a re-ingest without paging through ``list_files``.

``kg_nodes`` / ``kg_edges`` describe the workspace's published knowledge
graph, and are zero until a build has finished one. They come from the
build's own record rather than the graph itself, so this stays a fast read;
an unreachable graph store reports zero rather than failing the request.

Args:
    session: Database session.
    context: Resolved workspace plus caller access predicate.

Returns:
    The stats bag.

## Path parameters

- `workspace_id` string, uuid, required: Workspace identifier.

## Response `200`

Successful Response

- WorkspaceStats: Per-workspace content summary. ``files_by_ingestion_status`` is the completeness instrument: a caller does not need to page through ``list_files`` to know whether anything is stale. ``stale > 0`` means observed and ingested hashes diverged — call ``POST .../ingestions`` with ``stale_only=true`` to catch up. ``expired > 0`` means derived representations were dropped by retention; a re-ingest is needed to make those files searchable again.
  - `files_total` integer, required
  - `files_by_ingestion_status` object, required
  - `bytes_total` integer, required
  - `pages_ingested` integer, required
  - `index_documents` integer, required
  - `kg_nodes` integer, required: Nodes in the workspace's published knowledge graph; 0 when none is built.
  - `kg_edges` integer, required: Edges in the workspace's published knowledge graph; 0 when none is built.
  - `last_ingestion_at` string, date-time, nullable, required
  - `last_reconciliation_at` string, date-time, nullable, required
  - `next_expiry_at` string, date-time, nullable, required: Earliest artifact ``expires_at``; null when nothing expires.
  - `files_expiring_within_7d` integer, required

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `402`: Payment Required
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict
- `410`: Gone
- `413`: Request Entity Too Large
- `422`: Unprocessable Entity
- `424`: Failed Dependency
- `429`: Too Many Requests
- `500`: Internal Server Error
- `501`: Not Implemented
- `503`: Service Unavailable
- `504`: Gateway Timeout

---

[API](https://skmtc.dev/nace/apis/ndi-service.md) - [All operations](https://skmtc.dev/nace/apis/ndi-service/llms.txt) - [OpenAPI document](https://skmtc.dev/nace/apis/ndi-service/revisions/d9d1f8ec2207?raw)
