Documentation menu / searchSearch documentation →

Start here

Quick startConnect through MCPOpenCode native memoryOpenCode memory controllerMemory API & local models

Use the service

Memory & compactionMemory lifecycle controllerLocal agents & swarmsCLI referenceHTTP reference

Run a node

ConfigurationOperations & backupsLocal memory & ARM

Evidence

Performance & device targetsFull retrieval reportBenchmark methodologyEvaluation policyMemory benchmark notes

Build with us

Architecture & schemaTechnology & learning mapRepository maintenanceContributingSecurityWebsite & deploymentSearch & agent discoveryPrivate product measurementEngineering references

Project

Cleanup & release planRoadmapLocal AI memory: when instantKV fitsFeaturesChangelog

History

Verification history

Proposals

Distributed memory proposal

Use the service / single-node · source MVP

HTTP reference

Authenticated routes, conditional writes, TTL, errors and examples.

This guide describes the Rust node’s /v1 API. The public website serves documentation; its retired demo API returns HTTP 410. For remote access, use TLS at a reverse proxy or an SSH tunnel.

Authentication and keys

When authentication is enabled, /v1 requests require Authorization: Bearer TOKEN. Credentials determine the permitted namespace and operation pairs. /healthz is public; /metrics requires a stats grant. Never put tokens in URLs or memory values.

Treat a UTF-8 record key as one percent-encoded path segment: project/stack becomes project%2Fstack. Key size limits apply after decoding. Generic keys beginning __ are reserved for checkpoint internals.

Routes

Use /v1/namespaces/{namespace} as the base:

Method and pathRequest / response
POST /memoriesStructured memory; create-only or revision-protected update; returns memory, key, revision and timestamps
GET /memoriesTopic/tag/query/since_ms/until_ms/limit/max_bytes/cursor; bounded values; requires get + list
POST /searchJSON query and optional filters; BM25 scores, next_cursor and work counters; requires get + list
GET /memories/{key}Exact structured memory with revision and timestamps
DELETE /memories/{key}Deletes structured memory and indexes; optional If-Match; 204
PUT /records/{key}Raw value bytes; optional ttl_seconds query; returns revision, bytes, write/expiry timestamps
GET /records/{key}Original bytes, namespace content type and quoted revision ETag
DELETE /records/{key}Deletes an ordinary key; 204 on success
GET /recordsprefix, limit, cursor query; bounded metadata page
GET /statsLogical namespace entries, bytes and revision counters
POST /checkpointsTyped checkpoint request; returns receipt with stable locator and latest revision
GET /checkpoints/{id}Bounded restore response; max_bytes query
GET /sessions/{agent}/{session}/latestRestore the session’s latest checkpoint; max_bytes query
DELETE /checkpoints/{id}Prunes an old bundle; 204; refuses deletion of current latest

Record reads choose application/json, text/plain; charset=utf-8 or application/octet-stream from the namespace admission kind. Metadata/checkpoint responses are JSON. The node sends Cache-Control: no-store.

Memory routes belong to the unreleased source MVP. POST /memories uses a nested memory object. MCP accepts those fields directly. Memory guide · Schemas.

Ranked requests also accept expand (default false) and expansion_terms (default empty). Responses report query_reduced, selected_terms, index_reads, scored_candidates, expansion_terms and truncated. See the memory guide for limits and the ranked cursor upgrade rule.

The original KV and checkpoint routes remain compatible. Time filters use inclusive Unix milliseconds. Continue with the same cursor filters, including after empty pages.

First record over HTTP

After local setup, load only your generated private credentials file. Disable shell tracing before loading credentials.

The example sends the token through stdin, not a process argument:

set +x
. .instantkv/credentials.env
printf 'header = "Authorization: Bearer %s"\n' "$INSTANTKV_APP_TOKEN" |
  curl --config - --fail-with-body --request PUT \
    --header 'Content-Type: application/json' \
    --header 'If-None-Match: *' \
    --data '{"content":"Rust + redb"}' \
    'http://127.0.0.1:8080/v1/namespaces/knowledge/records/project%2Fstack'
printf 'header = "Authorization: Bearer %s"\n' "$INSTANTKV_APP_TOKEN" |
  curl --config - --fail-with-body --include \
    'http://127.0.0.1:8080/v1/namespaces/knowledge/records/project%2Fstack'

Supply each worker’s scoped token through its secret environment. Target the worker’s private namespace.

The complete server credentials file belongs to the operator. MCP and CLI handle bearer authentication for you.

Conditional writes and TTL

For conditional raw KV writes, use one of these headers:

  • If-None-Match: *: create only if the key is absent.
  • If-Match: "REVISION": update or delete only the observed revision.

Without either header, raw KV writes and deletes are unconditional. Conflicts return 409. Revision conditions do not retrieve historical values. Structured memory instead uses if_revision in its POST body and If-Match on DELETE.

?ttl_seconds=60 sets the TTL for a raw KV write. Namespace default, required and maximum TTL rules still apply. Above-limit requests fail. Checkpoint namespaces require durable storage, no TTL and no eviction. Configuration.

Checkpoint and restore

POST the checkpoint example with Content-Type: application/json. Use a unique ID for each new checkpoint. Set expected_latest_revision to the previous receipt’s latest_revision.

Restore defaults to 32 KiB. It accepts budgets from 512 bytes to 1 MiB. An insufficient budget returns an error instead of removing essential fields. References report current status and revision without including every value. Save requires GET permission on referenced namespaces. Restore reports forbidden if current grants deny those references. Checkpoint contract.

Errors and retries

StatusMeaning / next action
400Invalid request, policy violation or budget; inspect the body and fix input
401 / 403Missing/invalid credential or insufficient grants
404Missing namespace, record or checkpoint; expired records are unavailable
409Revision/payload conflict or protected latest checkpoint
413Request body exceeds configured limit
507Logical namespace quota exceeded; delete deliberately or adjust policy
503Storage unavailable or admission full; inspect logs or back off
504Response deadline; a submitted write may still commit

Application errors contain error.code, error.message and error.retryable. Framework body/query errors can use another response shape.

After a timeout, inspect the revision or retry the same checkpoint ID with the same payload. Do not retry by overwriting with a new ID.

The timeout limits the response wait. It does not cancel a transaction that has already started.