TETHESIS
DocumentationHTTP API
DOCUMENTATION · HTTP API

HTTP API

One JSON-over-HTTP surface: run Cypher, manage graphs and schema, stream large results, and, on your own server, watch it with Prometheus and OpenTelemetry. Everything the SDKs and MCP server do, they do over this.

QUERY

Cypher over HTTP

Post a query and parameters; add a time field to rewind the read. Every request carries a bearer key.

curl -X POST "https://invariantdb.com/graphs/$GRAPH/cypher" \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{ "query": "MATCH (e:Event) RETURN count(e)", "atRecorded": "2026-04-13T15:47:00Z" }'

The body is { "query": "…", "parameters": { … } }, with an optional atValid or atRecorded. A write may carry conditions and an idempotency key. A query over the 2 MiB body limit is refused with a clear error rather than truncated.

WRITES

Idempotency keys and conditions

A write can carry an Idempotency-Key header; a resend with the same key after a lost answer writes nothing more, and GET /graphs/{name}/idempotency-keys/{key} reports what the first attempt did. A write can also carry conditions, checked under the graph’s write lock just before commit; if one fails the answer is 409 CONDITION_FAILED and nothing is written. Conditions are off by default on a self-hosted server, and on for the hosted service.

POST /graphs/a1b2c3_vault/cypher Idempotency-Key: merge-an-512-1 { "query": "MATCH (a:Analysis {id: $id}) SET a.raw = $merged", "parameters": { "id": "an-512", "merged": "..." }, "conditions": [ { "node": "an-512", "rev": "1792310400123456789" } ] }
GRAPHS & SCHEMA

Registry and declarations

# graphs are created in the dashboard; list, inspect and drop over the API GET /graphs GET /graphs/{name} DELETE /graphs/{name} # schema is versioned; ACL, encryption + vector indexes come from it GET /graphs/{name}/schema POST /graphs/{name}/schema GET /graphs/{name}/schema/history
STREAMING

Cursors for large reads

Stream a big result set instead of materializing it server-side. Cursors are read-only.

POST /graphs/{name}/cursor { "query": "MATCH (n:Event) RETURN n", "batch_size": 1000 } # returns a cursor; page with GET /graphs/{name}/cursor/{cursor_id} until drained
MORE ROUTES

Beyond query and schema

Each of these is a route group in the feature reference. Several are off by default on a self-hosted server and on for the hosted service.

  • Multi-statement transactions — POST /graphs/{name}/tx, /tx/{id}/cypher, /tx/{id}/commit; serializable, constraints checked at commit. Off by default; on for the hosted service.
  • Change feed — GET /graphs/{name}/changes?after=<position>, one event per commit. Off by default; on for the hosted service, except for credentials an access policy restricts. Server-held cursors (/changes/cursors/*) are off by default.
  • Leases — /graphs/{name}/leases/*. Off by default; on for the hosted service.
  • Search — POST /graphs/{name}/search/fulltext and /search/vector.
  • Bulk load — POST /graphs/{name}/bulk (NDJSON; one batch is one commit). Off by default.
  • History checks — GET /graphs/{name}/audit/verify and /graphs/{name}/provenance/verify.
  • Cancel a running statement — POST /cancel/{id}; list them with GET /admin/queries.
ERRORS

One error envelope, with a retry answer

Each error has a code, usually a subcode, and a retry field (retryable, terminal or ambiguous): decide on retry, and branch on code and subcode. Unknown body fields are refused rather than ignored. A graph still opening after a restart answers 503 GRAPH_OPENING with Retry-After; a statement that cannot get the query memory it needs within its wait is stopped with 503 QUERY_MEMORY_BUDGET (Retry-After), and nothing of it is written.

{ "subcode": "LEASE_LOST", "retry": "terminal", "details": { "executed": false, "write_committed": false, "key": "task:42", "reason": "superseded" } }
OBSERVABILITY & OPS

Operations

  • GET /healthz — liveness; GET /metrics — Prometheus metrics for the server operator (scrape token).
  • POST /graphs/{name}/explain returns the plan with row estimates, without running it; /graphs/{name}/explain-analyze (or EXPLAIN ANALYZE) adds timing and row counts.
  • GET /openapi.yaml and a rendered Swagger UI at /docs; OpenTelemetry traces over OTLP when the operator sets an endpoint (self-hosted).
  • Per-key rate limits, per-query timeouts, a slow-query log, and memory-aware admission: statements wait for query memory and are stopped with nothing written if it doesn’t come; under memory pressure the server stops the statement holding the most memory.
  • Operator routes for compaction, warm-up, backup and restore — and the audit, provenance and compliance verify/export endpoints.
AUTH

Data calls carry a credential

Pass a credential on every data call: Authorization: Bearer gq_…. Health, docs and the OpenAPI spec are open. The full set of modes — static tokens, runtime API keys, JWT, HMAC, capability tokens and tenancy isolation — is on the auth page.

Build against the surface