Brain Docs

Reference

REST API overviewAuthenticationErrorsPaginationRate limits and request boundsAPI keys
Brain/Docs
✦ ASKBrain on GitHubDashboard
API ReferenceREST API overview

REST API overview

Base URLs, authentication, the response and error shapes, and a reference page for every one of Brain's 60 data-plane and broker routes — plus the two health probes.

PURPOSE

The Brain HTTP API is the hosted edge in front of the database. Brain itself speaks a binary wire protocol — CBOR over TCP — and this JSON API translates a stable /v1/* surface onto it. Every SDK's HTTP client and the dashboard call these routes. This page covers the conventions every route shares; each route then has its own reference page.

Base URL

Point the base URL at your own deployment. brain-edge listens on 0.0.0.0:8080 by default (BRAIN_EDGE_LISTEN), so:

DeploymentBase URL
Self-hostedhttp://<your-host>:8080 — or whatever host and port you put in front of brain-edge
Local devhttp://127.0.0.1:8080 — a brain-edge on the default port

There is no public managed host to point at

This reference does not name a hosted endpoint, because there is not one you can resolve today. If you are on the managed tier, use the base URL your onboarding gave you; otherwise run brain-edge yourself and use its address.

Examples here read the base from BRAIN_BASE_URL rather than hardcoding a host, so a snippet runs wherever your Brain is:

export BRAIN_BASE_URL=http://127.0.0.1:8080   # self-host default
export BRAIN_API_KEY=brain_…

Unset, the samples fall back to http://127.0.0.1:8080 — the same default the Python and TypeScript clients use when you omit the base URL, and what BrainHttpClient::localhost gives you in Rust.

Every data-plane route lives under /v1, except the LLM broker's, which live under /llm. Health probes sit outside both — see Health probes.

Authentication

Send your key as Authorization: Bearer <key>. The self-host edge also accepts X-API-Key. The key carries the identity — there is no namespace, space or scope header. See Authentication.

Response shape

Successful responses return the resource JSON directly. There is no { data: … } envelope:

{
  "memory_id": "20177564117…",
  "was_deduplicated": false,
  "salience": 0.62,
  "kind": 0,
  "created_at_unix_nanos": 1752969600000000000,
  "auto_edges_added": 2
}

Field names are snake_case throughout, in both bodies and query strings. A query parameter sent under the wrong name is not an error — it silently takes the field's default, so a filter appears to be applied and is not.

Error shape

{
  "error": { "code": "not_found", "message": "memory 42 not found" }
}

code is the stable handle — branch on it, never parse message. All fifteen codes, their statuses, and what is safe to retry are at Errors.

Identifiers and time

  • Memory ids are 128-bit values rendered as a decimal string.
  • Entity, statement and relation ids are hyphenated UUID strings.
  • All timestamps are unsigned unix-nanosecond integers (*_unix_nanos), except the credential routes' created_at_unix_secs, which is seconds. 0 means unset.

64-bit values exceed what IEEE-754 doubles hold exactly, so a client that routes them through a stock JSON parser rounds them. The SDKs do not.

Pagination

Seven routes page with an opaque cursor; four bound their result another way, and two of those report a partial answer with a flag rather than a cursor. The distinction matters — see Pagination.

Idempotency

Write verbs carry a request id on the wire, and Brain deduplicates a replay with identical parameters; a replay under the same id with different parameters is a conflict. Over HTTP the edge generates this id per request.

Every route

Routes are grouped exactly as the SDK sections are, so /api/memory/encode and /sdk-python/memory/encode are the same operation seen from the two sides.

AreaWhat it coversRoutes
MemoryThe three verbs, the store-level reads, and memory edges.GET /v1/graph, DELETE /v1/links, POST /v1/links, DELETE /v1/memories, GET /v1/memories, POST /v1/memories, POST /v1/memories/vector, GET /v1/memories/{id}/inspect, POST /v1/recall
Spaces and sessionsProvision and erase a space, and the sessions inside it.GET /v1/sessions, POST /v1/sessions, DELETE /v1/sessions/{id}, DELETE /v1/spaces, GET /v1/spaces, POST /v1/spaces
EntitiesThe typed graph's identity layer.GET /v1/entities, POST /v1/entities, POST /v1/entities/resolve, DELETE /v1/entities/{id}, GET /v1/entities/{id}, PUT /v1/entities/{id}, POST /v1/entities/{id}/merge, POST /v1/entities/{id}/rename, POST /v1/entities/{id}/unmerge
StatementsTyped claims and their supersession chains.GET /v1/statements, POST /v1/statements, DELETE /v1/statements/{id}, GET /v1/statements/{id}, GET /v1/statements/{id}/history, POST /v1/statements/{id}/retract, POST /v1/statements/{id}/supersede
RelationsTyped, directed, time-bounded edges between entities.GET /v1/entities/{id}/relations, POST /v1/entities/{id}/traverse, POST /v1/relations, DELETE /v1/relations/{id}, GET /v1/relations/{id}, POST /v1/relations/{id}/supersede
SchemaDeclare the typed graph, and the extractors bound to it.GET /v1/extractors, GET /v1/schema, POST /v1/schema, PUT /v1/schema, POST /v1/schema/validate, DELETE /v1/schema/{kind}/{name}, GET /v1/schemas
ReasoningPlanning, inference, the procedural block, query introspection.POST /v1/plan, POST /v1/procedural/materialize, POST /v1/query/explain, POST /v1/query/trace, POST /v1/reason
StreamsThe live change feed, over Server-Sent Events.GET /v1/subscribe
CredentialsThe LLM provider key Brain's extraction runs on.DELETE /v1/llm-credential, GET /v1/llm-credential, PUT /v1/llm-credential, POST /v1/llm-credential/test, POST /v1/llm-credential/verify
IntrospectionWho the credential is, and what the shard can do.GET /v1/capabilities, GET /v1/whoami
LLM brokerRelay to a provider using the key you registered with Brain.POST /llm/ns/{namespace}/anthropic/v1/messages, POST /llm/ns/{namespace}/openai/v1/chat/completions, GET /llm/ns/{namespace}/resolve

Transactions are wire-only

There is no HTTP transaction surface. Each route is its own unit. Grouping writes atomically requires the native wire protocol — see Transactions.

Health probes

Two more routes are served, outside /v1 and outside the table above. They take no credential and return no body — only a status — so they are safe to expose to an orchestrator that has no key.

MethodPathReturns
GET/health/live200 whenever the process is up. A static liveness signal; it does not touch Brain.
GET/health/ready200 once a TCP connection to Brain opens inside the probe budget, 503 otherwise.

Use /health/ready as the gate on routing traffic: it answers 503 while the database behind the edge is unreachable, which is exactly the window in which a /v1 call would fail with engine.unavailable. /health/live stays 200 through that window, so restarting on it would be wrong.

They are on the binary, not the library router

brain-edge's reusable router — the one a host application merges — does not register /health/*, so that host can own health itself without a path collision. The brain-edge binary merges the two probes above on top of it, and does so on either plane. So a stock self-hosted deployment serves them; an embedding application may serve its own instead.

Shared pages

PageWhat it covers
AuthenticationHeaders, what a key binds, whoami
ErrorsThe envelope, all fifteen codes, retry rules
PaginationCursors, and the two kinds of incompleteness
Rate limitsPlan metering, back-pressure, body cap, timeout
API keysThe admin plane that mints data-plane keys
See also
AuthenticationPOST /v1/memoriesTypeScript SDK

Was this page helpful?

Policies

The knobs Brain exposes — the four enable/disable categories, per-request recall filters, and worker tuning — and where each one applies.

Authentication

The two accepted headers, how the resolver differs between self-host and the managed gateway, what a key binds, and the whoami probe.

On this page

Base URLAuthenticationResponse shapeError shapeIdentifiers and timePaginationIdempotencyEvery routeHealth probesShared pages
Suggest an editOpen in Playground