Docs

Concepts

The primitives in a memlane space - members, memories, journal, records, actions, KV, events, context, batch, and forget - and how they fit together.

Everything lives in a space: one memory box. A space has members (each an agent with its own key), a timezone, a dream mode, and these stores:

PrimitiveWhat it holdsTypical use
MemoriesShort facts, recalled by words and by meaningPreferences, people, decisions
JournalOne entry per day (and per week)What happened, decisions, open loops
RecordsTyped JSON in named collectionsCommitments, goals, routines, contacts
ActionsAn approval ledgerAnything with side effects that needs a yes
KVNamespaced JSON valuesSettings, sync cursors, locks
EventsA capped append-only logRun history, audit breadcrumbs

Two calls tie them together: GET /v1/context reads what a run needs in one go, and POST /v1/batch writes several things atomically. Dreaming tidies memory overnight, and forget deletes things for good.

Spaces

On the hosted service a space belongs to an account. An agent joins one with device connect: POST /v1/connect returns a link to show the person, who signs in (or creates an account) and picks one of their memories or starts a new one. The agent then polls POST /v1/connect/token and gets its own api_key (om_...), once. Apps with OAuth sign-in open the same sign-in page. See Quickstart. People sign in at https://memlane.sh/sign-in and manage their memories on the dashboard.

POST /v1/spaces creates a space with no account. The service refuses it with 403 account_required and a pointer to device connect (POST /v1/connect); it is kept for compatibility. Where it is allowed, the response contains space_id, member_id, api_key (om_...), and recovery_code (omr_...): you are the space's first member and its owner. The key and the recovery code are each shown once. Only their SHA-256 hashes are stored. Send name to name yourself (default owner).

Send the key on every other call as Authorization: Bearer om_... or X-API-Key: om_.... MCP clients that support OAuth can sign in instead. If every key is lost, the recovery code adds a new owner: see Keys and recovery.

  • GET /v1/space shows settings, usage counts, limits, warnings (each limit the space has used 80% or more of), and delete_after (when the space will be deleted if it stays unused).
  • PATCH /v1/space changes name (up to 80 characters), timezone (IANA name), or dream_mode (client, server, or off). Owners only.
  • POST /v1/space/recovery makes a new recovery code and ends the old one. Owners only. POST /v1/space/recover uses one, with no key.
  • GET /v1/export returns everything as one JSON document.
  • DELETE /v1/space deletes the space and everything in it, permanently. Owners only.

Spaces are isolated: one key can never read or change another space. Spaces unused for 90 days (by any member) are deleted.

Members

Each agent that uses a space is a member with its own key, a name, and a role (owner or member). Owners invite others with a one-time code (invite_create); the invited agent redeems it (POST /v1/invites/accept) and gets its own key, or an app pastes it on the OAuth sign-in page. Removing a member stops only its key. member_list shows the app each member last connected from (client) and, for apps that signed in, their OAuth client (oauth).

Everything written records its author (the member that wrote it) next to origin, and updated_by when it changes. get_context says who you are (you) and, in a shared space, who else is in it. See Share a memory box.

Memories

A memory is one fact, in one or two sentences.

json
{
  "subject": "Sam",
  "text": "Prefers code reviews on Thursdays",
  "tier": "core",
  "tags": ["work"],
  "source_ref": "slack:C123/1712",
  "pinned": false,
  "origin": "user",
  "expires_at": null
}
FieldMeaning
subjectWho or what it is about (up to 200 characters). Optional.
textThe fact (1 to 4,000 characters). Required.
tiercore facts are always in context. long (default) facts are recalled on demand. scratch facts are short-lived.
tagsUp to 20 tags of up to 50 characters each.
source_refWhere it came from (message id, URL). Do not paste message bodies here.
pinnedPinned facts are always in context and never changed by dreaming.
originuser when the person stated it, agent (default) when the agent inferred it. Dreaming writes dream.
expires_atOptional ISO 8601 time after which the fact is hidden and later removed.

Writing the exact same subject and text again returns the existing fact (200, created: false) instead of storing a duplicate.

Recall (GET /v1/memories, MCP recall) finds facts two ways at once and merges the results, best first:

  • By words: full-text matching that ignores case and accents and works in any script, including Greek (final sigma and tonos are folded). Any word may match. Words of three or more letters match as prefixes and in their other English forms ("attend" finds "attending"); stray letters and common English words such as "is" or "my" are ignored, unless the query has nothing else.
  • By meaning: q and every fact are turned into embeddings, so "when is my partner's birthday?" finds "My wife was born on 3 March" even though they share no words. Meaning search is tuned for English.

Facts about a person or thing the question names rank first: the fact's subject is that name, or the name appears in it as a whole word. "What do I know about Ana?" puts facts about Ana above a fact that says "Analysis". Pinned and core facts get a small boost. Each returned fact has match: keyword, meaning, or both. The response also has search, which says what ran: mode is hybrid, keyword, semantic, or list, and meaning is used, not_requested, off (not enabled on this server), budget (the daily spend limit was reached), or error. entities lists the names that boosted results, when any did. Whenever meaning search is not used, the results come from word search alone, so recall always answers.

Pass mode=keyword for exact names, ids, and codes, or mode=semantic for meaning only. A q with no letters or digits, such as ?!, finds nothing. Without q it lists facts: pinned first, then core, long, scratch, newest first. The list has total, and next_cursor to pass as cursor for the next page. Listing everything doesn't count as a recall, and it leaves out facts that were replaced or have expired (GET /v1/export includes them). You can filter by subject (exact, case-insensitive), tier, or tag; filters apply to both kinds of match.

A new or edited fact is findable by words immediately and by meaning after a few minutes at most, usually two or so, while the vector index catches up. Until then, search.indexing counts the matching facts that may not be findable by meaning yet, so an empty mode=semantic result with indexing set doesn't mean nothing is stored. It is left out when there are none, and on a full page of results.

Each recall increments recall_count on the facts it returns (pass touch=false over REST to skip that). Dreaming uses recall counts to decide which facts to promote to core.

Remember from a conversation turns a conversation into facts using your agent's own model, so the server runs no model and keeps no copy of the conversation. The MCP tools for it are listed with ?tools=all:

  1. POST /v1/memories/extract (MCP extract_job) with messages, or just about if your model already has the conversation. It returns instructions, input (including up to 15 related facts already stored), and output_schema.
  2. Run those through your model and send its JSON to POST /v1/memories/extract/result (MCP extract_submit). Up to 20 facts are stored in one transaction.

A fact can set replaces to the id of an older fact it changes ("moved to Lisbon" replaces "lives in Athens"). The older fact is hidden right away and removed by the next dream, which can be undone. Until then, PATCH its expires_at to null to bring it back. Pinned facts are never replaced, and only a fact the person stated can replace another fact the person stated; the response's skipped lists any that were refused.

Import stores many facts at once: POST /v1/memories/import (MCP memory_import) takes up to 500 facts, or text with one fact per line, such as a memory list pasted from ChatGPT or Claude. They are stored in one transaction as origin user, tagged imported and the source, and facts already stored are skipped. See Export and import.

Change a fact with PATCH /v1/memories/{id}. Delete one with DELETE /v1/memories/{id}, or many with forget.

Journal

One entry per date and kind. kind is day (default) or week. Dreaming writes week digests.

bash
curl -s -X PUT https://api.memlane.sh/v1/journal/2026-11-01 \
  -H "Authorization: Bearer $MEMLANE_KEY" -H 'content-type: application/json' \
  -d '{"summary":"Shipped the export endpoint","decisions":["Use JSON, not CSV"],"open_loops":["Ask Sam about retention"],"merge":true}'

PUT replaces the entry unless merge is true. With merge, the summary is appended on a new line and the lists are combined without duplicates. Lists hold up to 50 items of up to 500 characters each, and the summary up to 4,000 characters. GET /v1/journal lists entries newest first, filtered by from, to, and kind.

Records

Records are typed JSON objects in named collections (commitments, goals, routines, anything you like). Collection names use letters, digits, _, ., and -, up to 64 characters. Names starting with dream. are written by dreaming.

json
{ "key": "deck-for-sam", "status": "open", "due_at": "2026-11-05T09:00:00Z", "data": { "what": "Send Sam the deck" } }
  • Upsert by key. POST /v1/collections/{collection}/records with a key updates the record that has that key (and bumps its version). Fields you send replace the old values, and fields you leave out keep them, so {"key": "deck", "status": "done"} changes only the status. data is replaced whole when sent; to change single fields, use PATCH. Send "due_at": null to clear a due date. Without a key it always creates.
  • Compare-and-set. PATCH takes expected_version. If the record has moved on, you get 409 with current_version in the error details.
  • Shallow merge. PATCH merges data into the existing object. Set a field to null to remove it.
  • Query by status (comma-separated), key, or due_before. Results are ordered by due date (undated last). Page with next_cursor.

Records whose status is done, dropped, closed, cancelled, archived, or rejected count as closed. Every other status counts as open for context.

Actions

The approval ledger. An agent proposes something with side effects, the owner approves it, and execution is recorded with a receipt.

bash
curl -s -X POST https://api.memlane.sh/v1/actions \
  -H "Authorization: Bearer $MEMLANE_KEY" -H 'content-type: application/json' \
  -d '{"class":"email_reply","summary":"Reply to Sam: Thursday works","payload":{"to":"sam@example.com","body":"Thursday works"},"idempotency_key":"reply-sam-1712","expires_at":"2026-11-03T18:00:00Z"}'
  • Each action gets a short id per space: A1, A2, ... Ids are case-insensitive (a7 works).
  • Idempotency. Reusing an idempotency_key with the same payload returns the existing action (200, created: false). Payloads are compared by content, so key order does not matter. The same key with a different payload is a 409. The action comes back in whatever status it is now, so check status: a denied action stays denied, and retrying can't reopen it. To ask the owner again, use a new key.
  • Compare-and-set transitions. POST /v1/actions/{id}/transition with {"from": "approved", "to": "executing"} succeeds only if the action is still approved. Two workers cannot both execute A7.
  • Expiry. Pending or approved actions past expires_at become expired and can no longer be approved or executed.
  • Receipts. Send receipt (any JSON object) with to: "done" or to: "failed" to record what happened.
  • Meta. PATCH /v1/actions/{id} with {"meta": {...}} merges into meta in any status, for example to keep a chat message id with the action. Set a field to null to remove it. Nothing else can be changed, so what the owner approved stays as it was.

Allowed transitions:

FromTo
pendingapproved, executing, denied, expired, superseded, blocked
approvedexecuting, denied, expired, superseded
executingdone, failed
blockedpending, denied, superseded
failedpending
done, denied, expired, supersedednone (final)

GET /v1/actions lists open actions (pending, approved, executing) by default. Pass status=done,failed for others.

KV

Namespaced JSON values for settings, cursors, and small state. A namespace uses the same name rules as collections. Namespaces starting with _ are reserved. Values can be any JSON up to 64 KB.

PUT /v1/kv/{ns}/{key} with {"value": ..., "expected_version": n}:

  • omit expected_version to upsert,
  • 0 to create only (fails with 409 if the key exists, which makes a simple lock),
  • n to update only if the value is still at version n.

expires_at makes a value disappear after a time. GET /v1/kv/{ns} lists a namespace and GET /v1/kv/{ns}/{key} reads one value.

Events

An append-only log of small structured entries: {"kind": "run", "key": "daily-brief", "status": "ok", "detail": {...}}. It is capped per space and the oldest events are dropped first. List newest first with filters kind, since, and before_id (for paging). Keep message bodies and secrets out of detail.

Activity

GET /v1/activity (MCP activity_list) shows who did what, newest first: the member, the op (memory.remember, action.approved, forget, member.joined, ...), and the item's id, never its text. Filter by member (me or an id), op (or a prefix such as memory), and since. Rows are kept 30 days. See Activity log.

Context

GET /v1/context (MCP get_context) is the one call to make at the start of a run. It returns:

FieldContents
now, timezone, todayThe current time and the space's local date.
profile.textPinned and core facts, one per line (- Subject: text [mem_id]), cut to budget_chars. truncated tells you whether some were left out.
profile.dream_summaryThe owner profile written by the last dream, if any.
dueOpen records due within due_within_days.
open_recordsOpen records, soonest due first, with undated ones last. All collections unless you name some in collections, including dream proposals. Up to open_limit.
open_records_totalHow many open records there are, including any past open_limit.
actionsPending, approved, and executing actions.
journalDay entries from the last journal_days days.
weeklyThe latest weekly digest.
kvThe namespaces you list in kv, as {ns: {key: value}}.
last_dreamId, status, finish time, and report of the most recent dream.
warningsOnly when the space has used 80% or more of a limit: one line per limit, with what to do. Tell the person. See Limits.

Parameters: budget_chars (200 to 20,000, default 4,000), journal_days (0 to 31, default 7), due_within_days (0 to 90, default 7), kv (comma-separated namespaces), collections (comma-separated, limits due and open_records), and open_limit (0 to 50; default 20 across all collections, or 50 if you name collections; 0 leaves them out).

Batch

POST /v1/batch applies up to 50 writes in one transaction: all succeed or none do.

json
{
  "ops": [
    { "op": "memory.remember", "input": { "text": "Sam is out Nov 10-14", "origin": "user" } },
    { "op": "journal.put", "date": "2026-11-01", "input": { "summary": "Planned the review", "merge": true } },
    { "op": "record.update", "collection": "commitments", "id": "rec_...", "patch": { "status": "done", "expected_version": 3 } },
    { "op": "action.transition", "id": "A7", "input": { "from": "executing", "to": "done", "receipt": { "message_id": "m1" } } },
    { "op": "kv.set", "ns": "cursors", "key": "gmail", "input": { "value": { "history_id": 4411 } } },
    { "op": "event.append", "input": { "kind": "run", "status": "ok" } }
  ]
}

Ops: memory.remember, memory.update, memory.delete, journal.put, record.put, record.update, record.delete, action.propose, action.update, action.transition, kv.set, kv.delete, event.append.

The response is {"results": [...]} with one result per op, in order. A failed version or status check, or a missing row, aborts the whole batch with 409. error.details has op_index and op, and the message names them too. They are left out in the one case that can't be told apart: when an earlier op in the same batch caused the failure, for example two ops deleting the same fact. Ops that read first (record.update, a journal merge, action.propose) see the state from before the batch.

Over MCP, send the same ops to batch_apply.

Forget

POST /v1/forget (MCP forget) removes things for good. See Forget and privacy for the full rules.

json
{ "query": "Sam Lee", "scopes": ["memories", "records", "journal", "actions", "kv", "events"], "dry_run": true }
  • ids deletes those memories (up to 200).
  • query deletes memories containing all of its words as whole words, plus records, journal text, KV entries, and events containing the exact phrase, and redacts actions containing it. It only looks in the scopes you list, and the default is memories alone. The response's not_searched names the rest.
  • Journal text is redacted by default (the phrase becomes [forgotten]). Set journal_mode: "delete" to delete the entries instead.
  • dry_run: true returns what would be deleted without deleting anything.
  • truncated: true means more matched than one call handles. Run it again.

Deleted and redacted items leave content-free tombstones (kind, id, and time only).

Errors

Errors have one shape: {"error": {"code", "message", "details"?}}.

StatusCodeWhen
400bad_requestInvalid input. details.issues lists the fields.
401unauthorizedMissing or unknown key.
404not_foundNo such item in this space.
409conflictA version, status, or idempotency check failed.
413bad_requestRequest body larger than 256 KB.
422quota_exceededThe space is full for that kind of item. See Limits.
429rate_limitedToo many requests. Retry in a minute.