Skip to main content
Version: v0.9.0a2
Integrator

API Reference

8 min readIntegrator · SDK authorOpenAPI

What this page covers

The Stigmem reference node exposes a REST API owned by Spec-03-HTTP-API, with endpoint semantics split across the component specs listed below. The interactive API reference is auto-generated from the OpenAPI schema served at http://localhost:8000/openapi.json.

Endpoint groups

Group · Base path
Auth
Spec
Facts · /v1/facts
API key
Spec-01-Fact-Model, Spec-03-HTTP-API, Spec-15-Fact-Semantics.
Federation · /v1/federation/*
API key + peer token
Spec-03-HTTP-API, Spec-05-Federation-Trust.
Conflicts · /v1/conflicts
API key
Spec-03-HTTP-API, Spec-15-Fact-Semantics.
Gardens · /v1/gardens/*
API key (role-gated)
Spec-02-Scopes-and-ACL, Spec-08-Quarantine-Garden.
Lint · /v1/lint
API key
Spec-20-Lint-Semantics.
Decay · /v1/decay/sweep
API key
Spec-X9-Decay-Semantics.
Synthesis · /v1/synthesis
API key
Spec-X10-Synthesis.
Auth / Keys · /v1/auth/keys/*
Admin API key
Spec-06-Capability-Tokens.
Auth / Audit · /v1/auth/audit
Admin API key
Spec-X6-Source-Attestation.
Admin / Billing · /v1/admin/billing/events
Admin API key
Async Jobs · /v1/jobs/:id
API key
Spec-20, Spec-X9.
Identity · /v1/me
API key
Node Metadata · /.well-known/stigmem
none
Spec-03-HTTP-API, Spec-04-Manifests.
Health · /healthz
none
Recall · /v1/recall
API key
Spec-07-Recall-Pipeline, Spec-X11-Recall-Graph.
Cards · /v1/cards/*
API key
Spec-X11-Recall-Graph.
Graph · /v1/graph/*
API key
Spec-X11-Recall-Graph.
Subscriptions · /v1/subscriptions
API key + capability token
Spec-X7-Subscriptions.
Provenance · /v1/facts/:id/provenance
API key
Spec-X11-Recall-Graph.
Instructions · /v1/agents/:id/instruction-manifest
API key
Spec-X1-Lazy-Instruction-Discovery.

Graph and recall endpoints

GET /v1/recall · POST /v1/recall

Returns a token-budget-bounded, salience-ranked slice of the fact store relevant to a natural-language or structured query. Uses a three-stage hybrid pipeline: lexical (FTS5/BM25), dense vector (ANN via sqlite-vec), and graph expansion (BFS on entity_edges). Results are packed with Maximal Marginal Relevance (MMR).

POST is preferred when query exceeds 1000 characters.

Key parameters:

Parameter
Default
Description
query
required
Natural-language or structured query.
token_budget
required
Max response tokens.
depth
1 (max 2)
Graph expansion depth.
weights
{lex:0.30, vec:0.50, graph:0.20}
Stage weights; must sum to 1.0 ±0.001.
entity
optional
Entity URI; enables entity-centric (card-first) recall.
relation
optional
Relation filter; skips memory card lookup.
scope
global
Garden or global scope.
lambda_mmr
0.7
MMR diversity tradeoff; 1.0 = greedy.
min_confidence
0.1
Minimum effective confidence.
force_refresh
false
Block on synchronous memory card refresh.
include_contradicted
false
Include unresolved contradictions.

Example — open-ended query:

curl -s -X POST http://localhost:8000/v1/recall \
-H 'Authorization: Bearer <api-key>' \
-H 'Content-Type: application/json' \
-d '{
"query": "what is the current project status for phase 9?",
"token_budget": 2000,
"depth": 1
}'

Example — entity-centric query (card-first):

curl -s "http://localhost:8000/v1/recall?entity=stigmem%3A%2F%2Fcompany.example%2Fagent%2Fcto&token_budget=1500" \
-H 'Authorization: Bearer <api-key>'

GET /v1/cards/{entity_uri}

Fetch (and optionally force-refresh) the synthesized memory card for a specific entity. Returns 404 when the entity has no live facts.

Memory cards are pre-aggregated summaries.

Marked stale on every assert_fact call and refreshed on the next read. When a fresh card is available during POST /v1/recall, the recall pipeline uses it as a single synthetic fact instead of re-ranking all raw facts for that entity.

Path parameter: entity_uri — URL-encoded entity URI.

Query parameters:

Parameter
Default
Description
scope
local
Scope the card was materialised from.
refresh
false
Force a server-side refresh even if the card is already fresh.

Auth: read permission required.

# Fetch card (auto-refreshes if stale)
curl -s "http://localhost:8000/v1/cards/stigmem%3A%2F%2Fcompany.example%2Fuser%2Falice?scope=local" \
-H 'Authorization: Bearer <api-key>'

# Force refresh
curl -s "http://localhost:8000/v1/cards/stigmem%3A%2F%2Fcompany.example%2Fuser%2Falice?scope=local&refresh=true" \
-H 'Authorization: Bearer <api-key>'

Error responses:

Status
Code
Condition
400
validation
Invalid scope value or malformed entity_uri.
403
authorization
API key lacks read permission.
404
lookup
No live facts exist for the entity.

GET /v1/graph/neighbors

Returns the graph neighbors of one or more seed entities by traversing the materialized entity_edges adjacency index.

Parameter
Default
Description
entity
required
Seed entity URI (repeat for multiple seeds).
depth
1 (max 2)
Traversal depth.
relation
optional
Filter edges by relation label.
min_confidence
0.1
Minimum edge confidence.
limit
50
Max edges returned per page.
cursor
opaque
Pagination cursor (TTL STIGMEM_CURSOR_TTL_S, default 300s).

POST /v1/subscriptions

Register a push subscription to receive events when facts matching a scope or entity change. Requires a capability token covering the subscribe verb on the target.

curl -s -X POST http://localhost:8000/v1/subscriptions \
-H 'Authorization: Bearer <api-key>' \
-H 'Content-Type: application/json' \
-d '{
"target": "stigmem://company.example/project/phase9",
"target_type": "entity",
"on_change": "webhook",
"webhook_url": "https://your-agent.example/hook",
"idempotency_key": "sub-phase9-agent-assistant"
}'

Events are delivered with subscription_id, event_type (fact_asserted | fact_retracted | conflict_opened | conflict_resolved), fact_id, and hlc.

Delivery security: garden ACL + capability revocation re-checked on every event.

Event content is not populated until the ACL check passes — preventing cross-garden fact leakage via standing event streams. If access has been revoked since subscription creation, delivery is silently dropped and the subscription is cancelled with event type subscription_cancelled_access_revoked.


GET /v1/facts/:id/provenance

Walks the derived_from DAG for a given fact and returns the full derivation graph.

Cross-scope inference protection.

Caller must have read access to the root fact's scope and garden_id. Unauthorized root facts return HTTP 403. When resolving derived_from references, facts in unauthorized scopes or gardens are represented as {"hash": "...", "exists": false} — identical to genuinely absent facts. The endpoint does not confirm or deny the existence of facts the caller cannot access.

curl -s http://localhost:8000/v1/facts/abc123/provenance \
-H 'Authorization: Bearer <api-key>'

Lazy instruction discovery endpoints

PUT /v1/agents/{agent_id}/instruction-manifest

Publish or replace the instruction manifest for an agent. The manifest is written with a versioned identifier so old manifests are superseded rather than overwritten in place.

Auth: write scope required.

{
"version": "v1-1746393600",
"entries": [
{
"name": "deployment-checklist",
"description": "Deployment Checklist",
"fact_uri": "instruction:default/agent/{agent_id}/deployment-checklist/v1",
"load_triggers": {
"intents": ["deployment checklist"],
"keywords": ["deploy", "checklist", "release"],
"task_types": []
},
"token_estimate": 340
}
],
"skip_coverage_gate": false
}

POST /v1/agents/{agent_id}/recall-instruction

Retrieve the most relevant instruction units for a given agent intent.

Three-phase retrieval strategy:

  1. Hint resolution — explicit manifest_hint names are loaded first (highest priority).
  2. Ranked retrieval — remaining slots filled by BM25 scoring of intent against each unit's description, load_triggers.intents, and keywords.
  3. Guaranteed units — units with guarantee_load: true are always appended regardless of score; at most 5 per manifest.
Field
Default
Description
intent
required
Natural-language description of what the agent is about to do.
max_chunks
3
Maximum instruction units to load (1–20).
token_budget
2000
Token limit across all returned chunks (1–100 000).
manifest_hint
[]
Explicit unit names to prioritize by name.
curl -s -X POST \
http://localhost:8000/v1/agents/a1b2c3d4-0000-0000-0000-000000000001/recall-instruction \
-H 'Authorization: Bearer <api-key>' \
-H 'Content-Type: application/json' \
-d '{
"intent": "how do I handle a production incident?",
"max_chunks": 3,
"token_budget": 2000
}'

Response includes chunks, total_tokens, truncated, missed_hints, and an audit_token to submit to POST /v1/instruction/audit.


CLI reference — stigmem instruction migrate

The stigmem instruction migrate command is the primary tool for publishing instruction files to a node.

stigmem instruction migrate PATH --role ROLE --agent-id UUID [options]
stigmem instruction migrate PATH --skill SKILL --agent-id UUID [options]
Flag
Default
Description
PATH
required
Markdown file or directory.
--role ROLE / --skill SKILL
mutually exclusive
Scope selector.
--agent-id UUID
required
Agent UUID owning the manifest.
--deployment NAME
default
Deployment namespace.
--version VER
v1
Fact version string.
--node-url URL
localhost:8000
Node base URL.
--api-key KEY
$STIGMEM_API_KEY
API key for writes.
--dry-run
off
Print diff, exit without writing.
-y / --yes
off
Skip confirmation prompt.

Authentication

All endpoints except /.well-known/stigmem and /healthz require an API key. Pass it as a Bearer token:

curl -H 'Authorization: Bearer <your-key>' http://localhost:8000/v1/facts

Set STIGMEM_AUTH_REQUIRED=false to disable auth in development.

OIDC / SSO

Human principals can obtain an API key via OIDC. Configure STIGMEM_OIDC_* env vars; the node validates the JWT and maps role claims to admin|writer|reader.

Multi-tenant requests

Default installs resolve all API keys into the single default tenant. To use non-default tenants, install and enable stigmem-plugin-multi-tenant, then provision API keys with the target tenant_id.

Multi-tenant scoping is experimental in v0.9.0a10. It does not yet provide shared-node readiness, per-tenant quota/resource controls, or tenant-aware non-default federation.

Federation peer tokens

Federation endpoints additionally require an Ed25519-signed JWT peer token exchanged during the federation handshake (Spec-05-Federation-Trust).

Generating interactive docs

# Terminal 1 — start the reference node
cd stigmem/node
uv run python -m stigmem_node

# Terminal 2 — regenerate and serve docs
cd stigmem/docs
npm run gen-api-docs
npm run start
info

The API reference sidebar is populated by npm run gen-api-docs. Until that command has run, only this overview page appears.