/api/v1, next to
the Memory API and hosted brains. They use
the normal signed-in session. For the user-facing guide see Memory Drive.
The drive is the source of truth. The kernel’s memory_facts rows are an index
rebuilt from it after every commit, so /memory/v2/recall keeps working unchanged.
Errors
Choosing a drive
Every route takes an optionaldrive, as a query parameter for GET or a body field
for POST/PUT. The default is personal.
Access is checked on every request, so removing someone from a workspace removes their
access at once, including their git tokens for that drive.
GET /memory/drive/mounts
Every drive you can open.
revision is null for a drive that hasn’t been created yet; opening it creates it.
Files and history
GET /memory/drive/info
Creates your personal drive on first call.
clone_url never contains a credential. usage is { bytes, files, max_bytes, max_files }. pending_writes counts writes whose commit
failed and will be retried.
Writing
POST /memory/drive/write
Applies a batch as one commit, only if the drive is still at expected_revision.
{ revision, changed }. MEMORY.md’s ## Index is regenerated from the topic
files on every write. twin/ is managed by Allternit and can’t be written.
Versions and conflict copies
An entry’s version is the first 12 hex characters of a SHA-256 hash of its stored line (UTF-8, no trailing newline). Clients that edit entries compute it the same way. The server needs no change for it: gizzi checks the version against the latest head before it sends a write withexpected_revision.
When gizzi replays local work after a rejected write, it merges per entry. If both sides changed the same entry differently, the other side keeps the id and the local text is written as a sibling entry with the id <id>-conflict-<8 hex> and the ordinary metadata key conflict_of: <id>. An edit beats a delete. The count of entries with conflict_of is the “N memories need a look” figure. See Memory tools.
POST /memory/drive/remember
Saves one memory without building an entry yourself.
memory_type (facts.md,
preferences.md, events.md, procedures.md, people-and-things.md,
relationships.md, tasks.md) unless you pass path. With session the source is that
session’s link; without it, a manual save from Settings. Returns
{ revision, fact_id, path, entry_id } for the personal drive.
POST /memory/drive/import
Moves memories saved before the drive existed into it.
{}(dry run) returns the plan and changes nothing:{ dry_run: true, plan: { total, converted, skipped, topic_files, already_imported, rows } }.{ "apply": true, "expected_revision": "…" }writes oneImport existing memorycommit. Running it again changes nothing.
POST /memory/drive/import-text
Imports memories from another assistant. Body { text, from, apply?, selected? }, where from is
chatgpt, claude, gemini, grok, copilot, perplexity, meta, kimi, mistral, mem0 or other.
text is plain lines, bullets, a numbered list (code fences are ignored), or JSON (an array of
strings, or objects with content, memory or text, also inside memories, results, items or data, which covers Mem0’s export), up to 500 items and 512 KB.
- Dry run:
{ dry_run: true, plan: { from, path, entries: [text], skipped: [{ text, reason }], remaining } }. apply: true: one commit topath(for exampleimports/gemini.md), returns{ dry_run: false, revision, imported }.selected: [text]imports only those previewed entries.
<assistant>:memory-import (meta-ai: for Meta AI, le-chat: for Le Chat).
Computers older than this change accept only chatgpt, claude and other and answer
400 from must be … for the rest; the app then imports as other.
GET /memory/drive/import-agents
Lists agents on the computer that holds the drive whose memory files can be imported:
{ sources: [{ id, name, files, items }] }, where id is claude-code, codex, hermes or
openclaw. Only these fixed paths under the home folder are read:
Markdown files give one item per bullet or paragraph; headings, tables, code blocks and comments
are left out. Files over 512 KB and symlinks are skipped. Older computers answer 404.
POST /memory/drive/import-agents
Body { source, apply?, selected? }. Same plan and result shapes as import-text. Items run
through the same checks (too long, looks like a secret, listed twice, already remembered) and each
keeps the file it came from as its source, for example claude-code:memory/<project>/<file>.md.
One run takes up to 500 items, newest files first; plan.remaining says how many are left for
the next run. The commit goes to imports/<source>.md.
GET /memory/drive/find-memories
The model that reads exported chats and the request limits:
{ model: "provider/model" | null, max_conversations, max_conversation_chars, max_batch_chars }
(today 20 conversations, 8,000 characters each, 80,000 per request). The model is
ALLTERNIT_MEMORY_MODEL, else ALLTERNIT_GEN_SMALL_MODEL, else the user’s chosen default brain, the
same one that saves memories from chats. There is no built-in model: model is null until a brain
is chosen, and chat memory saving then uses only the rule-based extractor. Older computers answer 404.
POST /memory/drive/find-memories
Body { from, conversations: [{ id, title?, date?, text }] }, where text is the person’s own
messages from one conversation. The app reads the export (ChatGPT or Claude conversations.json,
Gemini’s Takeout MyActivity, the Grok archive) in the browser and sends only this. Returns
{ memories: [{ text, conversation }] } and saves nothing. Requests run two at a time per computer;
when the model doesn’t answer, the reply is 503. With no brain chosen it is
409 {"error":"no_brain","message":"Pick a brain first."}.
POST /memory/drive/import-chats
Body { from, found: [{ text, conversation }], apply?, selected? } (up to 5,000 facts). Same plan and
result shapes as import-text and the same checks. Each line’s source is
<assistant>:conversation/<id>; the commit goes to imports/<assistant>-chats.md.
GET /memory/drive/capture
The capture switches and per-source counts:
{ settings: { channels, gizzi, agent_folders, vendors }, counts: [{ scheme, memories }], agents: [{ id, name, files, items }], verified_channels: [channel], vendor_reads: [...] }. verified_channels lists the channels with a verified owner identity, which channel capture needs.
Switches are stored per user in runtime_settings (key memory_capture); all three are on by
default. agent_folders on by default applies only to the owner the computer is paired as, so a
shared server’s home folder never reaches anyone’s drive. counts groups personal-drive entries by the part
of source: before the colon. Session links and allternit: ids aren’t listed. Older computers answer 404.
PUT /memory/drive/capture
Body: any of { channels, gizzi, agent_folders, vendors }. Returns { settings, imported }. Turning
agent_folders on runs one agent-folder import right away. The API also runs it 5 minutes after
start and then every 6 hours for every owner who has it on (memory_capture::spawn). Turn it off
and use forget-source with the agent’s scheme to prune what it added.
POST /memory/drive/vendors/run
Reads every eligible assistant login of the caller now (vendor_memory::run_owner) and returns
{ reads: [{ account_id, provider, name, status, memories_added, chats_read, chat_memories_added, detail, at }] }.
status is read, busy, needs_you, not_supported, no_model or failed. The same run happens
10 minutes after start and then every 6 hours for every owner with a Sessions computer
(subscription_sync::sync_owners), when the vendors capture switch is on (default) and only for
providers whose Subscriptions disclosure the owner acknowledged. GET /capture returns the last
results as vendor_reads.
Each login read goes through the gateway’s read-only routes:
The gateway answers
409 busy while the login has a task, 409 not_ready with session_health
when it isn’t signed in or shows a check, and 501 when the adapter has no reader. Both imports use
check_auto, so a line the owner removed never comes back. If the model doesn’t answer, the chats
stay unread and are tried next run. Every read is a vendor row in /activity; not_supported
logins are not logged.
POST /memory/drive/capture/turn
Body { source: "gizzi", label: "gizzi:session/<id>", text, role?, turn_id?, tool_name?, tool_input?, tool_output? }.
Gizzi sends the person’s message at the end of each turn. The API records it as a turn_user
observation with the label as its source when the gizzi switch is on, and runs no extraction,
because Gizzi saves memories itself. Returns { recorded }, or { recorded: false, reason } when
nothing was kept (source_off, incognito, empty, repeat).
Every turn is recorded for everyone, with Allternit Sleep on or off:
- The person’s message and the assistant’s last text reply of the turn (
role: "assistant", stored asturn_assistant) are kept up to 64,000 characters. Old clients that send noroleare treated asuser. - Each tool call (
role: "tool", stored asturn_tool) reads<tool_name>, the input clipped to 4000 characters,---, then the output clipped to 16,000 characters; a clipped part ends with[truncated N chars]. Credentials in tool input and output (token shapes, private key blocks andpassword=,token:style pairs) are replaced with[redacted]before storing. - Stored turns are cut into dated windows for raw search.
gizzi
capture switch. A row repeated with the same content in the same session within ten minutes is
dropped (turn_id is accepted for later use).
Channels are captured where messages arrive. In channel_transports::accept_events_with and
in bot email, a message is captured only when its sender matches the account’s verified owner
(channel_auth::Rule::is_owner). It’s recorded with the label <provider>:chat/<chat> and
goes through the same model extraction as a web chat turn (memory_capture::owner_channel_turn).
Facts and Dream lessons from these turns cite that label.
POST /memory/drive/forget-source
Body { scheme }, for example chatgpt, telegram or claude-code. Removes every
personal-drive entry whose source starts with <scheme>: as one commit, up to 2,000 at a time.
It also deletes the raw turns recorded from that source, with their search windows and vectors.
Returns { revision, removed, more }.
Incognito sessions are refused by /memory/v2/retain and /memory/v2/observation, which answer
{ status: "skipped", reason: "incognito" }.
Automatic imports (agent folder syncs, memory_capture::sync_agent_folders) use
text_import::check_auto: besides the usual checks they skip any text the owner deleted or
forgot (a retired memory_facts row with the same text), so a forget sticks. A person’s own
import uses check and can bring a forgotten line back.
GET /memory/drive/activity
What touched the owner’s memory, from memory_activity (V266, src/memory_activity.rs).
Query: after (follow new rows, oldest first), before (page back, newest first), session,
run (a Dream id), kind and limit (default 50, at most 200). Returns
{ items: [{ id, at, kind, title, detail, source, session, run }], cursor }.
detail.items holds up to 20 { text, source } previews (240 characters each) and
detail.total the full count. A row is tied to a session only when every added line came from
that chat (/?session=<id> sources). Rows for incognito sessions are never written. Rows older
than 90 days are dropped. The drive’s git history stays the full record. Older computers answer 404.
POST /memory/drive/activity
An agent working on the owner’s own drive reports what it did. Body
{ kind: "saved" | "recalled" | "forgot", title, items?: [{ text, source }], source?, session? }
Any other kind, including every sleep.* kind, is refused. (at most 50 items; source must be a scheme:value label). Gizzi’s memory_recall and
memory_write tools call it with source: gizzi:session/<id> (best effort, never blocking the tool).
Ledger: GET /memory/drive/ledger, GET /ledger/file, POST /ledger/snapshot, GET /ledger/download
The ledger is a bare git repo beside the personal drive (<drive folder>/ledger.git).
ledger::collect reads the owner’s rows from agents (bots and agents, not archived),
bot_templates, routines, cowork_routines, workflows, open tasks and long_running_tasks,
skills, cowork_projects, cowork_scheduled_tasks, loops, beta_deployments, the safe
columns of connector_connections, each bot’s workspace folder, and the SKILL.md folders in
~/.allternit/skills. It writes them as JSON and Markdown files.
Credential columns (identity_key, principal_id, tokens) are never read. JSON values under
credential-like keys are replaced, git_remote loses its userinfo, and any file with a token shape
(or, for copied files, a password:/TOKEN= style value) is left out and listed in README.md.
ledger::spawn snapshots every owner hourly. A snapshot commits only when the tree changed.
-
GET /memory/drive/ledger:{ revision, files: [{ path, bytes }], history: [{ revision, timestamp, message, changed, paths }] }. -
GET /memory/drive/ledger/file?path=&revision=:{ path, content }. -
PUT /memory/drive/ledger/file: body{ path, content }(up to 1 MB).ledger_edit.rsapplies the edit to the real thing, then saves a snapshot. Returns{ summary, revision }.- Record files update the owner’s row: only columns it has, never
id,user_id, timestamps or the kind’s dropped columns.[left out…]values keep the stored value, including nested JSON. A credential-keyed value typed into the file is refused. - Bot workspace files and files of installed skills are written to disk after a secret check.
README.mdandconnected-apps.jsonare read-only.- A record path not yet in the ledger creates the thing. It gets a new id (or the given one if
unused), with credentials refused and
[left out]values dropped. Scheduled kinds start paused. A missing required field answersAdd "<field>".
- Record files update the owner’s row: only columns it has, never
-
DELETE /memory/drive/ledger/file?path=: bots and agents are archived (archived_at), other records are deleted, and workspace and skill files are removed (notSKILL.md). Then it snapshots. Returns{ summary, revision }. -
POST /memory/drive/ledger/snapshot:{ changed, revision }. -
GET /memory/drive/ledger/download?revision=:application/zipwith everything underledger/. -
POST /memory/drive/ledger/restore: body{ files: { "<ledger path>": "<text>" }, apply? }(up to 5,000 files, 40 MB). Returns{ dry_run, plan: { items: [{ kind, path, name, action, reason, needs, paused }], files_added, files_kept, reconnect: [{ connector, account }] } }, whereactionisadd,already_hereorskip.ledger_restore.rskeeps each record’s id. It writes only the columns the table has here, withuser_idset to the caller. It drops[left out…]values and lists them inneeds. It pauses routines, scheduled messages, schedules, loops and scheduled runs. It adds bot workspace files and skill folders without overwriting anything. Applying saves a ledger snapshot.
Copies: GET/PUT /memory/drive/copies, POST /memory/drive/copies/run
Copies of the drive and ledger kept elsewhere (memory_copies.rs), stored per user in
runtime_settings (key memory_copies).
GETreturns{ folder: { path, status } | null, git: { url, has_token, status } | null }, wherestatusis{ last_at, last_error }. The token is never returned.PUTtakes{ folder_path?, git_url?, git_token? }.""stops that copy; an absent field leaves it as it is. The folder must be an existing absolute path. The remote must be HTTPS with no credentials in it. The token is sealed with the platform key, and the request is refused if sealing isn’t available. The ledger is saved and both copies run once before the reply.POST /runsaves the ledger and runs the copies now. They also run after each hourly ledger snapshot.
<folder>/Allternit/{memory,ledger}/… and removes only files listed in its
.allternit-copy.json (path → content hash). It never writes through a symlink.
Two-way. Before writing, a run compares the copy with what it last wrote. For a folder that’s the
manifest hashes; for git it’s the commits it last pushed (last_memory, last_ledger), against a
fetch of the two branches. Changed, added and deleted files go through memory_copies::apply_inbound:
- ledger files through
ledger_edit::edit/delete; - memory files as one checked
memory_drive_scopes::apply_forbatch.
<path>.conflict-<time> in the folder, or its commit is pushed to
allternit-conflicts/<branch>-<time>. status reports applied, conflicts and failed.
Re-saving the same remote keeps last_*, so remote edits are never overwritten unseen. The git copy force-pushes the drive to
allternit-memory and the ledger to allternit-ledger (force, because “delete forever” rewrites
history). The token goes to git as an http.extraHeader through GIT_CONFIG_* environment
variables, never on the command line or in the URL. Push errors are reported in plain words and
never include the token.
POST /memory/drive/purge
Permanently removes entries from the drive and its whole history.
Body { drive?, expected_revision, entry_ids: [id], confirm: "delete forever" } (1 to 200 ids;
for lines without an id, use the derived entry-<sha256> id). Returns { revision, purged }.
Commit messages, authors and dates are kept; stored revisions (index, import, Dreams) are
remapped; Dream reports that quoted a purged memory are replaced with a note. Purged ids and
text are refused from then on, on writes and pushes. Clones made before the purge keep their copy.
POST /memory/drive/reindex, GET /memory/drive/health
Rebuild the index from the drive now, and report { revision, indexed_revision, index_dirty, imported_at, pending_writes }.
Clone tokens
A token opens exactly one drive. A
read token can clone and fetch; a write token can
also push. Use it as the git password, never in the URL:
main, fast-forward only, at most
200 commits, every file a markdown file in the standard format, no possible credentials,
and no changes to twin/. A refused push prints Memory Drive refused this push: and the reason. After an accepted push the index is rebuilt.
Nightly Dream
status is running, applied, no_changes, failed or undone. summary counts
merged, resolved, lessons, pruned, proposals and skipped. See
how Dreaming works. With Dreaming on, the knowledge curator runs after a Dream that applied or made no changes, and its report line, Curator: N knowledge proposal(s) waiting for review., is added to the Dream’s report.
Questions board
For team, project and swarm drives. Questions and answers live inquestions.md.
status is open, answered (at least one answer) or resolved. Bots reach the same board
through the MCP tools memory_questions, memory_ask and memory_answer (with drive), using
their owner’s membership. Concurrent askers and
answerers never overwrite each other: each change is retried on the latest version.