E
Engram

API Reference

REST API

The Engram API runs at localhost:8000. All endpoints use JSON. Authenticated routes require an API key in the X-API-Key header.

Authentication

Set ENGRAM_API_KEY in your .env, then send it on every request via the X-API-Key header.

bash
# Generate a key once and add it to .env
echo "ENGRAM_API_KEY=$(openssl rand -hex 32)" >> .env

# Use it on every request
curl localhost:8000/api/memories \
  -H "X-API-Key: <your-key>"

Dev mode

If ENGRAM_API_KEY is not set, the API runs in dev mode: all requests are treated as a local admin user. Fine on an air-gapped machine, but set a key before exposing the port to your network.

Chat

Base: localhost:8000

MethodEndpointDescriptionAuth
POST/chatAsk a question grounded in your memories. Set stream: true for SSE token streaming; the final event carries context_used (sources).🔒
POST/v1/chat/completionsOpenAI-compatible chat endpoint — point any OpenAI SDK client at Engram.🔒
POST/v1/embeddingsOpenAI-compatible embeddings endpoint backed by nomic-embed-text.🔒

Memory

Base: localhost:8000

MethodEndpointDescriptionAuth
GET/api/memoriesList memories with matter_id / type / classification filters and cursor pagination.🔒
POST/add-memoryStore a new memory explicitly. Body: { text, matter_id? }.🔒
POST/ingestIngest document text (used by the file ingestor). Supports document_keys for structured docs.🔒
DELETE/api/memory/:idDelete a single memory point with ownership check.🔒
DELETE/api/memoriesBatch-delete by matter_id with optional type filter.🔒

Base: localhost:8000

MethodEndpointDescriptionAuth
GET/searchSemantic search over personal memories (second_brain).🔒
POST/api/docs/querySemantic search over the doc_knowledge collection.🔒
GET/api/search/unifiedMerged search across both collections, ranked by score.🔒

Knowledge

Base: localhost:8000

MethodEndpointDescriptionAuth
POST/api/docs/ingestStore crawled documentation pages (used by DocSpider).🔒
GET/api/modelsList models available on the local Ollama instance.🔒

Agents

Base: localhost:8000

MethodEndpointDescriptionAuth
POST/run-agents/calendarTrigger the calendar agent immediately (also runs every 15 min via APScheduler).🔒
POST/run-agents/emailTrigger the email agent immediately (also runs hourly via APScheduler).🔒
GET/api/audit/logsRecent agent activity from the tamper-evident audit log (admin only).🔒
GET/api/audit/verifyVerify the HMAC hash chain over the audit log.🔒

Users & Matters

Base: localhost:8000

MethodEndpointDescriptionAuth
GET/api/meReturns the profile of the currently authenticated user.🔒
GET/api/mattersList matters (projects) the current user can access.🔒
POST/api/mattersCreate a matter. Query param: name.🔒
POST/api/matters/:id/closeClose a matter and purge its memory points.🔒

Example: Unified Search

bash
curl "localhost:8000/api/search/unified?query=vendor%20contract%20renewal&n_results=5" \
  -H "X-API-Key: <your-key>"
json
{
  "results": [
    {
      "source": "second_brain",
      "score": 0.92,
      "text": "Renewal notice: the hosting contract auto-renews on 1 Sep...",
      "type": "file_ingest"
    },
    {
      "source": "doc_knowledge",
      "score": 0.71,
      "text": "Contracts API — renewal webhooks fire 30 days before...",
      "type": "documentation"
    }
  ]
}