Space Backup Manual

API reference: the peer protocol

Chapter 10 of 14 · Contents

The peer protocol is how Space Backup devices of one company talk to each other directly: computers back up to each other's drives, copy backups between themselves, serve albums, and let phones browse and read their backups. This chapter describes every request a computer serves, the byte layout of the connection, the capabilities and their versions, and the local contract between the apps and the Photos viewer.

This is a reference for integrators: people writing a client (the iPhone app is one), a test tool, or a monitor. Nothing here is needed to use Space Backup. Field names, sizes and error texts are exact; when a value is a default, the chapter says so.


Overview#

Every Space Backup computer (Windows, macOS and Linux alike) runs a peer server. Other devices of the same company connect to it to:

WhoConnects to othersAccepts connectionsNotes
Windows PC (tray app)yesyes, TCP port 47800the shared engine
Mac (menu-bar app)yesyes, TCP port 47800the Mac runs the Linux daemon
Linux PC (daemon)yesyes, TCP port 47800the shared engine
iPhone / iPadyesnever"outgoing only": no peer server, no destinations
A guest's device (another company)only the guest channel, to the album's PCsneversee The guest channel

All computers serve the same requests because they share one engine: a request that works against a Linux PC works against a Windows PC or a Mac.

Ports#

PortProtocolUse
47800TCPThe peer server. Default; change it with the CLI settings key port (restart to apply).
47801UDPLAN discovery: announcements (multicast group 239.255.47.80 and broadcast).

The firewall rules the apps create cover both ports (see Firewall and ports).

LAN discovery#

Every computer sends an announcement about every 30 seconds, and at once when its destinations change or when it sees a peer that is new or restarted:

Sealed packet layout:

BytesContent
4ASCII SBA1
12random nonce
nAES-256-GCM ciphertext of the announcement JSON (key: the company key's announce key; additional data: SBA1)
16GCM tag

The announcement JSON (property names are PascalCase here, unlike the requests):

{
  "Inst": "5f0c2a9e8b7d4c31a6e2f90d14b7c3a8",
  "Name": "OFFICE-NAS",
  "Port": 47800,
  "Boot": "a41c09e27f3b",
  "Ver": "0.12.3",
  "Dests": [
    {"Id": "3F9A1C07B2E4", "Path": "/mnt/backup1", "Root": "/mnt/backup1/SpaceBackup", "Free": 1873415372800,
     "Online": true, "Disk": "WD-WX12A3456789", "Speed": 182.4, "Kind": "external", "Keep": 10,
     "Lan": "\\\\OFFICE-NAS\\SpaceBackup", "full": false, "freeBytes": 1873415372800, "totalBytes": 4000787030016,
     "fullSince": null}
  ],
  "Gd": null
}
FieldMeaning
InstThe install's instance id: stable, unique per install. Peers are told apart by it, not by name.
NameThe machine name: the folder its backups go into on every destination.
PortIts peer server's TCP port. 0: not listening (a phone, or a PC whose port is taken).
BootRandom per process start. A peer seeing a new value answers at once, so a restarted PC finds its peers within seconds.
VerApp version (since v0.7.0). Phones send ios-<version>. A PC whose peer announces a newer plain x.y.z checks for an update at once.
Dests[]Its destinations: Id (destination id), Path (as on that PC), Root (its effective backup root, shown verbatim; absent from older versions), Free (bytes), Online, Disk (physical disk id, since v0.5.9), Speed (measured write speed in MB/s, 0 = not measured), Kind (internal, external or network; absent when not detected), Keep (that PC's max number of backups, which it also keeps over other machines' dates on its drives, see replication.md "The PC's keep count"; absent from older versions), Lan (its backup root as another computer on the LAN opens it, \\PC\Share[\folder]: the SMB share holding it or what the user set, see lan-path.md; absent or null when not shared and from older versions; a phone joins it with \<device>\<date>\<file>), Forms (the form of each phone's backups on it: device name → encrypted, plain or mixed, see forms; absent from older versions and before the first scan), and (0.16.10, camelCase like everywhere else these four appear) full (nearly full: free below max(5 %, 20 GB), until above max(8 %, 30 GB); nothing new is written there, see nearly-full.md), freeBytes, totalBytes (the drive's size), fullSince (when it became nearly full, ISO time UTC; null while it is not); absent from older versions and before the drive was first measured.
GdGoogle Drive records (which PC backs up which Google account). Older peers ignore it.

A peer not heard from for 100 seconds is offline. A peer seen on the LAN is always reached on the LAN.

Reaching a PC at another site#

Computers at different sites meet through Space Relay (see Space Relay and its relay protocol). The relay passes each PC's sealed announcement on unread, so destinations and free space are known before any connection. To connect to a peer, a device tries, in order:

  1. LAN: the peer is seen on the LAN → its LAN address.
  2. Same site: the relay reports the same public IP, or one of the peer's LAN addresses is on one of this device's own IPv4 networks (address and mask of its interfaces) → those LAN addresses (1.5 s timeout each).
  3. Relayed: a pipe through the relay (relay-connect, then both ends attach).

A route that answered as the wrong PC is avoided for 10 minutes; the last route that worked is tried first when it is a LAN address (the relay never goes first). A peer is never dialled at its public address. A change of the device's networks forgets the remembered routes and closes the idle reading connections. Whatever the route, the same handshake and encrypted frames run end to end inside it: the relay cannot read or change anything.

Devices that only connect out (Port 0 and no destinations, or a version starting ios-) are never connected to.

Destination ids#

A destination is named on the wire by its destination id: the first 12 hex digits (upper case) of SHA-256 of the UTF-8 string MACHINE|path, where MACHINE is the PC's machine name in upper case and path the destination path in lower case. Example: 3F9A1C07B2E4. These are the ids peers announce in Dests[].Id; they are not the machine:path ids that dest list prints.

Conventions used by every request#

ItemRule
destA destination id of the PC you are talking to.
cf"Computer name first": the sender's layout setting. true (default): <root>/<MACHINE>/<date>/…; false: <root>/<date>/<MACHINE>/…. Send the same value you back up with.
<root>The destination's backup root: the destination itself when its folder is named SpaceBackup (any case), else its SpaceBackup subfolder.
dateA date folder name, yyyy-MM-dd. Anything else is refused ("Invalid date folder").
relA path inside the date folder. / or \ are accepted; answers use \ on every platform. Refused: absolute paths, drive letters, ., .., empty components, :, invalid characters, reserved device names, components ending in a dot or space, more than 4,000 characters, anything that leaves the folder.
Machine names1–64 characters, ASCII letters, digits, -, _ and .; starting with a letter or digit, not ending with ., no .., not a reserved name.
mtimeFile modification time in .NET ticks, UTC (100-ns intervals since 0001-01-01). Example: 639278252430000000 is 2026-10-17 09:14:03 UTC.
hashXxHash128 of the file content, 32 hex digits.
Times in textISO 8601 UTC, e.g. 2026-10-17T10:00:00Z.
Drive names in messagesAs dest list shows them, PC and drive: CHIA2 G:, OFFICE-NAS /mnt/backup1; never an id. A drive known nowhere: an unknown drive of CHIA2.

A peer can only ever touch its own folder (<root>/<its machine name>/…) for writing. Reading another machine's folder needs a grant; albums need an album ticket.


Connection and authentication#

Membership: the company key#

All devices of a company hold the company key (handed over end to end when a device joins; see The company key). The company key is membership and transport only: it opens the channel, it decrypts no backup. From the key's passphrase the apps derive:

A PC without a company key accepts no peer connections (they are closed at once).

The company channel handshake#

The client proves first. The four handshake messages are plain frames (4-byte big-endian length, then UTF-8 JSON, at most 4,096 bytes):

  1. Client → server: {"v":1, "name":<client machine name>, "inst":<client instance id>, "nonce":<32 random bytes, base64>}
  2. Server → client: {"v":1, "name":<server machine name>, "inst":<server instance id>, "nonce":<32 random bytes, base64>}, or {"error":"…"} and the connection ends.
  3. Client → server: {"mac": base64(HMAC-SHA256(authKey, "client\n" ‖ T))}
  4. Server → client: {"mac": base64(HMAC-SHA256(authKey, "server\n" ‖ T))}, or {"error":"company key does not match"} and the end.

T, the transcript, is the concatenation of length-prefixed fields (each: 4-byte big-endian length, then the bytes):

L("SpaceBackup v1") | L(nc) | L(ns) | L(clientName) | L(clientInst) | L(serverName) | L(serverInst)

with nc/ns the client's and server's raw 32-byte nonces and the names and instance ids in UTF-8. Both sides compare MACs in constant time. Only a holder of the same company key can produce either MAC, so each side knows the other is in the company, and the names and nonces cannot be swapped.

Refusals the server sends in step 2:

errorWhy
invalid machine nameThe client's name breaks the machine name rule.
<NAME> is this PC's own nameA client may not use the server's own name.
this PC serves no guestsA guest hello reached a PC that has no album host.

A hello whose v is not 1, or whose nonce is not 32 bytes, closes the connection without an answer ("Unsupported protocol version", "Bad nonce" in the log).

Session keys and encryption#

After step 4 both sides switch to encrypted frames. With salt = nc ‖ ns:

Each direction is AES-256-GCM with its own frame counter as nonce (see Frame format), so frames cannot be read, altered, replayed, dropped or reordered without the connection failing.

Who the peer is#

After the handshake, the server knows the client's machine name (name) and instance id (inst); the client checks it reached the instance it meant (the instance in the peer's announcement) and drops the connection otherwise ("… is not the expected peer").

Every request is served as that machine: a peer writes only its own folder, a replicate is accepted only from the machine its grant names, a read ticket only from the device it was given to.

The company key proves membership, but every company device holds it. So for anything beyond a device's own backups the server asks for more proof:

ProofIssued byUsed forChecked how
Read ticket (grant)Account service, POST /account/api/peer-ticketsReading another machine's backups (a share or an approved restore)The PC asks POST /account/api/peer-tickets/check
Album ticket (ticket in every album.*)Account service, POST /account/api/albums/{id}/tickets (1 h) or a relay ticket (30 days)Every album requestThe PC asks POST /account/api/album-tickets/check
Replication / rearrange grant (grant)The source device itself, signed with its registered device keyreplicate, rearrange, replica.*ECDSA P-256 signature against the key the account service has for that device (GET /account/api/devices/key?name=)
Device key (guest channel)Registered with the account serviceA guest's connectionECDH with the registered keys, see The guest channel

The account service endpoints are described in Account service API. Ticket checks are cached on the PC (per ticket, shared by all connections): a yes for 5 minutes (never past the ticket's expiry), a no for 1 minute. When the service cannot be reached, a yes still within its 5 minutes is used; after that the request fails without refused (retry later): nothing is ever served unconfirmed.

Limits and timeouts#

LimitValue
Connections a PC serves at once16 per device (hello name + inst), 128 in all; a hello past either is answered {"error":"busy","retry":5} (logged once a minute per device), never closed silently
Space Relay pipes a PC serves at onceA pool apart from the LAN's (neither crowds the other out): 8 per device, 48 in all, answered busy past either; a relay pipe waiting 2 min for a request is closed (a LAN connection: 15 min)
A socket past every slotLAN 128 + 32 still in their hello, relay 48 + 16: answered {"error":"busy","retry":5} at once, its hello read, then closed cleanly (no reset)
A device connecting againits connections idle (waiting for a request) for 60 s or more are closed first; at a cap, the longest idle connection (the device's own first) makes room
Sockets still in their hello32 more; past them a connection is closed unread (logged once a minute with who holds the slots)
Handshake reads (server)15 s each
Idle connection (server)15 min without a request, then closed
Server writes60 s
Client reads and writes (engine clients)10 min
Engine clients reuse an idle connectionup to 4 min, then they reconnect
TCP connect timeout5 s on the LAN; 1.5 s / 3 s for same-site and direct routes
Peers' backups served at once2 job slots (see prepare)
Guest connections per PC8

Frame format#

A connection is a sequence of frames in each direction. First come the four plain handshake frames, then encrypted frames until the connection ends.

Handshake frames#

BytesContent
4Length n of the JSON, signed 32-bit big-endian, 0 ≤ n ≤ 4,096
nUTF-8 JSON object

Encrypted frames#

BytesContent
4Length L of what follows, signed 32-bit big-endian. L = 1 + body length + 16; 17 ≤ L ≤ 4,194,320
L − 16AES-256-GCM ciphertext of the plaintext type ‖ body
16GCM tag

JSON messages#

Data frames and streaming#

File contents travel as data frames (type 1), never inside JSON (one exception: the month index of remove and move is base64 inside its JSON). Senders use chunks of up to 1 MiB. A stream of data frames is always bracketed by JSON frames:

Order, pipelining and connections#

Errors#

AnswerMeaningWhat to do
{"ok":false, "error":"…"}The request failed (unknown or offline destination, bad path, disk error, a finished date, …). The connection is fine.Read error; fix or retry.
{"ok":false, "error":"Unknown request <op>"}The PC does not know this op (older version, or the feature is off on it).Check caps; fall back.
{"ok":false, "refused":true, "error":"…"}Not allowed: a ticket or grant the service or the signature does not confirm, another machine's folder, an album you may not change.Do not retry the same request; get a new ticket if it expired.
{"ok":false, "refused":true, "needsGrant":true, "error":"…"}Another machine was asked for without a grant on this connection.Send grant with a read ticket first.
{"ok":false, "refused":true, "superseded":true, "error":"…"}A replica.* request under a rearrange grant older than the PC's own rearrangement of that machine (rearrange).The asking primary ends its job.
{"ok":false, "busy":true, "retry":<s>, "error":"…"}All job slots are taken (prepare), or a guest sends too fast (retry: 1).Wait retry seconds and ask again.
{"ok":false, "missing":true, "error":"…"}The file asked for is not there (read, readmany, album reads).Treat as absent.
{"ok":false, "full":true, "error":"…"}The target drive has no room (replica.files).The date does not fit there.
{"ok":false, "full":true, "nearlyFull":true, "error":"…"}The drive is nearly full (nearly-full.md): a new date (mark) or something to copy (replica.files).Skip that drive, no failure; try again once its announcement says full: false.
{"ok":false, "verify":true, "error":"…"}What was written and read back does not have the expected hash (replica.put).The copy is not kept; send it again or give up.
Connection closedHandshake refused, a frame that does not authenticate, a length out of range, malformed JSON, a data frame where a request was expected (or the other way round), an unexpected internal error.Reconnect.

Errors whose meaning depends on the op are listed with each op.


Capabilities and versions#

How a peer learns the other's capabilities#

There is one protocol version (v: 1 in the handshake, SpaceBackup v1 in the transcript). Features added since are announced as capabilities: after the handshake, send caps and read the answer. Clients ask once per connection, before using a feature that needs one. A key that is missing means 0 / false. The older keys are booleans; newer ones are integers that grow with each addition.

{"op":"caps"}
{"ok":true, "putsmall":true, "dated":true, "jobs":true, "fanout":true, "resume":true, "e2e":true, "fetch":true,
 "placement":true, "gdrive":1, "read":3, "album":9, "replicate":2, "rearrange":3, "remove":1, "partial":1}

The PC never checks capabilities itself: a client that sends an op the PC does not know gets Unknown request <op>.

Every capability#

KeyCurrentVersionSinceWhat it added
putsmalltruetruev0.4.0putsmall: small files in pipelined batches.
datedtruetruev0.5.0Dated folders: every request but status and caps names a date and cf; prepare (re-homes the other layout, moves a v0.4 mirror into today's folder), link and prunedate.
jobstruetruev0.5.3Job slots: prepare takes one (busy/retry when all are taken), release frees it.
fanouttrue / falsetruev0.5.4dests on put and putsmall (one copy for several drives of that PC), recheck in prepare. false on a PC without a fan-out queue.
resumetruetruev0.5.5resume: true on put and the from frame (big files resume from verified blocks); mark / unmark; incomplete in prepare.
e2etruetruev0.5.6hash on putsmall and in put's commit: the PC keeps only data whose read-back hash is the sender's.
fetchtruetruev0.5.6fetch: a file by its hash, for self-repair.
placementtruetruev0.5.9placement (where each folder's copies live) and prunefolder.
gdrive112026-10-12gdrive-speed: Google Drive download speed test. 0 on a PC without the Google Drive service.
read312026-10-13dates; machine on list and stat; read (byte ranges).
22026-10-13grant: another machine is served only under a confirmed read ticket.
32026-10-16readmany (up to 64 files in one request) and cancel.
album1512026-10-15album.add, album.put, album.list, album.read, album.remove, album.delete.
22026-10-15Transfer jobs: album.copy, album.status, relay tickets, queued on album.put, state on each pushed drive.
32026-10-17album.clone.
42026-10-17album.readmany and guests (the guest channel).
52026-10-17album.caption (and caption carried by album.put).
62026-10-20album.put from the owning device into its public album (meta, as the backup put).
72026-10-20album.add and album.clone as PC-side jobs: they run to the end without the caller; detach: true, album.job, jobs in album.status, job in their frames.
82026-10-22Items keep their source's index fields (album.add items, album.put, album.list).
92026-10-23(0.14.3, iOS request #67) album.put with meta from a device of the member who owns an ordinary album, not only into a public album.
102026-11-01(0.16.59, iOS request #97) An album's Deleted area: album.remove and album.delete keep what they take 30 days; album.deleted, album.restore, album.purge.
112026-11-02(0.16.72, iOS request #103) An item the album already has without a thumbnail takes the one brought: album.add sent again (thumbs in its answer), album.copy and album.put with fillThumb.
122026-11-03A large put's items as one batch on the PC that takes them: album.put with batch: true (album.json written once per batch there, not once an item) and album.flush at the put's end. An older PC ignores batch and answers album.flush "Unknown request"; nothing else changes.
132026-11-08album.merge: every item of two of the owner's albums into a new one, duplicates once (albums.md, Merging two albums).
142026-11-08The album's Excluded folder (albums.md, Excluded items): an assistant's add puts a work item (index field work, conf 0.6 or more) into Excluded/ (album.json excluded, returned items in kept); album.put's item carries excluded {conf, why}; album.list carries them, their files as Excluded/<name>; album.excluded, album.return; album.remove of an excluded item moves it to the Deleted area.
152026-11-08The user's work mark (albums.md, The user's work mark): an assistant's add (AutoAdd, CloneForJob of a job that excludes work) is written "auto": true in album.json and album.put's item carries auto; the assistant's adds use the mark first (not work: never excluded; work: excluded unless the album keeps it); each PC's albums follow a mark on its own drives (not work: back from Excluded, kept; work: an assistant's add into Excluded with the label {conf: 1, why, user: true}, its kept entry dropped; an item added by hand never moves).
replicate212026-10-17replicate, replicas, replica.begin, replica.files, replica.put, replica.end.
22026-10-23(0.14.0, iOS request #66) Catch-up: copies and the reads for them under a grant past its expires, up to 90 days after it was issued; replica.has, replica.list, replica.read under a replication grant; the Replica state resend.
rearrange312026-10-18rearrange, replicas {rearrange: true}, replica.dates, replica.has, replica.drop, date on replica.begin. 2: replica.list, replica.read. 3 (2026-10-22, iOS request #54): the form check before replica.drop {form} (missing in the answer), replica.list {any}.
22026-10-19replica.list, replica.read: the primary copies a date from another PC's drive of the grant.
forms112026-10-26forms: the forms a PC asks the calling phone for on a drive (Encrypt… / Don't encrypt…), and the phone's answers.
remove112026-10-18remove: files and the new month index of a date in one request.
move112026-10-21move: renames inside a date and its new month index files in one step (iOS request #49).
changes0 / 1 / 2 / 332026-10-25(#70) 1: backups.changes and album.changes: the moves in a device's backups and an album's adds and removes made on this PC, as numbered change records since a counter. 2: also changes.watch (an open app hears every change at once) and changes.push (PC to PC), album adds and removes recorded. 3 (after 0.14.6): move and remove take ids (and a move its group), so an encrypted date's moves are recorded as moved/gone instead of full. 0 on a PC that keeps no change log.
partial112026-10-20unmark {partial: true}: a date closed after a stopped run; partial in prepare, dates, replica.dates, replica.list; partial on replica.begin.
upload112026-10-28Takes uploads through the relay's HTTPS door (iOS request #77) and mark {uploads: true}.
multidrive212026-11-07prepare and link take drives: [id, …] instead of dest and answer per drive (drives: {id: answer}): one round trip for all of a device's drives on this PC. 2 (iOS #160, 2026-11-07): list, mkdir, status and mark too. An older PC ignores drives; send it to an op only when the cap says that op takes it.
work-mark0 / 112026-11-08photos.work: a phone's work marks forwarded by the PC to the account service as its member. 0 on a PC that does not forward them.
photoreq1 / 222026-11-05photos.requests: what a PC's Photos window asks the calling phone to do with its own items (Delete, a caption, a public link), and the phone's answers. 2: also archive and unarchive (the window's Archive / Unarchive). 0 on a PC that keeps no such requests.
arrival112026-11-10Every copy is checked as it lands (Backing up › Every file is checked as it arrives): put and putsmall answer checked: true (the sender's hash matched and a photo or video decodes) or checked: false with damaged and resend (it arrived cut short or does not decode; kept, and a re-send request filed at once). Treat an item as backed up only on checked: true; send hash with every file.
resend112026-11-10A damaged backup copy is sent again by its origin (Re-sending a damaged copy): prepare answers resend, photos.requests lists op resend, and resend.answer takes a computer source's answers.
links312026-10-21Serves public links to the account service: on the guest channel with an lk_… ticket (access: "link"), only link.list → {items: [{i, name, kind, size, mtime, thumb} or {i, missing}]} and link.read {i, thumb?, offset?, length?} → a head {name, kind, size, offset, length, mtime}, data frames, {done, sent}; never anything of a date holding an encrypted tree. 2 (iOS request #47): a whole album's link, link.album {offset, limit} → {total, hidden, offset, items: [{key, name, kind, size, mtime, thumb}]} (what the album holds now on this PC; hidden: items with no plain copy here; items deleted or archived on their phone left out) and link.read {key, thumb?, offset?, length?}. 3 (iOS request #48): link.read {…, jpeg: true} sends a HEIC/HEIF/TIFF/RAW photo as a full-size JPEG made with ImageMagick (head name = <stem>.jpg, jpeg: true; cached on the PC), and link.album items carry taken.
vision0 / 112026-10-19Space Vision host (a phone's newest complete plain date on this PC): vision.status, vision.search, vision.get (Space Vision). 0 on a PC with none.
analyzeas vision12026-10-19The same as vision, under the phone's name for it (iOS request #40).
vision-worker0 / 112026-10-19This PC runs a Space Vision worker (a usable NVIDIA graphics card, runtime and models installed, not paused).
vision-lease0 / 112026-10-21Space Vision phase 2: workers on other PCs of the company may lease this host's plain dates (vision.challenge, vision.hello, vision.pending, vision.lease, vision.unlease, vision.put).
vision-select0 / 222026-10-22Space Vision selection (iOS request #51): vision.select and vision.job: a worker judges the phone's candidates against the user's words. 2 (iOS request #60): the host settles analysed candidates itself from their stored vectors first; vision.job answers partial while a worker judges the rest, and timings.
vision-search0 / 112026-10-22vision.search {query}: the machine's analysed items ranked by the words and their stored vectors, from the host's index alone (iOS request #60).
search-index0 / 112026-11-06search.index: a device's search index on this PC in one answer, instead of its month files read one by one (Space Vision).
geo0 / 112026-11-08geo.resolve, geo.places, geo.names, the geo filter of vision.search and assistant.job, and each hit's compact geo (geography).
vision-embed0 / 112026-10-22vision.embed: this PC makes a query's vector for a host (the Space Vision runtime and SigLIP 2 installed; no graphics card needed).
assistant-job0 / 1 / 2 / 3 / 412026-10-22assistant.job and assistant.job.status: this PC finishes a phone's assistant request: candidates, selection, the album with its filter and shares, the alert (iOS request #61). On a Space Vision host (vision: 1) that keeps albums. Without it the phone runs the request itself.
22026-10-23(0.14.0, iOS request #64) The reading's shared albums are searched and their matches cloned into the album made; no consent refusal (every member's plain backups are analysed); refused at submit only signed-out, or no-worker for content nothing could judge.
32026-10-25(iOS request #73) assistant.job.cancel: the Assistant's Stop ends a job after the step it is on, keeping what it did, with no done alert.
42026-11-05The desktop window: another computer of the phone's member sends the job for the phone's backups (machine: the phone) with no grant, under the job ticket it took for the phone (POST assistant/jobs/ticket device); refused at once with reason: "not-here" when this PC holds no plain backup of it.

album, replicate and rearrange are 0 on a PC that has no album host or replication host; current Windows, Mac and Linux builds have both.

Behaviour with older peers#

The other side lacksWhat the apps do
dated (v0.4 or earlier)prepare answers Unknown request: the destination fails with "<PC> runs an older Space Backup (v0.4 or earlier); update it to v0.5 to back up there".
caps itself failsfanout, resume, placement are taken as false.
fanoutEach destination of that PC gets its own copy.
resumeNo markers (mark/unmark are not sent) and no resumed big files.
e2eThe PC ignores hash and checks as before.
placementNo placement; prunefolder is not sent ("runs Space Backup v0.5.8 or older"): that folder's dates stay there until they age out.
gdrive 1The speed test says "needs a newer Space Backup there".
read ≥ 2grant answers Unknown request: such a PC serves another machine's encrypted trees only; readers go on without a grant.
read ≥ 3Single reads instead of readmany.
album ≥ 3The phone sends album.clone only to a PC with album >= 3; otherwise it counts the items as waiting.
album ≥ 4No guests and no album.readmany on that PC.
album ≥ 5No captions there.
album ≥ 8Album items carry only what album.json had before (no index fields); fields sent in album.add items are ignored.
album ≥ 7No detach and no album.job: the phone stays connected for an add or clone there (on that PC a dropped connection stops the add at its next progress frame; the items done so far stay, an add again answers them already).
replicate 1 (as primary)The source sends each computer its own copy.
replicate 1 (as target)That drive is failed ("runs an older Space Backup without replication"); the source sends it there itself.
replicate 2 (as target)After the grant's time that drive waits with grantExpired ("<PC> runs an older Space Backup that copies only under <machine>'s new grant"): send replicate again with a new grant. It is never copied from.
rearrange 1Copies to that PC are failed (the phone sends there itself); its old copies are kept (never dropped).
rearrange 2That PC's copies are not copied from: a form held only there counts as held nowhere (the phone resends it).
rearrange 3That PC is never asked to drop a date's old form: its drive waits ("<PC> runs an older Space Backup that cannot check a date's forms before dropping one") until it is updated; its copies are listed with replica.list (complete in one form only).
remove 1The phone leaves that PC alone and tries again at its next run.

Information requests#

caps#

status#

Whether one of the PC's destinations is connected, and its free space.

{"op":"status", "dest":"3F9A1C07B2E4"}
{"ok":true, "online":true, "free":1873415372800, "keep":10, "full":false, "freeBytes":1873415372800, "totalBytes":4000787030016, "fullSince":null}

Backing up to a PC#

A run from a device to one destination of a PC goes like this (one connection for the requests, up to 4 more for file transfers):

  1. prepare (takes a job slot; answers the dates already there),
  2. caps,
  3. mark the new date incomplete,
  4. list / stat to see what is there, link unchanged files from the previous date, mkdir,
  5. putsmall batches and put for big files, delete / rmdir / delpart for what went away,
  6. unmark (the date is complete; the PC writes its manifest), or, when the run stopped with items left, close it: the indexes, link of what it did not reach from the previous date, unmark {partial: true},
  7. placement, prunedate / prunefolder for dates that age out,
  8. release (frees the job slot).

A finished date is read-only for writes. A date folder with a manifest and no incomplete marker is finished: put, putsmall and link into it are refused with "<date> is complete on <PC>:<path>; mark it incomplete before writing into it". To change an older date, run on it: mark, the writes, unmark (which rewrites its manifest and hashes). delete, prunefolder and remove are allowed in a finished date and update its manifest themselves.

prepare#

Starts a backup job on the PC and lists the sender's dates on that destination.

{"op":"prepare", "dest":"3F9A1C07B2E4", "cf":true, "today":"2026-10-17"}
{"ok":true, "dates":["2026-10-14","2026-10-15","2026-10-16"], "recheck":false, "incomplete":["2026-10-16"], "partial":[]}

release#

{"op":"release"}

list#

Files and folders under a folder of a date.

{"op":"list", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16", "rel":"C\\Users\\anna\\Documents"}
{"ok":true, "files":[["Budget 2026.xlsx", 48213, 639277705310000000], ["Letters\\Bank.docx", 20114, 639201112000000000]],
 "dirs":["Letters"], "done":true}
{"op":"list", "drives":["3F9A1C07B2E4", "8D21E0F4A9C3"], "cf":true, "date":"2026-10-16", "rel":"Photos\\2026\\10"}
{"ok":true, "drives":{"3F9A1C07B2E4":{"ok":true, "files":[["IMG_0001.HEIC", 2210443, 639277705310000000]], "dirs":[]},
 "8D21E0F4A9C3":{"ok":false, "error":"Destination offline: F:\\"}}, "done":true}

stat#

{"op":"stat", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16", "rels":["C\\Users\\anna\\Documents\\Budget 2026.xlsx", "C\\gone.txt"]}
{"ok":true, "files":[[48213, 639277705310000000], null]}

mkdir, rmdir, delpart#

OpDoesRequest
mkdirCreates a folder (and its parents) in the date folder.dest, cf, date, rel
rmdirRemoves a folder if it is empty.dest, cf, date, rel
delpartDeletes the temp file (.~sbpart) of an interrupted copy of rel.dest, cf, date, rel
{"op":"mkdir", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-17", "rel":"C\\Users\\anna\\Pictures\\2026"}

delete#

Removes a file or a folder (this date's name only: other dates sharing the file by hard link keep it).

{"op":"delete", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-17", "rel":"C\\Users\\anna\\Temp", "dir":true}

Gives files of an earlier date a name in this date: a hard link, or a copy on the PC's own disk where links are not possible. This is how unchanged files cost nothing.

{"op":"link", "drives":["3F9A1C07B2E4", "8D21E0F4A9C3"], "cf":true, "from":"2026-10-16", "to":"2026-10-17", "rels":["C\\a.txt"]}
{"ok":true, "drives":{"3F9A1C07B2E4":{"ok":true, "errors":[null], "copied":false}, "8D21E0F4A9C3":{"ok":false, "error":"Destination offline: F:\\"}}}
{"op":"link", "dest":"3F9A1C07B2E4", "cf":true, "from":"2026-10-16", "to":"2026-10-17",
 "rels":["C\\Users\\anna\\Documents\\Budget 2026.xlsx", "C\\Users\\anna\\Documents\\Letters\\Bank.docx"]}
{"ok":true, "errors":[null, null], "copied":false}

mark, unmark#

{"op":"mark", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-17", "run":"r_20261017_091403"}
{"op":"unmark", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-17", "run":"r_20261017_091403", "partial":true}
{"ok":true, "fanoutFailed":["Photos\\2026\\10\\IMG_4021.HEIC"]}

A partial date is complete for everything that reads it: browse and restore (shown "partial"), the integrity check, replication (its copies are closed partial too), Space Vision, public links, rearranging, and the previous date a new run links from. Retention never counts it toward the max number of backups.

put#

One file of any size, streamed.

{"op":"put", "dest":"3F9A1C07B2E4", "dests":["3F9A1C07B2E4","8C21D0E5F7A9"], "cf":true, "date":"2026-10-17",
 "rel":"D\\Video\\Holiday.mp4", "size":2147483648, "mtime":639278252430000000, "resume":true}
{"ok":true, "have":16777216, "block":8388608, "blocks":["9c1e4be0d22f4a7f8b3c6d5e4f3a2b1c", "0f1e2d3c4b5a69788796a5b4c3d2e1f0"]}
{"op":"from", "offset":16777216}

…data frames…

{"op":"commit", "hash":"4be09c1e2f4a7fd28b3c6d5e1c4f3a2b"}
{"ok":true, "error":null, "checked":true}

A photo that arrived cut short (its bytes are what the device read, so the device read it short: an iCloud original not fully downloaded):

{"ok":true, "error":null, "checked":false, "damaged":"the JPEG is cut short (no end of picture after its scan)", "resend":"rs_3f2a9c1d0b7e6a54"}

putsmall#

One small file in one round trip; meant to be pipelined in batches (the engine sends up to 64 files / 2 MB, then reads the answers).

{"op":"putsmall", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-17", "rel":"C\\Users\\anna\\Documents\\notes.txt",
 "size":1834, "mtime":639278252430000000, "hash":"d22f9c1e4be04a7f6d5e8b3c4f3a2b1c"}

…one data frame of 1,834 bytes…

{"ok":true, "checked":true}

prunedate#

{"op":"prunedate", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-09-17"}

prunefolder#

Removes one backed-up folder from a date (and its manifest entries), on a destination that no longer receives that folder, as its dates age out.

{"op":"prunefolder", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-09-20", "rel":"C\\Users\\anna\\Music"}

placement#

Stores, in that backup root, the sender's folders and which PCs and drives hold each one's copies. The PC's weekly check asks those holders first when it repairs a file.

{"op":"placement", "dest":"3F9A1C07B2E4",
 "doc":"{\"Computer\":\"ANNA-PC\",\"Inst\":\"\",\"UpdatedUtc\":\"2026-10-17T09:20:00Z\",\"Folders\":[{\"Path\":\"C:\\\\Users\\\\anna\\\\Documents\",\"Rel\":\"C\\\\Users\\\\anna\\\\Documents\",\"Mode\":\"Auto\",\"Copies\":2,\"Holders\":[{\"Inst\":\"5f0c2a9e8b7d4c31a6e2f90d14b7c3a8\",\"Machine\":\"OFFICE-NAS\",\"Dest\":\"3F9A1C07B2E4\",\"Path\":\"/mnt/backup1\"}]}]}"}

remove#

Removes files of one date and replaces the month index that listed them, in one step (the iPhone's Remove from backups).

{"op":"remove", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16",
 "rels":["Photos\\2026\\10\\IMG_1234.HEIC", "Thumbs\\2026\\10\\IMG_1234.HEIC.jpg"],
 "index":{"rel":"Index\\2026-10.json", "data":"eyJ2IjoxLCJpdGVtcyI6W119", "mtime":639279090000000000}}
{"ok":true, "removed":["Photos\\2026\\10\\IMG_1234.HEIC", "Thumbs\\2026\\10\\IMG_1234.HEIC.jpg"], "missing":[]}

move#

Moves items between folders of one date (Photos\…, Archived\…, Deleted\…) and replaces the month index files that say where they are, in one step (the iPhone's Archive, Delete and putting back, without sending the item again).

{"op":"move", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16",
 "moves":[{"from":"Photos\\2026\\10\\IMG_1234.HEIC", "to":"Archived\\2026\\10\\IMG_1234.HEIC"}],
 "index":[{"rel":"Index\\2026-10.json", "data":"eyJ2IjoxLCJpdGVtcyI6W119", "mtime":639279090000000000}]}
{"ok":true, "moved":1, "already":0, "missing":[]}

backups.changes#

The moves in a device's backups made on this PC since a counter (#70, iOS docs/requests.md #70 "Wire shapes"): a device browsing those backups applies them instead of reading every month again.

{"op":"backups.changes", "machine":"IPHONE-17-PRO", "device":"d_7Hq2", "since":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:16"}
{"ok":true, "v":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:17", "changes":[{"part":"backups:d_7Hq2", "v":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:17",
 "prev":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:16", "at":"2026-10-24T21:55:03Z", "moved":{"Deleted":["A1B2-C3"]}, "gone":["D4E5-F6"]}]}

changes.watch#

An open app's watch (#70 point 5): every change of the parts it shows, made on this PC or arriving from another PC, the moment it is made, over the connection it already has to one PC. The app watches one PC (the first that answers); changes of every origin come down the same watch. The push stays for the background.

{"op":"changes.watch", "parts":[{"part":"album:al_5Kp9", "ticket":"<album ticket>"}, {"part":"backups:d_7Hq2", "machine":"IPHONE-17-PRO"}]}
{"ok":true, "v":{"album:al_5Kp9":["a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:42", "5b1e0c9d7a3f4b2e8d6c4a2f0e9b7d5c:7"], "backups:d_7Hq2":["a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:17"]}}
{"ok":true, "change":{"part":"backups:d_7Hq2", "v":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:18", "prev":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:17", "at":"2026-10-25T01:12:40Z", "moved":{"Deleted":["A1B2-C3"]}}}
{"ok":true, "ping":true}

changes.push#

PC to PC (#70 point 4): each PC sends the records it makes to the company's other online PCs (not phones) at once, over the LAN or Space Relay, end to end encrypted with the company key, so their open apps' watches, their Space Vision workers and their public links hear it too. Every online PC is told (an app may watch any of them), not only the ones holding the album or the backups.

{"op":"changes.push", "records":[{"part":"album:al_5Kp9", "v":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:43", "prev":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:42", "at":"2026-10-25T01:13:02Z", "remove":["9f2c000000000001"]}]}
{"ok":true, "taken":1}

Repair: fetch#

fetch#

Asks a PC for a good copy of a file by its hash, for self-repair (the weekly check found a damaged copy here).

{"op":"fetch", "hash":"4be09c1e2f4a7fd28b3c6d5e1c4f3a2b", "size":48213, "rel":"C\\Users\\anna\\Documents\\Budget 2026.xlsx"}
{"ok":true, "size":48213}

Replication#

A source (today the iPhone) sends a date once, to one PC, the primary, which copies the finished date, bytes as they are, to the source's chosen drives on other PCs, PC to PC (see Replication between computers). Encrypted trees stay encrypted: no PC needs or gets a key.

The replication grant#

Every replication request carries the source's grant, signed by the source itself:

"grant": {"payload":"<base64 of the UTF-8 JSON below>", "sig":"<base64 signature of those payload bytes>"}
{"v":1, "kind":"spacebackup-replicate", "machine":"Annas-iPhone", "date":"2026-10-17", "primary":"ANNA-PC",
 "targets":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}, {"pc":"BOB-PC","dest":"8C21D0E5F7A9"}],
 "issued":"2026-10-17T10:00:00Z", "expires":"2026-10-17T16:00:00Z"}

Catch-up: a PC that was off for days#

0.14.0, iOS request #66 (replicate 2). A drive named in a job's grant is finished from the PCs, without the source, however long its PC was off:

replicate#

Replica:

FieldMeaning
pc, destThe target PC and drive id.
driveThe drive's name, e.g. OFFICE-NAS /mnt/backup1.
statedone (whole date there, verified, marker removed), waiting (PC off, drive not connected, transfer broke, or being copied now), failed (refused, no room, an older version), resend (replicate 2: no PC holds the date complete for it, error says what is missing where; the source sends the date to that drive itself, its normal run). Count a drive as holding the date only when done.
sinceWhen the state was set (ISO 8601 UTC).
errorWhy it is not done.
fulltrue: the target has no room.
files, bytesWith done: what the date holds.
copyingWith waiting: being copied right now.
grantExpiredWith waiting: the grant ended and that drive needs a new one (its PC runs replicate 1, or the grant is more than 90 days old); send replicate again with a new grant. Without it a waiting drive is finished by the primary (catch-up).
keepThat drive's PC max number of backups (its own setting; the effective keep there is min(keep, the phone's grant keep), see replication.md "The PC's keep count"); absent when the primary does not know it.
{"op":"replicate", "dest":"5B7E19A0C3D2", "cf":true, "date":"2026-10-17", "wait":60,
 "grant":{"payload":"eyJ2IjoxLCJraW5kIjoic3BhY2ViYWNrdXAtcmVwbGljYXRlIiwi…", "sig":"MEUCIQD…"},
 "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}
{"ok":true, "machine":"Annas-iPhone", "date":"2026-10-17",
 "replicas":[{"pc":"OFFICE-NAS", "dest":"3F9A1C07B2E4", "drive":"OFFICE-NAS /mnt/backup1", "state":"done",
              "since":"2026-10-17T10:04:12.0000000Z", "files":312, "bytes":1288490188}]}

replicas#

{"op":"replicas", "date":"2026-10-17"}

replica.begin#

The primary starts writing a date on one target drive (one connection per target).

{"op":"replica.begin", "grant":{"payload":"eyJ2Ijox…", "sig":"MEUCIQD…"}, "dest":"3F9A1C07B2E4", "cf":true}
{"ok":true, "prev":"2026-10-16"}

replica.files#

{"op":"replica.files", "files":[["Photos\\2026\\10\\IMG_1301.HEIC", 2381044, 639278252430000000, "9c1e4be0d22f4a7f8b3c6d5e4f3a2b1c"]], "last":true}
{"ok":true, "need":["Photos\\2026\\10\\IMG_1301.HEIC"], "linked":288, "kept":23}

replica.put#

{"op":"replica.put", "rel":"Photos\\2026\\10\\IMG_1301.HEIC", "size":2381044, "mtime":639278252430000000, "hash":"9c1e4be0d22f4a7f8b3c6d5e4f3a2b1c"}

replica.end#

{"op":"replica.end"}
{"ok":true, "files":312, "bytes":1288490188}

Rearranging#

When the phone's destinations change and the user chooses Rearrange, the phone has the PCs move the dates it already backed up to the new drives, PC to PC, and drop them from drives no longer chosen, never below one complete copy. A rearrangement is ordered by the phone with a signed rearrange grant; every PC that writes or removes anything checks it.

The rearrange grant#

Same envelope, signature, key lookup and time rules as the replication grant, another kind:

{"v":1, "kind":"spacebackup-rearrange", "machine":"Annas-iPhone", "primary":"ANNA-PC",
 "from":[{"pc":"ANNA-PC","dest":"5B7E19A0C3D2"}, {"pc":"BOB-PC","dest":"8C21D0E5F7A9"}],
 "to":[{"pc":"BOB-PC","dest":"8C21D0E5F7A9"}, {"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","plain":true}],
 "dates":"all", "issued":"2026-10-18T10:00:00Z", "expires":"2026-10-18T16:00:00Z"}

rearrange#

FieldMeaning
machine, issuedThe job's machine and grant time.
statedone, working (a pass is running), waiting (for a PC, a drive or the phone), grantExpired (also while a pass is running: send rearrange again with a new grant: past its time the primary goes on copying (catch-up); only the drops, a drive whose PC runs replicate 1, or a grant more than 90 days old need the new one), none (no job).
dates[]{date, state, from, to:[{pc, dest, drive, state, error?, full?, skipped?, items?, keep?}], dropped:[drive], error?}; date state: done, waiting, resend, failed; from: the drive the primary copies it from; per to drive done / waiting / resend / failed / skipped (outside the effective keep: min(keep, grant keep)); skipped: "nearly full" on a waiting drive that is nearly full (0.16.10: no failure, moved when it clears); keep: that drive's PC max number of backups, absent when unknown.
rearranged[]{drive, items}: files the job verified on each to drive so far.
elsewhere[]{date, drives:[drive]}: dates on no drive of the primary; send another rearrangement with that PC as primary.
supersededPresent when a later rearrangement of the machine on another PC ended this job: replaced by <machine>'s later rearrangement on <PC> (issued …Z).
{"op":"rearrange", "grant":{"payload":"eyJ2IjoxLCJraW5kIjoic3BhY2ViYWNrdXAtcmVhcnJhbmdlIiwi…", "sig":"MEQCIF…"}, "wait":30}
{"ok":true, "machine":"Annas-iPhone", "issued":"2026-10-18T10:00:00Z", "state":"waiting",
 "dates":[{"date":"2026-10-16", "state":"waiting", "from":"ANNA-PC D:",
           "to":[{"pc":"BOB-PC","dest":"8C21D0E5F7A9","drive":"BOB-PC E:","state":"done","items":540},
                 {"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","state":"resend"}],
           "dropped":[]}],
 "rearranged":[{"drive":"BOB-PC E:", "items":540}]}

forms#

{"op":"forms"}
{"ok":true, "machine":"Annas-iPhone",
 "wanted":[{"pc":"BOB-PC", "dest":"8C21D0E5F7A9", "drive":"BOB-PC E:", "plain":false, "requested":"2026-10-26T15:00:00Z"}]}

photos.work#

{"op":"photos.work", "marks":[{"source":"Annas-iPhone", "id":"77ab0123456789ab", "work":false}]}
{"ok":true, "changed":1, "v":1234}

photos.requests#

{"op":"photos.requests", "answers":[{"id":"pa_3f2a9c1d0b7e6a54", "accepted":true, "url":"https://spacebackup.net/l/abc"}]}
{"ok":true, "machine":"Annas-iPhone",
 "wanted":[{"id":"pa_77c1e0a9d2b34f10", "op":"caption", "item":"0123456789abcdef", "caption":"Dinner at the pier", "requested":"2026-10-26T17:40:00Z"}]}

resend.answer#

A computer or Mac source's answers to the resend of prepare, after its run.

{"op":"resend.answer", "sent":["rs_3f2a9c1d0b7e6a54"], "gone":[]}

Re-sending a damaged copy#

Vladimir's rule (2026-11-10): a damaged backup copy (cut short, unreadable, not what was backed up, missing on every drive) is sent again by the device it came from, automatically; the user never presses Fix. The processing watchdog, the scrub and the audit find it; a good copy on another drive or computer heals it first (the scrub's repair). Only when no good copy is left does the PC holding it record a request (rs_…, kept in resend-requests.json in its data folder) for the source, the date, the file and its hash, and wake the source with the silent forms changed push. A phone or tablet reads it with photos.requests, a computer or Mac with its next run's prepare; the request stays pending, pushed again every 6 hours, until the source answers. A file sent again is checked by the next watchdog or scrub pass: read right, the request is done; still damaged, it is asked once more, then given up. The user is told (once, naming the files) only when the source answered gone, when its own bytes are the damaged ones, when it was still damaged after two sends, or when 3 days passed without an answer; never while a re-send is on its way. An original a GPU worker analysed (it has a picture vector) is not damaged: what this PC's probe cannot read there is a decoder gap of ours, and the device is not asked. Details: docs/resend.md.

replicas for a rearrangement#

replica.dates#

{"op":"replica.dates", "grant":{"payload":"eyJ2Ijox…", "sig":"MEQCIF…"}, "dest":"8C21D0E5F7A9", "cf":true}
{"ok":true, "dates":[{"date":"2026-10-15","complete":true,"partial":false}, {"date":"2026-10-16","complete":true,"partial":true}]}

replica.has#

{"ok":true, "exists":true, "complete":true, "form":"encrypted", "files":540, "completed":"2026-10-16T21:14:09.0000000Z"}

replica.drop#

{"op":"replica.drop", "grant":{"payload":"eyJ2Ijox…", "sig":"MEQCIF…"}, "dest":"5B7E19A0C3D2", "cf":true, "date":"2026-10-16"}
{"ok":true, "dropped":true}

replica.list#

{"ok":true, "form":"plain", "total":540, "files":[["Photos\\2026\\10\\IMG_1234.HEIC", 2811904, 638650000000000000, "9f1c…"]]}

replica.read#

The form check#

iOS request #54 (rearrange 3). A PC cannot read the phone's encrypted names or its encrypted month index, so a file of one form is paired with its twin in the other by what encryption keeps: each encrypted name is base32 of a 16-byte SIV and the name, so its length gives the plain name's length in bytes (a long name stored as ~<SIV> matches any); an encrypted file's size is 60 + plain path bytes + plain size + 28 × chunks of 1 MiB; both forms carry the asset's modification date. A file below a top folder's year and month (Photos, Thumbs, Archived, Deleted) needs one twin with the same name lengths, that size and an mtime within 2 s; the files right below a top folder (the month indexes, rewritten by PCs in a plain copy) are counted by name length, the new form needing at least as many; in the same form, paths are compared. The primary runs the same check before a from drop, between that copy (replica.list {any}) and every done to drive.


Onward copies#

Vladimir, 2026-11-06: "if a backup went to one drive, the app on the destination PC should be able to copy that backup to other destination drives". Whatever drive of a PC holds a date of another machine complete, that PC copies it, bytes as stored (encrypted stays encrypted, no key moves), to every other drive the machine's backups go to: its own drives and the other PCs'. The source never has to be online. What says where they go is signed by the source: its destinations grant, else (a phone) its latest rearrange grant's to drives within that grant's catch-up time. Copies only: nothing is dropped or converted. Details: docs/replication.md#onward-copies.

The destinations grant#

The replication grant's envelope, key and signature, with kind spacebackup-destinations, no primary and no date:

{"v":1, "kind":"spacebackup-destinations", "machine":"easytags-mbp",
 "targets":[{"pc":"CHIA2","dest":"<dest id>","rels":["Users\\vlad\\Documents"]}, {"pc":"CHIA3","dest":"<dest id>","plain":true}],
 "keep":30, "issued":"2026-11-06T10:00:00Z", "expires":"2027-02-04T10:00:00Z"}

rels: a computer's folders on that drive (their places in a date folder; only those files go there); absent: the whole date. plain: a phone's Not encrypted drive (only a plain copy goes there; absent: only an encrypted one). Valid at most 400 days; a computer signs one for 90 days at each run and puts it in the placement file it stores on every drive it reaches (placement, field Destinations); a phone sends it with replica.destinations. A later one replaces an earlier one; every PC that is asked under it keeps it, so the PCs holding the machine's drives all learn it.

replica.spread.dates#

replica.spread.files#

replica.spread.begin#

audit.local#

audit.fix#

replica.destinations#


Reading and browsing#

Devices read backups back with dates, list, stat, read and readmany. None of them takes a job slot or moves anything, so browsing never waits behind backups. A device reads its own folder freely (plain and encrypted, as stored). Another machine's folder is served only after a grant on the same connection: then its whole folder, read-only, encrypted trees as ciphertext (the reader needs the data key) and plain folders as they are. Without a grant: {"ok":false, "refused":true, "needsGrant":true, "error":"<machine>'s backups are served only after a grant (a ticket from the account service)"}.

list and stat with machine are described above.

dates#

{"op":"dates", "dest":"3F9A1C07B2E4", "cf":true, "machine":"Annas-iPhone"}
{"ok":true, "dates":["2026-10-15","2026-10-16","2026-10-17"], "incomplete":["2026-10-17"], "partial":["2026-10-16"]}

read#

A byte range of one file.

{"op":"read", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16", "rel":"Photos\\2026\\10\\IMG_1234.HEIC", "offset":0, "length":1048576}
{"ok":true, "size":2381044, "offset":0, "length":1048576, "mtime":639277705310000000}

…one data frame…

{"ok":true, "done":true, "sent":1048576}

video.copy#

A phone's H.264 copy of a video it cannot decode (an iPhone's Dolby Vision / 10-bit HEVC HLG on a phone whose HEVC decoder is 8-bit only).

{"op":"video.copy", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-22", "rel":"Photos\\2026\\10\\IMG_4713.MOV"}
{"ok":true, "state":"making", "seconds":18.4, "done":6.2}

video.copy.read#

A byte range of a ready copy (video.copy answered ready), sent as read sends a file.

readmany#

Several whole files of one date in one request: a screenful of thumbnails in one round trip.

{"op":"readmany", "dest":"3F9A1C07B2E4", "cf":true, "date":"2026-10-16",
 "rels":["Thumbs\\2026\\10\\IMG_1234.HEIC.jpg", "Thumbs\\2026\\10\\IMG_1235.HEIC.jpg"]}
{"ok":true, "rel":"Thumbs\\2026\\10\\IMG_1234.HEIC.jpg", "size":35120, "mtime":639277705310000000}

…data frame, {"ok":true,"done":true,"sent":35120}, the next file…

{"ok":true, "done":true, "all":true}

cancel#


Sharing: read tickets#

A share of a device's backups (or an approved restore) lets another member's devices read that device's backups from any PC holding them (see Sharing a device's backups).

  1. The reader gets a ticket: POST /account/api/peer-tickets {"sourceDevice"} → {ticket, sourceDevice, sourceName, reason, expires} (1 hour, for that reader device and source).
  2. The reader sends grant on its connection to the PC.
  3. The PC confirms the ticket with POST /account/api/peer-tickets/check (its own device token) and caches the answer (yes 5 minutes, no 1 minute). A stopped share stops being served within 5 minutes.

grant#

{"op":"grant", "ticket":"pt_Q2x7mR4vK9…"}
{"ok":true, "machine":"ANNA-PC", "until":"2026-10-17T10:12:00Z"}

Albums#

An album is a plain copy of chosen photos and videos, kept on one or more album drives of the company's PCs (see Albums). On a drive: <root>/Albums/<album id>/album.json, the items' files flat beside it, thumbnails under Thumbs/<file>.jpg. Album ids are al_ + 16 base32 characters.

Album tickets and who may do what#

Every album.* request carries ticket: an album ticket from the account service (POST /account/api/albums/{id}/tickets, valid 1 hour, bound to the calling device), or a relay ticket (30 days, bound to a PC, for its transfer jobs). The PC confirms it with POST /account/api/album-tickets/check, cached as above. One exception to the 5 minutes: when a write names a drive (dest, dests, alsoTo) that the cached yes does not list, the PC asks the service again before refusing (at most once per 10 seconds per ticket). The confirmed ticket says who asks, the album, its owner, the caller's access and the album's drives.

AccessWho
ownerA device of the album's owner.
memberA device of a member it is shared with (view and save).
member-addThe same, with members can add on: may add, clone in, remove and caption what they added (memberDevices: that member's device names).
relayA PC's relay ticket for its transfer jobs (a member's relay ticket also names the member; a filter's names filterMachines).
filterA PC filling an album by its standing filter (iOS request #57, POST /account/api/albums/auto): filterMachines, the devices whose items it adds.
guestSomeone outside the company; only on the guest channel.
RequestAllowed
album.list, album.read, album.readmanyThe ticket's own device, owner or member.
album.addThe ticket's own device, owner or member-add.
album.putA filter ticket's own PC, of an item whose source is one of filterMachines (addedBy is the album's owner, whatever is sent); a PC passing on the owner's request for an album drive on this PC; a PC passing on a member-add member's add (one of the album's PCs, or a PC that is not one of that member's own devices); a PC's relay ticket for its own jobs. A member's device never sends it itself. The phone-shaped form (meta): the device owning a public album, into that album; from album 9 also any device of the member who owns an ordinary album, into it (never an album shared with them; below).
album.remove, album.captionThe ticket's own device, owner or member-add (a member: only items whose addedBy is theirs); a PC passing on such a request; a relay ticket. Never member or a guest.
album.deleteThe owner's device; a PC passing on the owner's request; the owner's relay ticket.
album.copyThe owner's device.
album.statusThe ticket's own device, owner or member.
album.cloneThe ticket's own device: owner or member-add of album, and from.ticket given to that same device, owner or member of from.album. A relay ticket serves neither.

A relay ticket serves only album.put, album.remove, album.delete (and album.caption jobs) from that PC itself; for a deleted album only album.delete; a filter's relay ticket only album.put. A filter ticket serves nothing else either. Every write names destinations (dest/dests, this PC's ids); each must be one of the album's drives on this PC, else {"ok":false, "refused":true, "error":"CHIA2 G: is not one of this album's drives"}. A refused ticket is refused: true ("This album ticket was given to …", "This ticket is for another album", "Only the album's owner can change it", "An album request needs a ticket from the account service").

Item (in album.json): {id, source, files:[stored names], thumb, kind, created, place:{lat,lon}|null, added, size, addedBy?, caption?, <index fields>?}; kind is photo, video, live or file. An item is identified by (source, id): adding it again changes nothing. Item ids: 1–64 characters, letters, digits, -, _.

Item index fields#

album 8 (iOS request #53): modified, w, h, duration, types, camera, labels, text, colors, bright, description, transcript, frames, analysed, flat on the item, in the same shapes as the phone's month index (labels [[name, confidence]], camera {model, lens, iso, exposure, flash}, transcript {lang, text}, frames [[seconds, [[name, confidence]]]], analysed {by, at, v, what}), each absent when the source had none; at most 64 KB per item. Taken at album.add from what the device sends with the item, under the source's month index when the source is a plain date on that PC (the index wins); an encrypted source's index is never read. Carried by album.put, album.copy and album.clone. Items added earlier are filled at album.list from a source's plain, complete date on that PC (and written to album.json). A Space Vision analysis of the album copy merges into them as into a month index entry. Never the owner's private flags (favorite, archived, deleted, hidden), uploaded, edited, the index's caption, or anything about the owner's other devices: the PCs keep only the fields listed, whatever is sent.

Pushed drive (in answers that send to other PCs): {pc, dest, drive, state, ok, error?, added?, waiting?} with state done, waiting (kept as a transfer job on this PC for that PC; retried every minute for up to 30 days) or failed (refused); ok is true only for done.

album.add#

Makes plain copies of items from the caller's own backups on this PC, into the album on this PC's drives, and sends them on to album drives on other PCs.

{"op":"album.add", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"], "key":true,
 "items":[{"id":"9f2c41d07a8be613", "files":["Photos/2026/10/IMG_1234.HEIC","Photos/2026/10/IMG_1234.MOV"],
           "thumb":"Thumbs/2026/10/IMG_1234.HEIC.jpg", "kind":"live", "created":"2026-10-13T18:02:11Z",
           "place":{"lat":36.1147,"lon":-115.1728}}],
 "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}

…one data frame of 32 bytes (the key)…

{"ok":true, "added":["9f2c41d07a8be613"], "already":[], "failed":[],
 "pushed":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","state":"done","ok":true,"error":null,"added":1,"waiting":0}],
 "count":42, "job":"job_4be0c2a19f7d3e65"}

album.put#

One item into one album drive of this PC, its files streamed. Usually sent by a PC to another PC (the album's other drives); an owner's device may send it too, a member's device never.

{"op":"album.put", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dest":"3F9A1C07B2E4", "queued":"2026-10-17T10:20:00Z",
 "item":{"id":"9f2c41d07a8be613", "source":"Annas-iPhone", "kind":"live", "created":"2026-10-13T18:02:11Z",
         "place":{"lat":36.1147,"lon":-115.1728}, "files":["IMG_1234.HEIC","IMG_1234.MOV"], "thumb":"IMG_1234.HEIC.jpg",
         "addedBy":"anna@acme.com"}}
{"ok":true, "files":["IMG_1234.HEIC","IMG_1234.MOV"], "thumb":"IMG_1234.HEIC.jpg"}

…data frames, {"op":"end","mtime":639277705310000000,"hash":"…"} per file…

{"ok":true, "count":43}

album.put from the owning device (public album)#

The phone's own plain copy of an item for a public link (iOS request #42): it reads and decrypts the item itself and sends the plain file into its Shared publicly album (made with POST /account/api/albums {"public": true}), with the same fields and data frames as the backup put. No key is lent. The lent-key path (album.add) stays as it is for ordinary albums.

From album 9 (0.14.3, iOS request #67) the same put also goes into an ordinary album its member owns: the phone's files shared into Space Backup from another app ("From other apps") are in no backup, so it sends them this way. Items of its library still go through album.add. id is then the phone's own (x and 15 hex digits), source the device and created from meta.created.

{"op":"album.put", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "id":"9f2c41d07a8be613",
 "dests":["d1"], "alsoTo":[{"pc":"CHIA3", "dest":"e2"}], "created":"2026-10-03T18:02:11Z",
 "meta":{"name":"IMG_1234.HEIC", "size":2481152, "mtime":639277705310000000, "kind":"photo", "month":"2026-10"},
 "thumb":{"size":18342}}
{"ok":true, "files":["IMG_1234.HEIC"], "thumb":"IMG_1234.HEIC.jpg"}

…data frames, {"op":"commit", "hash":"8c1e…(32 hex)"}, thumbnail data frames, {"op":"commit", "hash":"02af…"}…

{"ok":true, "added":true, "count":12, "pushed":[{"pc":"CHIA3", "dest":"e2", "state":"done", "ok":true, "added":1}]}
{"ok":true, "count":7, "pushed":[{"pc":"OFFICE-PC", "dest":"5B7E19A0C3D2", "drive":"OFFICE-PC E:", "state":"done", "ok":true, "added":1, "waiting":0}]}

album.changes#

What was added to and removed from an album on this PC since a counter (#70): a device with the album open applies it instead of reading the album again. The same request and answer as backups.changes, for the part album:<album>.

{"op":"album.changes", "ticket":"<album ticket>", "album":"al_5Kp9", "since":"a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a:40"}

album.list#

{"op":"album.list", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8"}
{"ok":true, "dests":["3F9A1C07B2E4"], "dest":"3F9A1C07B2E4",
 "album":{"v":1, "id":"al_k3j9x2m4p7q1r5s8", "name":"Las Vegas", "owner":"anna@acme.com", "updated":"2026-10-17T10:20:04Z",
          "items":[{"id":"9f2c41d07a8be613", "source":"Annas-iPhone", "files":["IMG_1234.HEIC","IMG_1234.MOV"],
                    "thumb":"IMG_1234.HEIC.jpg", "kind":"live", "created":"2026-10-13T18:02:11Z",
                    "place":{"lat":36.1147,"lon":-115.1728}, "added":"2026-10-17T10:20:04Z", "size":5123456,
                    "addedBy":"anna@acme.com", "caption":"Dinner at the Bellagio",
                    "modified":"2026-10-13T18:05:00Z", "w":4032, "h":3024, "types":["portrait"],
                    "camera":{"model":"iPhone 17 Pro","iso":80}, "labels":[["dinner",0.91],["table",0.62]],
                    "description":"Two people at a dinner table.", "colors":{"orange":0.41,"brown":0.22}, "bright":0.38,
                    "analysed":{"by":"CHIA2","at":"2026-10-19T22:10:00Z","v":1,"what":["labels","description","colors","bright"]}}]},
 "files":[["IMG_1234.HEIC", 2381044, 639277705310000000], ["IMG_1234.MOV", 2742412, 639277705310000000], ["Thumbs/IMG_1234.HEIC.jpg", 35120, 639278252430000000]]}

album.read#

{"op":"album.read", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "name":"IMG_1234.HEIC"}

album.readmany#

{"op":"album.readmany", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "names":["Thumbs/IMG_1234.HEIC.jpg","Thumbs/IMG_1240.HEIC.jpg"]}

album.remove#

{"op":"album.remove", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"],
 "ids":["9f2c41d07a8be613"], "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}
{"ok":true, "removed":1, "count":41,
 "pushed":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","ok":true,"state":"done"}]}

album.deleted#

The album's Deleted area (iOS request #97): what album.remove took out in the last 30 days.

{"op":"album.deleted", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8"}
{"ok":true, "dests":["5B7E19A0C3D2"], "dest":"5B7E19A0C3D2",
 "items":[{"id":"9f2c41d07a8be613", "source":"Annas-iPhone", "files":["IMG_1234.HEIC"], "thumb":"IMG_1234.HEIC.jpg", "kind":"photo",
           "removedBy":"anna@acme.com", "removedAt":"2026-11-01T22:10:04Z", "purgeAt":"2026-12-01T22:10:04Z"}],
 "files":[["Deleted/IMG_1234.HEIC", 2481920, 638675…], ["Deleted/Thumbs/IMG_1234.HEIC.jpg", 18211, 638675…]]}

album.restore#

Put back (iOS request #97; a whole album: requests #101).

{"op":"album.restore", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"],
 "ids":["9f2c41d07a8be613"], "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}
{"ok":true, "restored":1, "count":42, "pushed":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","ok":true,"state":"done"}]}

album.purge#

Delete permanently of items in the album's Deleted area (iOS request #97).

album.excluded#

The album's Excluded folder (albums.md, Excluded items): the work photos and videos an assistant's add kept out of the album (Space Vision's work label).

album.return#

Return to album of excluded items: their files move from Excluded/ into the album (the first names free), they are listed in album.json's kept (never excluded from that album again) and added as now.

album.flush#

A large put's end (albums put, albums import; Vladimir drops terabyte folders into one album). A PC sending one keeps one connection to each of the album's other PCs for all its files and marks each album.put (both forms) batch: true; the PC taking them records them in album.json held in memory (as the local batch, albums.md), written out every eighth of the album's items (at least 256) or 30 seconds and before anything else changes that album folder there (a put not marked batch, a removal, a caption, the sync, thumbnails). When the put is done the sender asks each of those PCs to write its batch out, and that PC asks the PCs it passed the items on to (the meta form's fan-out), before it answers; when the connection closes without it, the PC writes the batch out then. album.json's format is unchanged.

{"op":"album.flush", "album":"al_k3j9x2m4p7q1r5s8"}
{"ok":true}

album.caption#

{"op":"album.caption", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"],
 "id":"9f2c41d07a8be613", "caption":"Dinner at the Bellagio", "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}
{"ok":true, "captioned":1, "pushed":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","ok":true,"state":"done"}]}

album.delete#

{"op":"album.delete", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"], "alsoTo":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4"}]}

album.copy#

Copies the whole album to new drives (when the owner changed the album's drives). No key: the album is plain.

{"op":"album.copy", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":[], "alsoTo":[{"pc":"BOB-PC","dest":"8C21D0E5F7A9"}]}
{"ok":true, "copied":42, "already":0, "failed":[],
 "pushed":[{"pc":"BOB-PC","dest":"8C21D0E5F7A9","drive":"BOB-PC E:","state":"waiting","ok":false,"error":"BOB-PC is offline","added":0,"waiting":42}],
 "count":null}

album.clone#

A new album made from an existing one (own, or shared with the caller), between the PCs.

{"op":"album.clone", "ticket":"at_P9w3…", "album":"al_m2n8b4v6c1x7z3q5", "dests":["5B7E19A0C3D2"], "alsoTo":[],
 "from":{"ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8"}, "ids":["9f2c41d07a8be613"]}
{"ok":true, "added":["9f2c41d07a8be613"], "already":[], "failed":[], "pushed":[], "count":1, "job":"job_71c3a08e5d2b94f0"}

album.merge#

Merging two albums (docs/albums.md "Merging two albums"): every item of two of the owner's albums into a new album, each once. The account service makes the new album and archives the two first (POST albums/merge).

{"op":"album.merge", "ticket":"at_P9w3…", "album":"al_m2n8b4v6c1x7z3q5", "dests":["5B7E19A0C3D2"], "alsoTo":[],
 "from":[{"ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8"}, {"ticket":"at_3MZ1…", "album":"al_q4w7e2r9t5y1u3i6"}], "detach":true}
{"ok":true, "accepted":true, "job":"job_71c3a08e5d2b94f0", "of":57, "notifies":true}

album.status#

{"ok":true, "drives":[{"pc":"ANNA-PC","dest":"5B7E19A0C3D2","drive":"ANNA-PC D:","state":"done","items":42},
                      {"pc":"BOB-PC","dest":"8C21D0E5F7A9","drive":"BOB-PC E:","state":"waiting","waiting":42,"error":"BOB-PC is offline","since":"2026-10-17T10:31:00Z"}],
 "jobs":[]}

album.add and album.clone as PC-side jobs#

Since album 7 every album.add and album.clone is a job of the PC: it finishes every item, its copies on this PC's drives and the fan-out to alsoTo (or their transfer jobs) whether or not the caller is still connected. Its progress frames and answer are sent best-effort: once a send fails (the phone was minimized, the network changed), the PC logs it and sends nothing more for that job, and the job goes on. The lent key is dropped when the job ends (before its answer), as before; the album's item count goes to the account service then, as after every change.

{"op":"album.add", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "dests":["5B7E19A0C3D2"], "key":true, "detach":true, "items":[…], "alsoTo":[…]}
{"ok":true, "accepted":true, "job":"job_4be0c2a19f7d3e65", "of":120}
{"op":"album.job", "ticket":"at_7KQ2…", "album":"al_k3j9x2m4p7q1r5s8", "job":"job_4be0c2a19f7d3e65"}
{"ok":true, "job":{"job":"job_4be0c2a19f7d3e65", "op":"add", "state":"done", "by":"Annas-iPhone", "detached":true, "done":120, "of":120,
 "started":"2026-10-20T21:02:11.0000000Z", "finished":"2026-10-20T21:04:40.0000000Z",
 "result":{"added":["9f2c41d07a8be613", "…"], "already":[], "failed":[], "pushed":[{"pc":"OFFICE-NAS","dest":"3F9A1C07B2E4","drive":"OFFICE-NAS /mnt/backup1","state":"done","ok":true,"error":null,"added":120,"waiting":0}], "count":162},
 "error":null}}

Guests#

The guest channel#

A guest is someone outside the album owner's company with an accepted invitation to an album (see Guests from outside the company). A guest has no company key, so it opens its own channel on the PC's peer port (a relay pipe in guest mode, or a LAN connection), proving its registered device key and an album ticket from its guest pass (POST /account/api/guest/pass). The PC proves its own registered key. Needs a PC with album 4 that is signed in to the account service.

The guest pass, and each album ticket in it, is good until its expires (1 hour; ask for a new one when less than 10 minutes are left). Its per-company relay value is the relay pass, sealed for the relay: its JSON holds the group, company, device, expiry (x, Unix seconds), the PCs the guest may reach, and ExpiresAt (the same expiry as an ISO 8601 date-time); see Guests at the relay.

  1. Guest → PC (plain frame): {"v":1, "guest":1, "name":<device name>, "inst":<instance id>, "nonce":<32 bytes b64>, "eph":<ephemeral P-256 SPKI b64>, "ticket":"at_…"}.
  2. The PC confirms the ticket (access guest, its device name is name, the album has a drive on this PC, fewer than 8 guests connected). Else {"error":"…"} and the end. PC → guest: {"v":1, "name", "inst", "nonce", "eph"}.
  3. Both compute, with G = the guest device's registered key, P = the PC's registered device key, g/p the ephemerals: ee = ECDH(g,p), es = ECDH(G,p), se = ECDH(g,P) (32-byte X coordinates); th = SHA-256(L("SpaceBackup guest v1") | L(nc) | L(ns) | L(gName) | L(gInst) | L(pName) | L(pInst) | L(gEph) | L(pEph) | L(ticket)); then HKDF-SHA256(ikm = ee‖es‖se, salt = nc‖ns, info = SpaceBackup guest v1 keys ‖ th, 128 bytes) = c2s key ‖ s2c key ‖ client MAC key ‖ server MAC key (32 bytes each).
  4. Guest → PC {"mac": b64(HMAC-SHA256(clientMacKey, "client\n" ‖ th))}; PC → guest {"mac": b64(HMAC-SHA256(serverMacKey, "server\n" ‖ th))}, which the guest checks against the PC key from its pass. Then the same encrypted frames as the company channel.

Refusals at the hello include: a guest's connection needs an album ticket, the account service did not confirm this ticket, not a guest's ticket, this ticket was given to <name>, not to <device>, the album <name> is not kept on <PC>, this PC serves too many guests now; try again later, this PC cannot serve guests (it is not signed in to the account service), the device's key does not match the one registered for it.

What a guest may send#

Only the handshake's album; ticket may be left out (the handshake's is used):

OpAs for a member, except
album.list {album, dest?}album.json comes without the items' source, without removed, and without analysed.by.
album.read {album, dest?, name, offset?, length?}none.
album.readmany {album, dest?, names}none.
album.changes {album, since?} (changes 1)add items come as a guest's album.list gives them (no source, no analysed.by).
changes.watch {parts} (changes 2)Only the part album:<album> of the handshake's album; any other part is refused once ({"ok":true, "refused":{part, "error":"A guest may only view the album shared with them"}}), the album goes on. add items as in album.changes. A ticket the account service no longer confirms, checked before each record: refused for the part, and the connection closes.

What the iPhone sends#

The phone is an ordinary client of the requests above; nothing on a PC is phone-only. In short:

TaskRequests
ConnectLAN address (from the relay's lanAddrs when on the same public IP), else a relay pipe; the company channel handshake; caps. The phone announces Port 0, no Dests, Ver ios-<version>.
A backup runprepare, mark, stat/list, link, putsmall/put (with dests for several drives of one PC), unmark, release.
Change an older date (Archive, a rewritten month index)A run on that date: mark, the writes, unmark.
Remove from backupsremove (one per date and destination).
Several computers chosenOne run to the primary, then replicate with a grant; replicas at its next run for dates not done everywhere.
Destinations changed, Rearrangerearrange with a rearrange grant; replicas {rearrange:true}.
Browse, view, savedates, list, read, readmany (read ≥ 3), cancel; grant first for a shared device.
Albumsalbum.add (key lent) to the PC holding its newest backup, album.list/read/readmany to view, album.remove/delete/caption to the same PC, album.copy when the album's drives change, album.clone, album.status.

See also The iPhone and iPad app.


Google Drive helper: gdrive-speed#

gdrive-speed#

The PC that backs up a Google account asks the other PCs how fast they download from Google Drive, to suggest the best worker.

{"op":"gdrive-speed", "token":"ya29.a0AfB_FAKE…"}
{"ok":true, "mbps":41.7, "free":912384000000, "error":null}

Google Drive assignment records (which PC backs up which account) travel in the LAN announcements (Gd), not as requests.

Space Vision#

Phase 1 (docs/space-vision.md#phase1, iOS request #40). What the PCs learn about the photos and videos of a phone's Not encrypted backups is written into the plain month index of its newest complete date (labels, text, colors, bright, camera where the phone had none, description, a video's transcript and frames, and analysed {by, at, v, what}), so browsing needs no new request. Encrypted trees are never read. The three requests below take the same right as read: the caller's own machine, another only under a grant.

vision.status#

vision.coverage#

vision.audit#

vision.covered#

vision.progress#

vision.viewing#

geo.resolve#

geo.places#

geo.names#

search.index#

vision.get#

Workers on other PCs (phase 2)#

A GPU PC analyses another PC's plain phone backups (docs/space-vision.md#phase2): it proves it is a company device, leases one plain date, reads its files with read / readmany while the lease lives (another machine's files, only that date, only Photos\, Archived\, Thumbs\, never an encrypted tree) and puts the records back; the host merges them into the month index as a local worker's. Plain dates only; every member's devices (0.14.0, iOS request #64; before: the worker's member's own devices and devices shared with them); the host's own worker first. Caps vision-lease: 1. A host with no worker of its own calls a worker as soon as a phone's date is completed there (vision.call with analyse), not at the worker's next round.

vision.challenge#

vision.hello#

vision.pending#

vision.lease#

vision.unlease#

vision.put#

Selection: which candidates match the user's words#

The phone narrows a request ("night views of Chicago") to candidates by place and date itself; a PC's worker looks at them and says which match (docs/space-vision.md#select, iOS request #51). A read-only judgement: nothing is written to the index. Caps vision-select: 1 (every host: vision: 1). Always a detached job, kept in memory for 24 hours.

vision.select#

vision.job#

vision.embed#

vision.call#

vision.selectlease#

vision.selected#

Assistant jobs: the computers finish a request#

The phone hands an assistant request over once and may close, lose signal or be paused; the PC holding its backups finishes it (iOS request #61; docs/assistant-jobs.md). Caps assistant-job: 1 (2 since 0.14.0: shared albums, no consent; 3: assistant.job.cancel). The PC:

  1. takes the candidates from its index of the machine's plain dates: place (a circle), days (from/to, days, the item's own local day), time of day, kind, night or day (the rules of album filters); and (assistant-job: 2) from the albums shared with the user that it holds (the reading's shared), by the index fields each album item keeps;
  2. selects by what they show (content) as vision.select does: the stored analysis and vectors first, a worker for the rest, up to 5,000 newest candidates; a shared album's items by the analysis the album keeps only (one never analysed is left out); no content: every candidate;
  3. for makeAlbum / shareAlbum, makes the album on the account service for the phone's member, on its own drive holding the phone's backups, with the standing filter and the shares, presenting the job and the phone's job ticket (jobTicket) (POST assistant/jobs/album);
  4. adds the chosen items from its backups, as a filter adds them; an item held only in encrypted backups is copied with the lent key, else listed in encrypted; an item no backup here holds goes in needsPhone; the chosen items of shared albums are cloned in as album.clone copies them (each keeps its source and id);
  5. tells the phone: POST assistant/jobs/done sends the member an alert ("Night Chicago Views" / "23 photos added") and their devices changed: ["album:<id>", "albums"]; only for a job sent with a jobTicket (a show job without one is read from its status).

The phone's Stop (assistant.job.cancel, assistant-job: 3, iOS request #73) ends a job after the step it is on: what it did stays, its state is cancelled, and step 5 is skipped (no alert).

Jobs are kept 24 hours in memory (not across a restart: the status then answers notFound and the phone runs the request itself); one runs at a time. The user's words stay with the job: never logged, never sent on. When assistant-job is 0 or absent, or the submit is refused, the phone keeps today's path (it selects and adds itself).

assistant.job#

assistant.job.status#

assistant.job.cancel#

The Assistant's Stop (iOS request #73; caps assistant-job: 3).

{"op": "assistant.job.cancel", "job": "aj_3f9a1c07b2e4d5c6a7b8c9d0"}
{"ok": true, "job": "aj_3f9a1c07b2e4d5c6a7b8c9d0", "state": "running", "cancelling": true}

Other requests and updates#

There are no other peer requests. In particular:


The Photos viewer launch contract#

The Photos window on Windows, macOS and Linux (see The Photos window on a computer) is a web page served by the local app on this computer and shown inside the app's own window (WebView2, WKWebView, WebKitGTK). This contract is between the app window and that local server; it is not the peer protocol and never leaves the computer.

Starting the server#

Run photos open --json through the app's control channel (sbctl photos open --json on Windows, spacebackup photos open --json on Linux and macOS, or the control socket / named pipe the app already uses):

{"url":"http://127.0.0.1:52814/?s=Yk3vQ9x2LmP0aR7tU4wE1zC8nB6dF5gH0jK2sV9qXcA", "port":52814, "secret":"Yk3vQ9x2LmP0aR7tU4wE1zC8nB6dF5gH0jK2sV9qXcA"}

Loading the page#

  1. Load url in the window. The first request, /?s=<secret>, answers 302 to / with Set-Cookie: sbphotos<port>=<secret>; Path=/; HttpOnly; SameSite=Strict, so the secret leaves the address bar. A wrong secret answers 401 with "This Photos window has expired. Open Photos again from Space Backup."
  2. Instead of the URL, a host may set that cookie itself before the first load (the Windows window does), or send the header X-SpaceBackup-Secret: <secret> on its own requests. The page itself works with the cookie.
  3. To open a screen, append #albums, #places, #types or #shared to url (default: All).
  4. / serves the viewer (photos.html); its scripts, styles and images are embedded in the app (no external CDN, works offline).

Security rules#

CheckAnswer
Host other than 127.0.0.1:<port> or localhost:<port> (DNS rebinding)421 Wrong host
Origin other than the viewer's own403 Other origins are refused
Sec-Fetch-Site other than same-origin or none403 Other sites are refused
A POST with the cookie only and no Origin403 A request that changes something must come from the viewer
No valid cookie or header/api/…: 401 Not signed in to this viewer; pages: 401 with the "expired" page
Method other than GET, HEAD, POST405

Every answer carries Cache-Control: no-store (nothing decrypted lands in the web view's disk cache), X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, Cross-Origin-Resource-Policy: same-origin, X-Frame-Options: DENY; pages carry the CSP default-src 'self'; img-src 'self' blob: data:; media-src 'self' blob:; style-src 'self'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'. No CORS headers, ever. The secret is compared in constant time.

Limits: 64 connections at once, keep-alive connections closed after 2 minutes idle, request head at most 32 KB (431), body at most 1 MB (413).

Endpoints#

EndpointDoes
GET /api/session{platform, email, restoreTo, saveTo, cache:{bytes, limit}}: the signed-in email, default Restore and Save folders, cache size.
GET /api/sources[?refresh]The photo sources (own devices, shared devices, albums), as photos sources.
GET /api/changed/wait[?after=<cursor>][&wait=<s>]{cursor, changed, full}: live updates, as changes wait. Without after, the cursor to start from, at once; with it, the topics this computer learned of after it (albums, album:<id>, backups:<device>, devices, shares, faces, settings, languages, pictures, notifications, destinations, computers, runs…; each once, oldest first), held up to wait seconds (default and at most 25) until one comes; full: true: the cursor is not known here (the app restarted) or too old, read everything. Not for a TV's session or a page window.
GET /api/items?source=d:<device>|a:<album id>[&refresh]{source, from, date, problem, items}: one source's items, as photos list --source.
POST /api/thumbs {"ids":[…], "make"?:bool}{"thumbs":{id: base64 JPEG}, "later":[ids]}, up to 200 ids. make: false: stored thumbnails only, the others named in later (ask again with make, the default).
GET /api/thumb?id=One thumbnail (JPEG), 404 when none.
GET /api/preview?id=A picture the web view can show: JPEG for HEIC/HEIF, RAW, TIFF and pictures larger than 4,096 px.
GET /api/file?id=[&file=<name>][&download=1]The original file (HTTP Range: one range, 206/416); download=1 adds Content-Disposition: attachment.
GET /api/video?id=The item's video, with HTTP Range, so it plays while arriving.
POST /api/cli {"args":[…]}{exit, text, data}: the same dispatcher as the command line, limited to photos sources|list|show|save|preview|restore|add|new-album|assistant, albums list|show|create|share|unshare|restore|caption, share list, history, browse, restore, account status, dest list. Paths in arguments must be full paths. Anything else: exit code 2, "… is not available from the Photos viewer".

Errors are JSON {"error":"…"}: 400 (bad request or usage), 404 (not found, "That file is not in the backup."), 502 (the backup could not be read: a PC offline, a decryption problem).

Folder picker#

Optional. The page posts the JSON string {"op":"pickFolder", "id":"…", "start":"<path>"} to window.webkit.messageHandlers.spacebackup (WKWebView, WebKitGTK) or window.chrome.webview (WebView2). The host answers by running window.spaceBackupReply("<id>", "<chosen path>" | null) in the page, or (WebView2) by posting {"id":"…", "value":"<path>"} back. Without a host the dialog keeps a text field with the default folder.

Lifetime#