build_knowledge_graph
Build (or rebuild) the workspace's knowledge graph from its ingested files.
Cost class: job (corpus-level extraction and entity resolution; billed on completion).
The graph is built over every ingested file in the workspace at once — entity resolution links entities across documents, so it cannot be a per-file operation the way parsing or categorization are. Files that are not yet ingested are not in the corpus. Ingest them first, then build. A workspace with no ingested files is refused with invalid_request before a job is created. That check runs after an idempotent replay, so a retry of a build that already started still returns the original job. A workspace whose ingested files are all excluded by graph rules still starts a job. The workflow fails that job. A rebuild resumes from the durable store, re-paying only for what changed since the last build. force clears the store and rebuilds from scratch.
Once built, query the graph with the kg-info / kg-search / kg-walk context tools. A file's representations.knowledge_graph reads true once a build that covered it has finalized.
Args: body: Build parameters — currently just force. context: Resolved workspace plus the caller's access predicate. session: Database session. wait_seconds: Bounded inline wait (0 → immediate 202). A real build far outlasts any sync window, so callers normally poll the returned job. idempotency_key: Replaying with the same key returns the original job. response: Injected by FastAPI for status-code management.
Returns: A :class:~ndi_service.app.platform_api.results.Job. On success the result is a :class:~ndi_service.app.platform_api.results.KnowledgeGraphBuildResult.
Raises: PlatformError: invalid_request when the workspace has no ingested files. Raised after an idempotent replay, and before a job row or workflow is created.
Request
- Base URLhttps://ndi-api.nace.ai (the document declares no server; this is the origin it was published from)
- AuthAPI key in header X-API-Key
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
Workspace identifier.
Query parameters
Bounded inline wait. 0 (the default) returns 202 immediately. Above 0 the route returns 200 with a terminal job if the work finished in time, and 202 with the still-running job if it did not. Either way, read status.
Headers
Replaying a request with the same key returns the original job with 200, never a second job. The key is kept with the job for replay and never cleared, so it must not contain personal data.
Request body
Response
Successful Response
Changes
No recorded changes to this operation across all 1 revision of this API.