Overview
The Files drive serves the files on one computer to the owner’s other devices. Every request names roots and items by opaque ID, never by path. Writes carry the revision the client last saw, so a stale write becomes a conflict copy instead of an overwrite. Big files move as content-defined chunks that resume after a dropped connection. The full contract lives in the platform repo atcontracts/files-drive/SPEC.md, with JSON schemas in contracts/files-drive/schema/ and generated Rust, TypeScript, Swift and Kotlin types. The protocol itself is described in the Files drive API. This page covers the runtime side: the routes allternit-api answers on the computer that owns the files, plus the cloud-api sharing routes and guest gateway in Sharing and the guest gateway. The other cloud-api routes (wake consent, endpoints) are documented with their own release.
The Files drive ships dark. On the runtime it is off unless the process runs with
ALLTERNIT_FILES_DRIVE=1. While it is off, every route answers 403 feature_disabled and nothing is created on disk. The per-user files_drive flag is held by cloud-api and read by clients as flags.files_drive in GET /api/v1/me/flags (read-only; a PUT naming it is a 400). A gizzi that is only paired reads it with its runtime device credential, which GET /me/flags accepts read-only (Account flags).Base URL
POST /api/v1/runtime-devices/{computer_id}/proxy with path set to /api/v1/files/v2/....
Authentication and callers
Requests go through the platform auth middleware like every other runtime route. The runtime then decides the principal:
A request replayed by the relay (it carries
x-allternit-relayed), forwarded by a proxy, or sent from a non-loopback peer is a relayed caller. Relayed callers reach registered roots only, which is all v2 exposes, and a folder they add starts with sharing and agent access turned off.
Two more headers matter:
X-Allternit-Device-Namenames the device in conflict-copy names when the request does not say.X-Allternit-Unlockis the proof of a fresh device unlock (Face ID, Windows Hello). Protected roots answer403 protected_root_lockedwithout it. Today any non-empty value is accepted; a signed unlock assertion replaces it before the drive leaves the flag.
Roots
The first request creates the default roots:path_hint (for example ~/Allternit/Inbox) is sent to the owner and own devices only, never for a provider’s internal folder.
Memory Drive
Memory Drive is a git repository, not a folder. The runtime shows its current files as a read view and turns every Files write or delete there into one commit through the Memory Drive write path, so its history and checks stay in force. Only Markdown files can be written. Writes there fail closed: an existing name withoutbase_rev, or a stale base_rev, is an error, never a conflict copy. Making folders, moving, copying in, uploading and restoring versions are refused with forbidden.
Adding a folder
POST /roots takes an AddRootRequest with local_path. The runtime resolves ~, refuses .., follows symlinks, and requires the real folder to exist inside the home folder. It refuses, with 403 scope_violation, the home folder itself, the secrets deny-list (~/.ssh, ~/.gnupg, cloud CLI credentials, keychains, agent CLI tokens, ~/.allternit private state), any folder that contains one of those, and the Allternit data folders. These are the same rules as the Workspace Files routes.
A relayed caller may not turn sharing or agent access on, or protection off, with PATCH /roots/{root_id}; those changes are made from the computer itself.
Endpoints
What this release does not do yet, each with a clear error:
POST /searchsupportsmode: "name"only.full_textandsemanticreturn501 unsupported.
POST /copy to another computer (dest_computer_id set to a different computer) runs as a job: the answer carries a JobRef, and GET /jobs/{job_id} follows it.
Replicas
A replica is a sealed copy of one root on another of the owner’s computers. The host holds ciphertext only. Replication never wakes a computer: a pass runs only while the source is already on, and a host that is asleep leaves the replicabehind. Register the replica on the host and on the source with the same CreateReplicaRequest. On the source, host_base_url is the host’s loopback or mesh address. Leave it out for a cloud computer, which is reachable only through the relay. The source then pushes through cloud-api’s peer relay, which never wakes anything. GET /api/v1/computer-files/{id}/placement in cloud-api suggests a host. ALLTERNIT_FILES_UPLOAD_KBPS limits upload speed, and ALLTERNIT_FILES_REPLICA_EVERY_S sets how often a pass runs (default 300).
What the runtime sends to cloud-api
While the drive is on and the computer is paired, the runtime also:- adds its
StorageDiscoveryto the presence heartbeat asfilesStorage; - writes the asleep snapshot on the sleep notice (SIGTERM) and at most every 5 minutes while changes are pending;
- collects guest drops kept while it slept into Inbox.
Writing files
A file of 4 MiB or less may use the small write:POST /uploads with the chunk list, POST /chunks/have-need or the session’s need list to skip chunks the computer already has, one PUT per needed chunk, then POST /uploads/{session_id}/commit. The runtime checks every chunk hash and the whole-file hash at commit (chunk_hash_mismatch, chunk_missing, manifest_invalid).
Body limits: the small write and the chunk PUT take at most 4 MiB + 64 KiB; every other v2 route takes 1 MiB. A bigger body returns 413 payload_too_large.
Conflicts
With a stalebase_rev and on_conflict: keep_both (the default), the write lands beside the original as Lease (conflict iPhone 2026-11-15 1042).pdf and the response carries ConflictInfo. The date and time are the writing device’s local time, from utc_offset_minutes (-840 to 840); without it the runtime uses UTC. The device name comes from device_name, then X-Allternit-Device-Name, then the principal’s name. on_conflict: fail returns 409 rev_mismatch with the item as it is now in current.
Reading files
GET /items/{item_id}/content returns the bytes with ETag: "<rev>" and Accept-Ranges: bytes. Send If-None-Match: "<rev>" to get 304 when nothing changed, or Range: bytes=0-1023 for a 206 partial response. A range past the end returns 416.
A symlink inside a root that resolves outside it is listed with read: false; reading it returns 403 scope_violation.
Change feed
Each root has a change cursor.GET /roots/{root_id}/changes?cursor=<cursor>&wait_s=25 returns the changes after the cursor and a new one; wait_s (at most 25) holds the request until something changes. When the cursor is too old the response has reset_required: true and the client lists the root again.
GET /subscribe opens a WebSocket. The client’s first frame is a SubscribeMessage:
changes frames as files change, reset frames when a cursor expires or a root is removed, and a heartbeat every 25 seconds. A protected root without the unlock header closes the socket with reason protected_root_locked.
Errors
Every error is anErrorBody: {error, code, message} plus Files fields (current, missing_chunks, retry_after_s, computer_state, wake). error and code hold the same code.
The full table, including the cloud-api and guest codes, is in section 16 of
contracts/files-drive/SPEC.md.
Sharing and the guest gateway
A share gives one folder or file to someone without an account, with one role:view_download, comment, edit or upload_only. User guide: Share files.
Guests are checked twice on every request. cloud-api checks the token and the share’s state, then relays to the owner’s runtime, which checks the scope again.
Owner routes (cloud-api)
Each needs the owner’s session.{computer_id} is the runtime device id; another user’s id answers 404 not_found. All answer 403 feature_disabled while the owner’s files_drive flag is off or no signing key is configured.
Creating a share asks the computer to confirm the item, that it is in
root_id, and that the root is shareable. A sleeping computer answers 503 asleep; creating a share never wakes it. passcode (4 to 64 characters) is stored as a PBKDF2-SHA256 hash. invite_emails is accepted and not sent.
Public routes (cloud-api)
- Redeem. A link with a passcode answers
401 passcode_requiredwithout one and401 passcode_invalid(withretry_after_s: 30) for a wrong one. Ten wrong passcodes in 15 minutes answer429 rate_limited. A token lives at most 1 hour and never past the share’sexpires_at. Sending a still-valid token inAuthorization: Files-Gueston redeem renews it as the same guest without the passcode. - Token.
fgt1.<base64url claims>.<base64url Ed25519 signature over "fgt1." + claims>. The claims areGuestCapabilityClaims(share_id,guest_id,computer_id,root_id,item_id,role,iat,exp,kid). Runtimes verify it offline with the key fromtoken-keys. - Gateway. Send the token as
Authorization: Files-Guest <token>and use the runtime paths below/api/v1/files-gateway/v2/. Open to guests:GET ping,GET whoami,GET roots/{root_id}/list,GET items/{item_id},GET items/{item_id}/content,GET items/{item_id}/comments,POST comments,PUT roots/{root_id}/content,POST mkdir, and the upload session routes. Everything else answers403 forbidden.upload_onlycannot list, stat or download (403 forbidden, “This link only allows uploads.”). - Every request checks the signature,
exp, whether the share or guest was turned off (410 share_revoked), the share’s expiry (410 share_expired), the computer, and the role. - Sleeping computer. A guest never wakes it: the answer is
403 guest_wake_not_allowedwithcomputer_state: asleep. Withguest_wake: truethe gateway starts a wake and answers503 wakingwithretry_after_s. Anupload_onlysmall write into the shared folder itself is kept in the owner’s R2 space and answers202with aQueuedDrop(r2_key=files-drops/{computer_id}/{drop_id}), up to 100 waiting per share. - Audit. Every guest access, allowed or denied, writes a
ShareAccessrow. The runtime also emitsfiles.share.accessed, and the gateway publishes the same event on the cloud events system (MCP agents server,data={ computer_id, access }, filtercomputer_id). It never pushes a notification unless the owner turns it on.
On the runtime
The runtime acceptsFiles-Guest only on /api/v1/files/v2/*. It verifies the token offline with cloud-api’s public key (ALLTERNIT_FILES_TOKEN_KEYS_URL, else ALLTERNIT_CLOUD_API_URL plus /api/v1/computer-files/token-keys), cached for an hour and refetched when a token names an unknown kid. Then on every request: computer_id must be this computer, the item must be the shared item or inside it, the root must be shareable and not protected, and the role must allow the route. A guest gets principal.kind: guest, its role’s permissions on each item, and no pinned_on or local paths. An upload session can be used only by the guest that opened it.