# Space Backup peer protocol, machine-readable. # Derived from the code (src/SpaceBackup/Crypto.cs, Remote.cs, Guests.cs, Albums.cs, AlbumJobs.cs, Replication.cs, # Rearrange.cs, PeerGrants.cs, DeviceKeys.cs, GDriveService.cs), not from the prose of chapter 10. # Kept honest by tests/SpaceBackup.Tests/PeerProtocolSchemaTests.cs: every op the dispatchers handle, every capability # the PC announces and the worked examples' byte lengths are checked against the real code. # Subset: 2-space indent, maps, lists, scalars, block scalars; no anchors. # Placeholders in messages: {name}. Types: string, bool, int (64-bit), ticks (.NET ticks UTC), b64 (base64), hex. info: title: "Space Backup peer protocol" protocolVersion: 1 transcriptLabel: "SpaceBackup v1" manual: "10-api-peer.md" relayManual: "11-relay.md#relay-protocol" ports: peerTcp: 47800 discoveryUdp: 47801 discoveryMulticast: "239.255.47.80" sources: - "src/SpaceBackup/Crypto.cs" - "src/SpaceBackup/Remote.cs" - "src/SpaceBackup/Guests.cs" - "src/SpaceBackup/Albums.cs" - "src/SpaceBackup/AlbumJobs.cs" - "src/SpaceBackup/Replication.cs" - "src/SpaceBackup/Rearrange.cs" - "src/SpaceBackup/PeerGrants.cs" - "src/SpaceBackup/DeviceKeys.cs" - "src/SpaceBackup/GDriveService.cs" jsonNotes: - "Requests and answers are UTF-8 JSON objects, camelCase field names (System.Text.Json defaults)." - "The sender's JSON encoder escapes non-ASCII and the characters < > & ' + as \\uXXXX (System.Text.Json's default encoder): a base64 '+' is sent as \\u002B. Parse with a real JSON parser." - "Fields whose value is null may be present as null; treat null and absent alike. Ignore unknown fields." - "Every answer has ok (bool). ok:false answers carry error (string) and may carry refused, needsGrant, superseded, busy, retry, missing, full, verify." conventions: dest: "destination id of the PC you talk to: first 12 hex digits (upper case) of SHA-256(UTF-8 'MACHINE|path'), machine upper case, path lower case" cf: "bool, the sender's 'computer name first' layout; true (default): //; false: //" date: "yyyy-MM-dd; anything else: 'Invalid date folder: {date}'" rel: "path inside the date folder, / or \\ accepted, answers use \\; checked by PathGuard.Resolve" machine: "1-64 chars, ASCII letters, digits, - _ .; starts with letter or digit; not ending with .; no ..; not reserved; else 'Invalid machine name: {name}'" mtime: "ticks: .NET ticks UTC (100 ns since 0001-01-01)" hash: "XxHash128 of the file content, 32 hex digits" driveNames: "drives in messages are named as `dest list` shows them: 'CHIA2 G:'; unknown: 'an unknown drive of CHIA2'" frames: manual: "10-api-peer.md#frame-format" plain: manual: "10-api-peer.md#plain-frames" use: "the four handshake messages (and a refusal)" layout: - "4 bytes: length n, signed int32 big-endian" - "n bytes: UTF-8 JSON object (JsonObject.ToJsonString)" maxBytes: 4096 errors: - message: "Bad frame length" when: "n < 0 or n > 4096" - message: "Bad handshake" when: "not JSON" encrypted: manual: "10-api-peer.md#encrypted-frames" layout: - "4 bytes: length L = 1 + body + 16, signed int32 big-endian" - "L - 16 bytes: AES-256-GCM ciphertext of (type byte | body)" - "16 bytes: GCM tag" types: json: 0 data: 1 cipher: "AES-256-GCM, 16-byte tag, no associated data" nonce: "12 bytes, not sent: 4 zero bytes | frame counter (uint64 big-endian); one counter per direction, 0 for the first encrypted frame, +1 per frame" maxFrame: 4194304 maxFrameMeaning: "type byte + body at most MaxFrame (4 MiB): body at most 4194303 bytes; sent L at most 4194320" receiverAcceptsL: "17 <= L <= 4194320 (ReadLength(MaxFrame + 16)); outside: 'Bad frame length', connection closed" overhead: 21 overheadMeaning: "4 length bytes + 1 type byte + 16 tag bytes per frame" dataChunk: 1048576 dataChunkMeaning: "senders cut file data into data frames of at most 1 MiB" errors: - message: "Frame failed authentication" when: "tag does not verify (tampered, reordered, replayed, wrong key); connection closed" - message: "Frame too large" when: "sender side, body + 1 > MaxFrame" - message: "Unexpected data frame" when: "a data frame where a JSON message was expected; connection closed" - message: "Empty message" when: "JSON frame whose body is the JSON null" ordering: - "answers come in request order; requests may be pipelined" - "one request at a time per connection; parallelism = more connections (engine: up to 4 per peer destination)" - "cancel is the only message read while an answer is being sent (it stops a readmany)" - "the connection stays usable after any ok:false answer; a ChannelException closes it" handshake: manual: "10-api-peer.md#handshake" company: steps: - from: "client" frame: "plain" json: "{\"v\":1,\"name\":,\"inst\":,\"nonce\":}" - from: "server" frame: "plain" json: "{\"v\":1,\"name\":,\"inst\":,\"nonce\":} or {\"error\":...}" - from: "client" frame: "plain" json: "{\"mac\":b64(HMAC-SHA256(authKey, UTF-8 'client\\n' | T))}" - from: "server" frame: "plain" json: "{\"mac\":b64(HMAC-SHA256(authKey, UTF-8 'server\\n' | T))} or {\"error\":\"company key does not match\"}" transcript: "T = L('SpaceBackup v1') | L(nc) | L(ns) | L(clientName) | L(clientInst) | L(serverName) | L(serverInst); L(x) = int32 big-endian length | bytes; names UTF-8; nc, ns the raw 32-byte nonces" macCompare: "constant time (CryptographicOperations.FixedTimeEquals)" nonceBytes: 32 macBytes: 32 refusals: - message: "invalid machine name" when: "step 2: the client's name breaks the machine name rule" - message: "{name} is this PC's own name" when: "step 2: the client uses the server's name" - message: "this PC serves no guests" when: "step 2: a guest hello (guest field) on a PC without an album host" - message: "busy" when: "step 2, any hello (peer or guest): the device (name + inst) already holds maxConnectionsPerDevice connections with requests under way, or all devices together maxConnections (Space Relay pipes are a pool apart: maxRelayConnectionsPerDevice, maxRelayConnections); also a socket past every slot (maxConnections + maxHandshakes; relay: maxRelayConnections + maxRelayHandshakes), its hello read before a clean close; answered {\"error\":\"busy\",\"retry\":}; wait retry seconds and connect again" - message: "company key does not match" when: "step 4: the client's MAC is wrong" silentClose: - message: "Unsupported protocol version" when: "v is not 1 (either side); logged, no answer" - message: "Bad nonce" when: "nonce not 32 bytes" clientErrors: - message: "Peer refused: {error}" when: "the server answered {error}" - message: "Peer does not have the same company key" when: "the server's MAC is wrong" - message: "{where} is not the expected peer (it is {name})" when: "the answering instance id is not the one the client dialled" guest: manual: "10-api-peer.md#guest-channel" needs: "album 4 on the PC, which must be signed in to the account service" steps: - from: "guest" frame: "plain" json: "{\"v\":1,\"guest\":1,\"name\":,\"inst\":,\"nonce\":,\"eph\":,\"ticket\":}" - from: "pc" frame: "plain" json: "{\"v\":1,\"name\",\"inst\",\"nonce\",\"eph\"} or {\"error\":...}" - from: "guest" frame: "plain" json: "{\"mac\":b64(HMAC-SHA256(clientMacKey, 'client\\n' | th))}" - from: "pc" frame: "plain" json: "{\"mac\":b64(HMAC-SHA256(serverMacKey, 'server\\n' | th))} or {\"error\":...}" agreement: "ee = ECDH(guestEph, pcEph), es = ECDH(guestDeviceKey G, pcEph), se = ECDH(guestEph, pcDeviceKey P); raw 32-byte X coordinates; G and P are the keys registered with the account service" transcriptHash: "th = SHA-256(L('SpaceBackup guest v1') | L(nc) | L(ns) | L(gName) | L(gInst) | L(pName) | L(pInst) | L(gEph SPKI) | L(pEph SPKI) | L(ticket))" keys: "OKM = HKDF-SHA256(ikm = ee|es|se, salt = nc|ns, info = 'SpaceBackup guest v1 keys' | th, 128 bytes) = c2s(32) | s2c(32) | clientMac(32) | serverMac(32)" refusals: - message: "invalid device name" when: "name breaks the machine name rule" - message: "a guest's connection needs an album ticket" when: "ticket empty or longer than 200" - message: "the account service did not confirm this ticket" when: "the service said no" - message: "this PC cannot check the ticket now; try again later" when: "the service could not be asked" - message: "not a guest's ticket" when: "access is not guest, or no registered guest key" - message: "this ticket was given to {requester}, not to {device}" when: "ticket of another device" - message: "the album {albumName} is not kept on {pc}" when: "no album drive on this PC" - message: "this PC serves too many guests now; try again later" when: "8 guests connected" - message: "this PC cannot serve guests (it is not signed in to the account service)" when: "no own registered device key" - message: "bad key" when: "an ephemeral or registered key is not a P-256 SPKI" - message: "the device's key does not match the one registered for it" when: "step 3 MAC wrong" guestSideErrors: - message: "The PC refused: {error}" when: "the PC answered {error}" - message: "{pc} is not the PC the account service registered (its key does not match)" when: "step 4 MAC wrong" sessionKeys: manual: "10-api-peer.md#session-keys" companyKey: master: "PBKDF2-HMAC-SHA256(UTF-8 passphrase.Trim(), salt UTF-8 'SpaceBackup company key v1', 200000 iterations, 32 bytes); passphrase at least 8 chars" purposes: "HKDF-Expand(SHA-256, master, 32 bytes, info = UTF-8 purpose)" purposeNames: - "auth: handshake MACs" - "session: channel keys" - "announce: LAN announcements" - "relay: relay group id" - "fingerprint: first 8 hex digits, shown as XXXX-XXXX" - "account: AccountProof = b64(HMAC-SHA256(Expand(master,'account'), 'space-account-v1'))" - "data-key-recovery: wraps data-key recovery copies" channel: salt: "nc | ns (64 bytes)" c2s: "HKDF-SHA256(ikm = sessionKey, salt, info = 'c2s', 32 bytes)" s2c: "HKDF-SHA256(ikm = sessionKey, salt, info = 's2c', 32 bytes)" cipher: "AES-256-GCM per direction, nonce = 4 zero bytes | counter (see frames.encrypted)" announce: manual: "10-api-peer.md#discovery" layout: "'SBA1' | nonce(12) | AES-256-GCM(announceKey, aad 'SBA1') ciphertext | tag(16)" json: "PascalCase: Inst, Name, Port, Dests[{Id, Path, Root, Free, Online, Disk, Speed, Kind, Keep, Lan, Forms}], Boot, Ver, Gd" every: "30 s, multicast 239.255.47.80:47801 and broadcast" limits: manual: "10-api-peer.md#limits" maxConnections: 128 maxConnectionsPerDevice: 16 maxHandshakes: 32 busyRetrySeconds: 5 reconnectDropsIdleAfterSeconds: 60 maxRelayConnections: 48 maxRelayConnectionsPerDevice: 8 maxRelayHandshakes: 16 relayIdleTimeoutSeconds: 120 maxFrame: 4194304 plainFrameMax: 4096 handshakeReadTimeoutMs: 15000 idleReadTimeoutMs: 900000 serverWriteTimeoutMs: 60000 clientTimeoutMs: 600000 clientMaxIdleMinutes: 4 connectionsPerPeerDestination: 4 jobSlots: 2 jobSlotLingerSeconds: 60 busyRetryBaseSeconds: 30 readManyMax: 64 albumReadManyMax: 64 albumReadManyFileMax: 8388608 maxGuests: 8 guestRatePerSecond: 20 guestBurst: 100 guestMaxRefusals: 100 resumeMinSize: 67108864 resumeBlockSize: 8388608 putSmallBatchFiles: 64 putSmallBatchBytes: 2097152 listChunkBytes: 1048576 replicaFilesPerFrame: 2000 waitMaxSeconds: 600 ticketYesSeconds: 300 ticketNoSeconds: 60 ticketRecheckSeconds: 10 grantMaxLifetimeHours: 24 grantSkewMinutes: 5 captionMax: 2000 errorShapes: manual: "10-api-peer.md#errors" failed: "{ok:false, error}: the request failed; connection fine" unknown: "{ok:false, error:'Unknown request {op}'}: op not known (older PC, or the host for it is off)" refused: "{ok:false, refused:true, error}: not allowed (ReadRefusedException); do not retry the same" needsGrant: "{ok:false, refused:true, needsGrant:true, error}: another machine without a grant on this connection" superseded: "{ok:false, refused:true, superseded:true, error}: replica.* under a rearrange grant older than this PC's own rearrangement of the machine; the asker ends its job" busy: "{ok:false, busy:true, retry:, error}: job slots taken (prepare) or guest rate limit (retry 1)" missing: "{ok:false, missing:true, error}: file not there" full: "{ok:false, full:true, error}: target drive has no room (replica.files)" verify: "{ok:false, verify:true, error}: read-back hash differs (replica.put)" caughtAsFailed: "IOException, UnauthorizedAccessException, ArgumentException, NotSupportedException, FormatException, InvalidOperationException (not ChannelException) become {ok:false, error: exception message}" caps: manual: "10-api-peer.md#caps-table" request: "{\"op\":\"caps\"}" missingMeans: "a key that is missing means 0 / false" serverChecks: "the PC never checks capabilities before serving; an op it lacks answers 'Unknown request {op}'" putsmall: type: "bool" current: true versions: - "true (v0.4.0): putsmall, small files pipelined in batches" dated: type: "bool" current: true versions: - "true (v0.5.0): every request but status and caps names date and cf; prepare, link, prunedate" jobs: type: "bool" current: true versions: - "true (v0.5.3): prepare takes a job slot (busy/retry), release frees it" fanout: type: "bool" current: true condition: "true only when the PC has a fan-out queue (PeerServer.FanOut != null); else false" versions: - "true (v0.5.4): dests on put and putsmall; recheck in prepare" resume: type: "bool" current: true versions: - "true (v0.5.5): resume:true on put, the from frame, mark/unmark, incomplete in prepare" e2e: type: "bool" current: true versions: - "true (v0.5.6): hash on putsmall and on put's commit; Verification failed answers" fetch: type: "bool" current: true versions: - "true (v0.5.6): fetch, a file by its hash for self-repair" placement: type: "bool" current: true versions: - "true (v0.5.9): placement and prunefolder" gdrive: type: "int" current: 1 condition: "1 when the PC has the Google Drive service (PeerServer.Extra != null); else 0" versions: - "1: gdrive-speed" read: type: "int" current: 3 versions: - "1: dates; machine on list and stat; read (byte ranges)" - "2: grant; another machine is served only under a confirmed read ticket" - "3: readmany (up to 64 files) and cancel" album: type: "int" current: 15 condition: "15 when the PC has an album host (PeerServer.Albums != null); else 0" versions: - "1: album.add, album.put, album.list, album.read, album.remove, album.delete" - "2: album.copy, album.status, transfer jobs, relay tickets, queued on album.put, state on pushed drives" - "3: album.clone" - "4: album.readmany and the guest channel" - "5: album.caption (and caption on album.put)" - "6: album.put from the owning device into its public album (meta, as the backup put)" - "7: album.add and album.clone run to the end as PC-side jobs whether or not the caller stays connected; detach:true, album.job, jobs in album.status, job in their frames" - "8: items keep their source's month-index fields (modified, w, h, duration, types, camera, labels, text, colors, bright, description, transcript, frames, analysed): album.add items, album.put item and meta, album.list; never favorite, archived, deleted, hidden (10-api-peer.md#album-item-details)" - "9 (0.14.3, iOS request #67): album.put with meta from a device of the member who owns an ordinary album (not one shared with them), not only into a public album" - "10 (0.16.59, iOS request #97, requests #101): album.remove keeps what it removes in the album's Deleted area 30 days (permanent:true: gone at once); album.list carries it as album.json's deleted (cut to what the caller may see) and its files as Deleted/; album.read of Deleted/; album.deleted, album.restore, album.purge; album.delete keeps the album 30 days in the drive's deleted albums (permanent:true: gone at once)" - "11 (0.16.72, iOS request #103): an item the album has without a thumbnail takes the one brought: album.add sent again (thumbs in its answer; encrypted backups with the lent key), album.copy from a drive that has it, album.put with fillThumb (first answer thumbOnly: only the thumbnail is sent)" - "12 (2026-11-03): a large put's items as one batch on the PC taking them: album.put with batch:true (album.json written once per batch there), album.flush at the put's end" - "13 (2026-11-08): album.merge: every item of two of the owner's albums into a new one, duplicates once (docs/albums.md, Merging two albums)" - "14 (2026-11-08): the album's Excluded folder (docs/albums.md, Excluded items): an assistant's add (AutoAdd, CloneForJob) puts a work item (index field work.conf >= 0.6) into Excluded/, album.json's excluded; album.put's item carries excluded {conf, why}; album.list carries excluded and kept and the files as Excluded/; album.read of Excluded/; album.excluded, album.return; album.remove of an excluded item moves it to the Deleted area" - "15 (2026-11-08): the user's work mark (docs/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 kept); each PC's albums follow a mark on its own drives (not work: returned from Excluded and kept; work: an assistant's add into Excluded with label {conf:1, why, user:true}, its kept entry dropped; a hand add never moves); album.json autoSince" replicate: type: "int" current: 2 condition: "2 when the PC has a replication host (PeerServer.Replicas != null); else 0" versions: - "1: replicate, replicas, replica.begin, replica.files, replica.put, replica.end" - "2 (0.14.0, iOS request #66): catch-up: copies and the reads for them (replica.begin/files/put/end, replica.dates/has/list/read) under a grant past its expires, up to 90 days after it was issued; replica.has/list/read under a replication grant; Replica state resend" rearrange: type: "int" current: 3 condition: "3 when the PC has a replication host; else 0" versions: - "1: rearrange, replicas {rearrange:true}, replica.dates, replica.has, replica.drop, date on replica.begin" - "2: replica.list, replica.read (the primary copies a date from another PC's drive of the grant)" - "3: the form check before replica.drop {form} (missing in the answer), replica.list {any}; a rearranged copy keeps what its source lacks (iOS request #54)" forms: type: "int" current: 1 condition: "1 when the PC has a replication host; else 0" versions: - "1 (2026-10-26): forms (the forms this PC asks the calling phone for on a drive; answers)" spread: type: "int" current: 2 condition: "1 when the PC has a replication host; else 0" versions: - "1 (2026-11-06, onward copies): replica.spread.dates, replica.spread.begin (any company PC holding a date copies it to a drive the source's destinations grant or rearrange grant names), replica.destinations; placement carries the computer's destinations grant" - "2 (2026-11-07, request #157): replica.spread.dates answers a complete date's manifest digest; replica.spread.files (its files), so a PC copies what a drive lacks of a complete date from a sibling copy" remove: type: "int" current: 1 versions: - "1: remove (files and the new month index of a date in one request)" move: type: "int" current: 1 versions: - "1: move (renames inside a date and its new month index files in one step, iOS request #49)" changes: type: "int" current: 3 versions: - "1: backups.changes, album.changes (#70: change records since a counter, one origin PC each)" - "2: changes.watch (an open app's channel: every change of its parts, from this PC and the others), changes.push (PC to PC), album adds and removes recorded (#70)" - "3: move and remove take ids (and a move its group): an encrypted date's moves are recorded as moved/gone instead of full (#70, after 0.14.6)" photoreq: type: "int" current: 2 condition: "2 when the PC keeps the Photos window's requests to phones; else 0" versions: - "1 (2026-10-26): photos.requests (Delete, a caption, a public link the Photos window asks of the calling phone for its own items; answers)" - "2 (2026-11-05): also op archive (archive it in the backups, kept on the phone) and unarchive (out of Archived), the window's Archive / Unarchive" arrival: type: "int" current: 1 versions: - "1 (2026-11-10): every copy is checked as it lands (docs/arrival-check.md): put and putsmall answer checked:true (the sender's hash matched, a photo or video decodes) or checked:false with damaged and resend (kept; a re-send request filed and the device woken at once); a commit without hash is never checked:true; checked:true with kept when the origin has nothing better; checked:false without damaged when the PC could not read the copy (it checks it again itself)" resend: type: "int" current: 1 versions: - "1 (2026-11-10): a damaged backup copy is sent again by its origin (docs/resend.md): prepare answers resend, photos.requests lists op resend, resend.answer takes a PC source's answers" upload: type: "int" current: 1 versions: - "1 (2026-10-28): uploads through the relay's HTTPS door (relay-incoming kind upload; docs/relay-upload.md); mark {uploads: true}" partial: type: "int" current: 1 versions: - "1: unmark {partial:true} (a date closed after a stopped run, .spacebackup-partial); partial in prepare, dates, replica.dates, replica.list; partial on replica.begin" olderPeers: manual: "10-api-peer.md#older-peers" dated: "prepare answers 'Unknown request prepare': the engine fails the destination with '{name} runs an older Space Backup (v0.4 or earlier); update it to v0.5 to back up there'" capsFails: "RemoteStore takes fanout, resume, placement as false" fanout: "each destination gets its own copy; dests is not sent" resume: "mark/unmark not sent (unmark only when resume), no resume:true" e2e: "an older PC ignores hash" placement: "placement and prunefolder not sent" replicateAsTarget: "ReplicaClient: '{pc} runs an older Space Backup without replication' (state failed)" replicate2: "after the grant's time that drive waits with grantExpired ('{pc} runs an older Space Backup that copies only under {machine}'s new grant'); it is not copied from" rearrangeAsTarget: "ReplicaClient: '{pc} runs an older Space Backup without rearranging'" rearrange2: "that PC's copies are not copied from: a form held only there counts as held nowhere (the phone resends it)" rearrange3: "that PC is never asked to drop a date's old form: its drive waits until it is updated; replica.list without any" read2: "grant answers 'Unknown request grant'" proofs: manual: "10-api-peer.md#peer-identity" readTicket: "opaque string from POST /account/api/peer-tickets; the PC confirms it with POST /account/api/peer-tickets/check" albumTicket: "opaque string from POST /account/api/albums/{id}/tickets (1 h) or a relay ticket (30 days); confirmed with POST /account/api/album-tickets/check" replicationGrant: "signed by the source device (grants.replication)" deviceKey: "guest channel ECDH with registered keys" cache: "per ticket (key: SHA-256 of the ticket), shared by all connections: yes for 5 min (never past expires), no for 1 min; service unreachable and nothing cached: IOException, not refused" grants: manual: "10-api-peer.md#replication-grant" replication: manual: "10-api-peer.md#replication-grant" usedBy: - "replicate" - "replica.begin" - "replica.files" - "replica.put" - "replica.end" wire: "grant: {payload: b64(payload bytes), sig: b64(signature)}" signedBytes: "the payload bytes exactly as sent (UTF-8 JSON; no canonical form; the PC verifies the base64-decoded bytes)" payloadFields: v: "int, must be 1" kind: "\"spacebackup-replicate\"" machine: "the source machine name (valid machine name)" date: "yyyy-MM-dd" primary: "the PC the source sends the request to" targets: "[{pc, dest}], at least one" issued: "ISO 8601 UTC (yyyy-MM-ddTHH:mm:ssZ from the PC signer)" expires: "ISO 8601 UTC" algorithm: "ECDSA P-256 with SHA-256" signatureEncoding: "r|s, 64 bytes (IEEE P1363) or DER (Rfc3279 sequence, about 70-72 bytes); the verifier takes 64 bytes as P1363, anything else as DER" key: "the machine's key as the account service has it: GET /account/api/devices/key?name={machine} -> signingKey when registered, else publicKey (SPKI base64)" keyCache: "a key 5 min, 'no such device' 1 min; a signature that fails with a cached key asks once more" expiry: - "expires - issued at most 24 h and > 0" - "issued at most now + 5 min" - "refused from expires + 5 min" - "checked again before every replica.files, replica.put and replica.end" refusals: - message: "No replication grant: a copy needs the source's signed grant" - message: "Bad {grant}: {why}" grant: "'replication grant' ('rearrange grant' when the payload's kind, or else the op, is a rearrangement)" why: - "payload or signature missing" - "not an object" - "neither a replication, a rearrange nor a destinations grant" - "bad machine name" - "bad date" - "no primary" - " drive without pc" - " drive without dest" - "dates is neither" - message: "Bad {grant}: the signature is not base64" - message: "{machine}'s {grant} is valid for too long (at most {hours} hours)" - message: "{machine}'s {grant} is issued in the future" - message: "{machine}'s {grant} has expired" - message: "The account service knows no active device {machine} in this company" - message: "The {grant} is not signed by {machine}'s device key" rearrange: manual: "10-api-peer.md#rearrange-grant" usedBy: - "rearrange" - "replica.begin" - "replica.dates" - "replica.has" - "replica.drop" - "replica.list" - "replica.read" wire: "same envelope as replication" signedBytes: "the payload bytes exactly as sent" payloadFields: v: "int, must be 1" kind: "\"spacebackup-rearrange\"" machine: "the source machine name" primary: "the PC that runs the rearrangement" from: "[{pc, dest}], at least one: drives that held the dates" to: "[{pc, dest, plain?}], at least one: the new drives; plain:true = Not encrypted there" dates: "\"all\" or a non-empty list of yyyy-MM-dd" issued: "ISO 8601 UTC" expires: "ISO 8601 UTC" algorithm: "ECDSA P-256 with SHA-256" signatureEncoding: "as replication" key: "as replication" expiry: - "as replication; the refusal texts there name it a rearrange grant ({grant} = 'rearrange grant')" refusals: - message: "No rearrange grant: a rearrangement needs the source's signed grant" - message: "Bad {grant}: {why}" grant: "'rearrange grant'; the replication refusals' why list applies too" why: - "no from drives" - "to drives" - "bad dates" - message: "A rearrange grant does not allow a replication" - message: "A replication grant does not allow a rearrangement" - message: "Not a rearrange grant" destinations: manual: "10-api-peer.md#destinations-grant" usedBy: - "replica.destinations" - "replica.spread.dates" - "replica.spread.files" - "replica.spread.begin" - "replica.files" - "replica.put" - "replica.end" - "placement" wire: "same envelope as replication; in a placement file: Destinations {Payload, Sig}" signedBytes: "the payload bytes exactly as sent" payloadFields: v: "int, must be 1" kind: "\"spacebackup-destinations\"" machine: "the source machine name" targets: "[{pc, dest, plain?, rels?}], at least one: every drive the source's backups go to; plain:true = a phone's Not encrypted drive; rels = a computer's folders on that drive (their places in a date folder), absent: the whole date" keep: "int, optional, at least 1: the backups the source keeps per drive" issued: "ISO 8601 UTC" expires: "ISO 8601 UTC; at most 400 days after issued (a computer signs for 90 days at each run)" algorithm: "ECDSA P-256 with SHA-256" signatureEncoding: "as replication" key: "as replication" expiry: - "expires - issued at most 400 days and > 0; no catch-up time past expires" refusals: - message: "{from} sent {machine}'s destinations grant: a computer hands over only its own" - message: "Not a destinations grant: {grant}" - message: "A {grant} names its primary: an onward copy needs a destinations or a rearrange grant" readTicket: manual: "10-api-peer.md#sharing" usedBy: - "grant" signedBytes: "none on the PC: the ticket is opaque; the PC sends it to POST /account/api/peer-tickets/check" algorithm: "checked online by the account service" key: "the PC's own device token (Authorization) for the check" encoding: "string, as the service issued it" expiry: "the service's expires (1 h); the PC trusts a yes for at most 5 min and never past expires" checks: - "the service's requesterName must equal this connection's peer name" - "sourceName becomes the machine readable on this connection" albumTicket: manual: "10-api-peer.md#album-tickets" usedBy: - "album.*" - "guest channel hello" signedBytes: "none on the PC: opaque; POST /account/api/album-tickets/check" algorithm: "checked online by the account service" key: "the PC's own device token for the check" encoding: "string; on the guest channel at most 200 chars" expiry: "the service's expires; yes cached 5 min; a write naming a drive the cached yes lacks re-asks (at most every 10 s per ticket)" answer: "requesterName, requesterEmail, album, albumName, ownerEmail, access (owner, member, member-add, relay, guest), destinations[{deviceName, dest, label}], expires, deleted, requesterKey (guest), member (member's relay ticket), memberDevices" refusals: - message: "The account service did not confirm this album for this device (not its owner or a member it is shared with, or the ticket expired)" - message: "An album request needs a ticket from the account service" - message: "This ticket is for another album" - message: "A guest's ticket serves only a guest's own connection" - message: "A relay ticket serves only the transfer jobs of its own PC" - message: "The album was deleted" - message: "A member's relay ticket serves only the transfer of that member's adds and removes" - message: "This album ticket was given to {requester}, not to {peer}" - message: "Only the album's owner can change it (the owner has not let members add)" - message: "Only the album's owner can change it" - message: "{drive} is not one of this album's drives" ops: caps: manual: "10-api-peer.md#op-caps" cap: "none" channel: "company" sender: "any device" request: "no fields" response: ok: "true" putsmall: "bool" dated: "bool" jobs: "bool" fanout: "bool" resume: "bool" e2e: "bool" fetch: "bool" placement: "bool" gdrive: "int" read: "int" album: "int" replicate: "int" rearrange: "int" spread: "int: 1 = onward copies: replica.spread.dates, replica.spread.begin, replica.destinations (docs/replication.md#onward-copies, 2026-11-06); 2 = digests in replica.spread.dates, replica.spread.files (2026-11-07)" remove: "int" move: "int: 1 = move (iOS request #49)" partial: "int: 1 = unmark takes partial:true; prepare and dates answer partial" changes: "int: 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 (#70; iOS docs/requests.md #70); 2 = also changes.watch and changes.push (PC to PC); 3 = move and remove take ids (encrypted dates recorded as moved/gone); 0 on a PC that keeps no change log" upload: "int: 1 = takes uploads through the relay's HTTPS door (PUT /v1/upload, iOS request #77; docs/relay-upload.md) and mark {uploads: true}" photoreq: "int: 1 = photos.requests (what the Photos window asks the calling phone to do with its own items); 2 = also archive / unarchive" links: "int: 1 = serves public links to the account service on the guest channel (link.list, link.read; docs/public-links.md); 2 = also a whole album's link (link.album, link.read by key; iOS request #47); 3 = link.read {jpeg: true}: a HEIC photo as JPEG (iOS request #48)" vision: "int: 1 = a Space Vision host (a phone's newest complete plain date on this PC: vision.status, vision.search, vision.get)" analyze: "int: the same as vision (the phone's name for it, iOS request #40)" vision-worker: "int: 1 = this PC runs a Space Vision worker (a usable NVIDIA GPU, runtime and models installed, not paused)" vision-lease: "int: 1 = workers on other PCs may lease this host's plain dates (vision.challenge, vision.hello, vision.pending, vision.lease, vision.unlease, vision.put; docs/space-vision.md#phase2)" vision-coverage: "int: 1 = vision.coverage: per phone of this PC's plain backups the items analysed at the current description version, at an older one, never, failed, and the oldest unanalysed item's age (counts only; any PC of the company; docs/space-vision.md#coverage, 0.16.30); 1 on every PC with Space Vision" vision-audit: "int: 1 = vision.audit: the processing watchdog's stages per phone of this PC's plain copies (counts and causes only; any PC of the company; docs/space-vision.md#watchdog, 0.16.159); 1 on every PC with Space Vision" vision-progress: "int: 1 = vision.progress: per kind (photos, videos, transcripts, faces in photos, faces in videos) done of total, the rate over the last hour and the time left, this PC's worker (state, what it works on now), the workers seen here, the last runs (docs/space-vision.md#progress, 0.16.80); 1 on every PC with Space Vision" vision-fleet: "int: 1 = the fleet (docs/space-vision.md#fleet, 0.16.86): vision.viewing, part leases (vision.hello parts/card, vision.pending's part/held, vision.lease's part) and the placement; vision-progress 3 = the workers view's fields (worker cards, perMin, today, owner; the sum's fleet)" faces: "int: 1 = faces.*: the faces of this PC's Space Vision (people, names, merge/split/move/reject/hide/delete, thumbs) for the phone (its device's owner) and proved PCs (docs/faces.md#peer); 1 on every PC with Space Vision faces" vision-select: "int: 1 = vision.select / vision.job: a worker judges the phone's candidates against the user's words (iOS request #51; docs/space-vision.md#select); 2 = the host's fast pass over the stored vectors, vision.job answers partial and timings (iOS request #60; docs/space-vision.md#select-fast); 2 when vision is 1" vision-search: "int: 1 = vision.search with query: the machine's analysed items ranked by the words and the stored vectors, from the host's index alone (iOS request #60); 1 when vision is 1" search-index: "int: 1 = search.index: a device's search index on this PC in one answer (its newest plain backup's month files with this PC's analysis merged in; docs/space-vision.md#search-index, 2026-11-06); 1 on every PC with Space Vision" vision-embed: "int: 1 = vision.embed: this PC makes a query's vector (the Space Vision runtime and SigLIP 2 are installed; no graphics card needed)" assistant-job: "int: 1 = assistant.job / assistant.job.status: this PC finishes a phone's assistant request (candidates, selection, album, filter, share, the alert; iOS request #61; docs/assistant-jobs.md); 2 = the reading's shared albums searched, no consent refusal (iOS request #64); 3 = assistant.job.cancel (iOS request #73); 4 = another computer of the phone's member sends the job for the phone under the job ticket it took for it (the desktop window, 2026-11-05); 4 when vision is 1 and it keeps albums" audit: "int: 1 = audit.local and audit.fix (the backup audit, docs/audit.md): what this PC's drives hold for the company report, and the onward copies a repair asks for; 0 or absent: an older PC (asked with replica.spread.dates: presence only)" multidrive: "int: 1 = prepare and link take drives:[id,...] instead of dest, done for each drive at once and answered {ok:true, drives:{id: that drive's answer, or {ok:false, error}}} in the request's order (at most 64 drives; maclaude: an iPhone with 21 drives over the relay, 2026-11-07); 2 = list, mkdir, status and mark too (iOS #160, mars2): list answers frames {ok:true, drives:{id:{ok, files, dirs}}, done}, the last naming every drive" video-copy: "int: 1 = video.copy and video.copy.read: a phone's H.264 8-bit SDR copy of a video it cannot decode (the TV copy's recipe, made on request; docs/sharing.md, A phone's H.264 copy of a video); 1 when this PC has ffmpeg" geo: "int: 1 = the geography (docs/geography.md, 2026-11-08): geo.resolve, geo.places, geo.names, the geo filter of vision.search and assistant.job, and each hit's compact geo; 1 on every PC of this build (the offline data ships in it)" example: request: | {"op":"caps"} response: | {"ok":true,"putsmall":true,"dated":true,"jobs":true,"fanout":true,"resume":true,"e2e":true,"fetch":true,"placement":true,"gdrive":1,"read":3,"album":15,"replicate":2,"rearrange":3,"forms":1,"spread":2,"photoreq":0,"resend":1,"arrival":1,"remove":1,"move":1,"partial":1,"changes":0,"upload":1,"audit":1,"work-mark":0,"multidrive":2,"links":3,"vision":0,"analyze":0,"vision-worker":0,"vision-lease":0,"vision-coverage":0,"vision-audit":0,"vision-progress":0,"vision-fleet":0,"faces":0,"vision-select":0,"vision-search":0,"search-index":0,"vision-embed":0,"assistant-job":0,"video-copy":0,"geo":1} status: manual: "10-api-peer.md#op-status" cap: "none" channel: "company" sender: "any device" request: dest: "string" drives: "[string], optional (multidrive 2): several destinations instead of dest, at most 64; the answer is then {ok:true, drives:{id: this answer for that drive}} (unknown or offline: online:false)" response: online: "bool: known destination whose folder exists" free: "int bytes; 0 when offline" keep: "int: this PC's max number of backups, which it also keeps over the caller's dates on its drives; 0: none set" notes: - "an unknown dest is online:false, not an error" example: request: | {"op":"status","dest":"3F9A1C07B2E4"} response: | {"ok":true,"online":true,"free":1873415372800,"keep":10} prepare: manual: "10-api-peer.md#op-prepare" cap: "dated (recheck: fanout; incomplete: resume; busy: jobs)" channel: "company" sender: "the backing-up device; its own folder" request: dest: "string" drives: "[string], optional (multidrive 1): several destinations instead of dest, at most 64; the answer is then {ok:true, drives:{id: this answer for that drive, or {ok:false, error}}}" cf: "bool, default true" today: "yyyy-MM-dd, the run's date" response: dates: "[yyyy-MM-dd], the caller's date folders there" recheck: "bool: list that destination instead of trusting the index (fan-out failed or queued)" incomplete: "[yyyy-MM-dd] holding the incomplete marker" partial: "[yyyy-MM-dd] closed after a stopped run (partial 1); complete for every reader, not in incomplete" resend: "[{id, op:'resend', date, rel, size, cause, requested, hash?, item?}], only when there are some (resend 1): the caller's files on that drive damaged with no good copy anywhere; the run copies each again even when it looks unchanged and answers with resend.answer (docs/resend.md)" errors: - message: "busy with other PCs' backups, retry in {retry} s" shape: "{ok:false, busy:true, retry, error}; retry = 30 + random 0..30" - message: "Unknown destination {dest}" - message: "Destination offline: {path}" - message: "Missing date" - message: "Invalid date folder: {date}" notes: - "takes a job slot (2 per PC); the same peer instance is always let in again; held until release or 60 s after its last connection closed" - "with drives (multidrive 1) one job slot covers them all (busy is the whole request's answer); the drives are prepared at once; an unknown or offline drive is {ok:false, error} in drives, the others answered" example: request: | {"op":"prepare","dest":"3F9A1C07B2E4","cf":true,"today":"2026-10-17"} response: | {"ok":true,"dates":["2026-10-14","2026-10-15","2026-10-16"],"recheck":false,"incomplete":["2026-10-16"]} release: manual: "10-api-peer.md#op-release" cap: "jobs" channel: "company" sender: "the backing-up device" request: "no fields" response: ok: "true" example: request: | {"op":"release"} response: | {"ok":true} list: manual: "10-api-peer.md#op-list" cap: "dated; machine: read 1 (another machine: read 2 and a grant)" channel: "company" sender: "any device; own folder, or another machine under a grant" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string, '' for the date folder" machine: "string, optional, default the caller" drives: "[string], optional (multidrive 2): several destinations instead of dest, at most 64; each frame is then {ok:true, drives:{id:{ok:true, files, dirs}}, done}" response: files: "[[rel, size, mtimeTicks]], relative to rel, recursive" dirs: "[rel]" done: "bool; false on all but the last frame" streaming: "one or more answer frames, each about 1 MB of JSON at most (estimated rel.Length*6+48 per file)" notes: - "with drives (multidrive 2) each drive is listed at once; a frame holds only the drives with entries in it, the caller appends each drive's files and dirs across frames; the last frame (done:true) names every drive in the request's order: the rest of its entries, or {ok:false, error} (unknown, offline); a refused read is the whole request's refusal" errors: - message: "Missing path" - message: "Unknown destination {dest}" - message: "Destination offline: {path}" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" shape: "{ok:false, refused:true, needsGrant:true, error}" example: request: | {"op":"list","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-16","rel":"C\\Users\\anna\\Documents"} response: | {"ok":true,"files":[["Budget 2026.xlsx",48213,639277705310000000]],"dirs":[],"done":true} stat: manual: "10-api-peer.md#op-stat" cap: "dated; machine as list" channel: "company" sender: "any device; own folder or a grant" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rels: "[rel]" machine: "string, optional" response: files: "[[size, mtimeTicks] or null], in the order of rels" errors: - message: "Missing paths" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" example: request: | {"op":"stat","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-16","rels":["C\\a.txt","C\\gone.txt"]} response: | {"ok":true,"files":[[48213,639277705310000000],null]} mkdir: manual: "10-api-peer.md#op-mkdir" cap: "dated" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string" drives: "[string], optional (multidrive 2): several destinations instead of dest, at most 64; the answer is then {ok:true, drives:{id:{ok:true} or {ok:false, error}}}" response: ok: "true" errors: - message: "Missing path" - message: "Missing date" - message: "Missing drives" shape: "drives:[] (multidrive 2)" - message: "Too many drives (at most {max})" shape: "more than 64 drives (multidrive 2)" rmdir: manual: "10-api-peer.md#op-mkdir" cap: "dated" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string; removed only when empty" response: ok: "true" errors: - message: "Missing path" delpart: manual: "10-api-peer.md#op-mkdir" cap: "dated" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string; its .~sbpart temp file is deleted" response: ok: "true" errors: - message: "Missing path" delete: manual: "10-api-peer.md#op-delete" cap: "dated" channel: "company" sender: "the backing-up device; own folder; allowed in a finished date (manifest updated)" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string" dir: "bool, default false" response: ok: "true" errors: - message: "Missing path" example: request: | {"op":"delete","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-17","rel":"C\\Users\\anna\\Temp","dir":true} response: | {"ok":true} vision.status: manual: "10-api-peer.md#op-vision-status" cap: "vision 1" channel: "company" sender: "a device about its own machine, or another machine under a grant (as read)" request: machine: "optional; default the caller's own" response: machine: "string" pc: "this PC's name" items: "int: the machine's items on this PC's plain destinations (newest complete date of each)" analysed: "int: done by a GPU worker" colored: "int: with the hosts' colours" videos: "int: videos done by a worker" transcribed: "int: of those, with a transcript" encryptedDates: "int: dates kept encrypted (never analysed)" waiting: "null | signed-out | no-worker (no consent since 0.14.0: every member's plain backups are analysed)" lastRun: "{at, by, items} | null" worker: "{active, why, machine, profile, gpu, running, working?, remoteStored?, remoteLastPut?}" pending: "int: items still waiting for a worker (phase 2)" workers: "[{machine, active, items, lastPut, seen, leases:[{dest, machine, date, expires}]}]: workers on other PCs working here (phase 2); items: the machine's done records it put here (from the stored records, kept across a host restart; 0.13.1)" doneBy: "{worker: int}: the machine's done items per worker, this PC's own included (0.13.1)" errors: - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" shape: "refused, needsGrant" example: request: | {"op":"vision.status","machine":"Vlads-iPhone"} response: | {"ok":true,"machine":"Vlads-iPhone","pc":"MARS-001","items":24031,"analysed":12340,"colored":24031,"videos":512,"transcribed":210,"encryptedDates":17,"waiting":null,"lastRun":{"at":"2026-10-19T21:04:00Z","by":"MARS-001","items":412},"worker":{"active":true,"why":null,"machine":"MARS-001","profile":"8g","gpu":"NVIDIA GeForce RTX 2080 SUPER 8 GB","running":false}} vision.coverage: manual: "10-api-peer.md#op-vision-coverage" cap: "vision-coverage 1" channel: "company" sender: "any device of the company (counts only: no file name)" request: machine: "optional: one phone" months: "bool, optional (default true): the per-month split" fresh: "bool, optional: count now and wait (else the PC's snapshot, at most 5 minutes old; 0.16.169)" response: pc: "this PC's name" version: "its app version" dv: "its description version" at: "when counted (UTC): the snapshot's time" cachedS: "int: the snapshot's age in seconds (0: counted for this request; 0.16.169)" refreshing: "bool, optional: the snapshot is older than 60 s (or a put came since) and a refresh runs now" columns: "[items, current, older, never, failed]: the months' rows" worker: "{active, why, ownFirst}: this PC's own worker; ownFirst: it comes first now (it runs or delivered in the last 6 h)" workers: "as vision.status's: workers on other PCs seen in the last 15 minutes" lastWork: "the last lease, put or local delivery here (UTC) | null" machines: "[{machine, items, current, older, never, failed, failedDue, videos, nextRetry, coverage (percent), plainDate, encryptedDates, encryptedNewer, waiting, leased, oldest {landed, hours, created, state}?, oldestWaitingHours?, exts {ext: n}?, months {yyyy-MM: [items, current, older, never, failed]}?, encryptedDate?, encryptedKeys?, encryptedItems?, encryptedOnlyItems?, encryptedMatch? (keys|count), plainKeys?, encryptedUnmatched? [hex], encryptedUnmatchedMore?}]: per phone with backups here (only encrypted: items 0); the encrypted date's key list holds two keys an item" example: request: | {"op":"vision.coverage","months":false} response: | {"ok":true,"pc":"CHIA2","version":"0.16.30","dv":5,"at":"2026-10-30T23:40:00Z","cachedS":12,"columns":["items","current","older","never","failed"],"worker":{"active":false,"why":"no graphics card with 8 GB or more","ownFirst":false},"workers":[],"lastWork":"2026-10-30T23:31:12Z","machines":[{"machine":"Vlads-iPhone","items":348,"current":340,"older":6,"never":2,"failed":0,"failedDue":0,"videos":22,"nextRetry":null,"coverage":97.7,"plainDate":"2026-10-30","encryptedDates":2,"encryptedNewer":0,"waiting":null,"leased":false,"oldest":{"landed":"2026-10-30T00:00:00Z","hours":23.7,"created":"2026-10-29T18:02:11Z","state":"never"},"oldestWaitingHours":23.7}]} vision.audit: manual: "10-api-peer.md#op-vision-audit" cap: "vision-audit 1" channel: "company" sender: "any device of the company (counts and causes only: no file name)" request: machine: "optional: one phone (always audited afresh)" fix: "bool, optional: queue again what the PCs make and is missing, broken or stale (an audit afresh)" wait: "int, optional (default 150, 1-170): seconds the caller waits for the audit" response: pc: "this PC's name" version: "its app version" dv: "its description version" at: "when audited (UTC)" cached: "true: the last report (fresh for 30 minutes, no fix asked)" running: "true: the audit did not end within wait; lastAt is the last report's time and the report is the next caller's" stages: "[thumb, preview, video, exif, geo, caption, vector, faces, search]" machines: "[{machine, items, absent, needsUser, indexDate, stages {stage: {ok, na, waiting, bad, requeued, retrying, failed, healed, gaveUp, causes {cause: n}}}}]: per phone with plain copies here" example: request: | {"op":"vision.audit","fix":false,"wait":150} response: | {"ok":true,"pc":"CHIA2","version":"0.16.159","running":true,"lastAt":"2026-11-08T18:00:00Z"} vision.covered: manual: "10-api-peer.md#op-vision-covered" cap: "vision-coverage 1 (an older PC answers Unknown request)" channel: "company" sender: "any device of the company (vision coverage)" request: machine: "the phone" keys: "[hex]: encrypted keys of that phone another PC's plain copies do not hold" response: pc: "this PC's name" covered: "[hex]: those an item of this PC's plain copies of the phone has (HMAC'd with each matching key this PC holds)" example: request: | {"op":"vision.covered","machine":"Vlads-iPhone","keys":["3f1c…"]} response: | {"ok":true,"pc":"CHIA2","covered":["3f1c…"]} vision.progress: manual: "10-api-peer.md#op-vision-progress" cap: "vision-progress 1" channel: "company" sender: "with all: any device of the company (as vision.coverage); without: as vision.status (the caller's own phone, another under a grant)" request: all: "bool, optional: every phone on this PC (or machine), to any device of the company" machine: "optional: one phone" response: v: "1" pc: "this PC's name" version: "its app version" machine: "the phone counted, null: every phone here" at: "when answered (UTC)" kinds: "{photos, videos, transcripts, photoFaces, videoFaces}: each {done, total, failed, lastHour, today, perMin, etaMin} (etaMin minutes: 0 nothing left, null no rate in the last hour; none for transcripts), a faces kind {off: true} while Recognize faces is off" worker: "this PC's own worker {pc, state: working|idle|paused|busy|off|no-gpu|not-installed, why, rule, profile, profileReason, gpu, gpus, version, faces, now {task: analyse|describe|redescribe|faces|select, kind: photo|video, n, of, since, host?, machine?, date?} | null}" workers: "[{pc, state: working|idle, seen, lastPut, leases [{machine, date}], profile?, gpu?, version?, now?}]: the workers of other PCs seen here in the last 15 minutes" runs: "[{started, at, by, host, machine, dates, photos, videos, transcripts, faces, failed, errors}]: the last 10 runs delivered here, newest first" example: request: | {"op":"vision.progress","all":true} response: | {"ok":true,"v":1,"pc":"CHIA2","version":"0.16.80","machine":null,"at":"2026-11-03T14:02:31Z","kinds":{"photos":{"done":23950,"total":24031,"failed":12,"lastHour":310,"today":2210,"perMin":5.17,"etaMin":13.3},"videos":{"done":480,"total":512,"failed":1,"lastHour":20,"today":96,"perMin":0.33,"etaMin":93},"transcripts":{"done":210,"total":480,"failed":0,"lastHour":9,"today":40,"perMin":0.15},"photoFaces":{"off":true},"videoFaces":{"off":true}},"worker":{"pc":"CHIA2","state":"no-gpu","why":"no graphics card with 8 GB or more","rule":null,"profile":null,"profileReason":"no usable graphics card","gpu":null,"gpus":0,"version":"0.16.80","faces":false,"now":null},"workers":[{"pc":"MARS2","state":"working","seen":"2026-11-03T14:01:10Z","lastPut":"2026-11-03T13:58:02Z","leases":[{"machine":"Vlads-iPhone","date":"2026-11-02"}],"profile":"16g","gpu":"NVIDIA GeForce RTX 3090 24 GB","version":"0.16.80","now":{"task":"describe","kind":"photo","n":96,"of":300,"since":"2026-11-03T14:00:58Z","host":"CHIA2","machine":"Vlads-iPhone","date":"2026-11-02"}}],"runs":[{"started":"2026-11-03T13:31:12Z","at":"2026-11-03T13:58:02Z","by":"MARS2","host":"CHIA2","machine":"Vlads-iPhone","dates":["2026-11-02"],"photos":290,"videos":8,"transcripts":3,"faces":298,"failed":2,"errors":["cannot identify image file"]}]} vision.viewing: manual: "10-api-peer.md#op-vision-viewing" cap: "vision-fleet 1" channel: "company" sender: "any device of the company (an app showing photos)" request: machine: "the phone whose items are shown" date: "optional: its date" dates: "optional: up to 31 dates" rels: "optional: up to 2,000 thumbnail or file paths in the date: these items first for every worker for 10 minutes" response: dates: "how many dates were noted" items: "how many items" example: request: | {"op":"vision.viewing","machine":"Vlads-iPhone","date":"2026-11-02","rels":["Thumbs\\2026\\10\\IMG_1.JPG.jpg"]} response: | {"ok":true,"dates":1,"items":1} vision.search: manual: "10-api-peer.md#op-vision-search" cap: "vision 1" channel: "company" sender: "as vision.status" request: q: "string, optional with color: the Photos viewer's search words over the PCs' fields of the month index" query: "string, up to 500 characters (cap vision-search 1; instead of q): the semantic search, see the response's second form" max: "with query: 1..1000, default 50 (a place alone without limit: its page size)" color: "optional: red, orange, yellow, green, teal, blue, purple, pink, brown, black, gray (grey), white; share >= 0.15" machine: "optional" dest: "optional: one destination" kind: "photo | video | any, optional" from: "yyyy-MM-dd, optional" to: "yyyy-MM-dd, optional" limit: "with q or color: 1..200, default 50; a place alone (geo with no q, color or query, both forms): the page size, 1..5000, default 1000 (docs/geography.md section 8 item 12)" after: "optional, a place alone (cap geo 1): the next of the page before (the last hit's id, its asset when it has no id); absent: the first page" geo: "optional (cap geo 1): the geographic filter of docs/geography.md section 2, {place: {level, id, name}, region, continent, water: {kind, name} (an ocean holds its seas: kind ocean, name Atlantic matches the Caribbean too), lat: {min, max}, lon: {min, max}, hemi}, every key given must hold; with q or query only the items in it; alone (no q, color or query) every item in it, newest first then by id (match / why: place), a page at a time (limit, after)" response: vector: "with q: false (full text only); with query: true when the query's vector was made (else the word rule alone, why says why not)" hits: "with q: [{id: content hash, asset, kind, dest, date, rel, thumb, created, match: labels|text|description|transcript|frames|color|index, t0?, snippet?, lang?, description, color: {name}, geo}]; with query: [{id: content hash, asset, date, kind, score 0..1, why, description, geo}] best first, at most max (every analysed item ranked; score >= 0.5 is what vision.select would select)" total: "int: with q the hits; with query the machine's analysed items ranked; a place alone every item in it (all the pages)" next: "a place alone: the after of the page after this one, null on the last page" ms: "with query: int, the host's time" why: "with query, when vector is false: why there was no vector (no encoder, …)" errors: - message: "unknown colour" - message: "Nothing to search for" - message: "Missing query" - message: "after: {id} is not in this listing (list again from the start)" example: request: | {"op":"vision.search","q":"happy birthday","machine":"Vlads-iPhone","limit":20} response: | {"ok":true,"vector":false,"hits":[{"id":"9f0c1d2e3a4b5c6d7e8f90a1b2c3d4e5","asset":"a71e0c2b9d4f3e10","kind":"video","dest":"3F9A1C07B2E4","date":"2026-10-18","rel":"Photos\\2026\\09\\IMG_0907.MOV","thumb":"Thumbs\\2026\\09\\IMG_0907.MOV.jpg","created":"2026-09-07T17:02:11Z","match":"transcript","description":"A birthday party with a cake.","color":{"name":"brown"},"snippet":"…we all sing happy birthday to you…","lang":"en"}],"total":1} geo.resolve: manual: "10-api-peer.md#op-geo-resolve" cap: "geo 1" channel: "company" sender: "any device; with machine, as read (the caller's own machine, another under a grant or ticket)" request: words: "string: what was said (\"Masha in Vegas\", \"north of the Arctic Circle\", \"Скандинавия\")" langs: "optional: [\"ru\",\"en\"] or \"ru,en\": the label in the first of them (default English)" machine: "optional: the device whose items on this PC order the candidates (none: by population)" ticket: "optional: the reader's ticket for another machine, as vision.search" response: geo: "the filter (docs/geography.md section 2) of the first candidate; null: the words say no geography" label: "string: the filter in words (\"Las Vegas area\", \"Middle East\", \"north of the Arctic Circle\")" matched: "string: the words it took (folded)" candidates: "[{geo, label, count}]: every reading of an ambiguous name (\"Paris\": France's, Texas's), the most of the machine's items first; count 0 without machine" example: request: | {"op":"geo.resolve","words":"Masha in Vegas","langs":["en"],"machine":"Vlads-iPhone"} response: | {"geo":{"place":{"level":"metro","id":"geonames:5506956","name":"Las Vegas"}},"label":"Las Vegas area","matched":"vegas","candidates":[{"geo":{"place":{"level":"metro","id":"geonames:5506956","name":"Las Vegas"}},"label":"Las Vegas area","count":212}],"ok":true} geo.places: manual: "10-api-peer.md#op-geo-places" cap: "geo 1" channel: "company" sender: "as read: the caller's own machine, another under a grant or ticket" request: level: "locality | metro | county | state | country (default country)" machine: "the device whose items on this PC are counted" geo: "optional: within a filter (a country's states)" langs: "optional: the names in the first of them where the data has it" ticket: "optional, as vision.search" response: level: "string" places: "[{id, name, count}], the most first: id US, US-NV, US-NV-003 or geonames:; each item counted once" errors: - message: "geo.places needs machine (whose items are counted)" example: request: | {"op":"geo.places","level":"country","machine":"Vlads-iPhone","langs":"ru"} response: | {"ok":true,"level":"country","places":[{"id":"US","name":"США","count":1830},{"id":"CA","name":"Канада","count":412}]} geo.names: manual: "10-api-peer.md#op-geo-names" cap: "geo 1" channel: "company" sender: "any device (no machine: the PC's place data, no one's items)" request: ids: "[\"geonames:5506956\",\"US-NV\"] or \"geonames:5506956,US-NV\" (at most 5000): a town or metro (geonames:), county (US-NV-003), state (US-NV, CA-ON), country (US), continent (NA), region (middle-east); country:, continent:, region:, state:, county:, metro: or locality: before one says its kind (AF, AS, NA, SA alone are continents: country:NA is Namibia)" langs: "optional: [\"ru\",\"en\"] or \"ru,en\": each name in the first of them that has one, else English" response: names: "{id: name}: keyed by the ids as asked; an id that names nothing is left out" example: request: | {"op":"geo.names","ids":["geonames:5506956","US-NV","US","NA","middle-east"],"langs":["ru","en"]} response: | {"ok":true,"names":{"geonames:5506956":"Лас-Вегас","US-NV":"Невада","US":"США","NA":"Северная Америка","middle-east":"Ближний Восток"}} search.index: manual: "10-api-peer.md#op-search-index" cap: "search-index 1" channel: "company" sender: "as read: the caller's own machine, another under a grant (or ticket) on this connection" request: machine: "optional: the device whose index (default: the caller)" ticket: "optional: the reader's ticket for another machine, as vision.search" have: "optional: the version the caller holds; the answer then carries nothing when it is still the current one" response: version: "string: what the index was made from; the same version, the same items" date: "yyyy-MM-dd: the backup date it was made from (the machine's newest complete plain date on this PC)" months: "int: the month files packed in the data frames; each located entry carries geo (cap geo 1, docs/geography.md section 8 item 13): the PCs' whole record, a superset of the compact geo the hits carry (same keys, same values) plus lat, lon, cell, localityId, subLocality, countyCode, state, country; only in this answer, never in the month files on the drives" size: "int: the bytes of the data frames: gzip of [int32 count][int32 length, month JSON]... (little-endian), then {ok, done, sent}" same: "true when have is the current version: no data frames follow" ms: "int: the host's time" none: "true (with ok false): no complete plain backup of the machine on this PC" errors: - message: "No plain backup of {machine} here" example: request: | {"op":"search.index","machine":"Vlads-iPhone","have":"3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"version":"3f9a1c07b2e4d5c6a7b8c9d0","date":"2026-11-06","same":true,"ms":1} vision.get: manual: "10-api-peer.md#op-vision-get" cap: "vision 1" channel: "company" sender: "as vision.status" request: machine: "optional" asset: "the month index id, or id: the content hash, or rel: the main file" segFrom: "int, default 0" segCount: "1..500, default 500" response: state: "done | failed | pending" labels: "as the index" description: "one line" long: "the 2-4 sentence description" ocr: "the full text read in it" transcript: "[{t0, t1, lang, text}] (a page of segTotal)" segTotal: "int" errors: - message: "not found" example: request: | {"op":"vision.get","machine":"Vlads-iPhone","asset":"a71e0c2b9d4f3e10","segFrom":0,"segCount":2} response: | {"ok":true,"machine":"Vlads-iPhone","id":"9f0c1d2e3a4b5c6d7e8f90a1b2c3d4e5","asset":"a71e0c2b9d4f3e10","date":"2026-10-18","kind":"video","state":"done","description":"A birthday party with a cake.","transcript":[{"t0":0,"t1":4.2,"lang":"en","text":"and now we all sing"},{"t0":4.2,"t1":9,"lang":"en","text":"happy birthday to you"}],"segTotal":2} vision.challenge: manual: "10-api-peer.md#op-vision-challenge" cap: "vision-lease 1" channel: "company" sender: "a Space Vision worker PC (before vision.hello)" request: "nothing" response: nonce: "64 hex, single use, bound to this connection" expires: "ISO 8601 UTC, 60 s" example: request: | {"op":"vision.challenge"} response: | {"ok":true,"nonce":"5c1e0f9a2b7d4c31a6e2f90d14b7c3a85c1e0f9a2b7d4c31a6e2f90d14b7c3a8","expires":"2026-10-21T14:03:31Z"} vision.hello: manual: "10-api-peer.md#op-vision-hello" cap: "vision-lease 1" channel: "company" sender: "a Space Vision worker PC" request: nonce: "the nonce of vision.challenge" dv: "int, optional (0.14.1): the worker's description version; none (0.14.0 and older): its announced app version's, 0.14.0 on 3, 0.13.x 2, unknown 1 (items never analysed only)" version: "string, optional (0.14.2): the worker's app version (none: the one its peer announcement carries)" fp: "string, optional (0.14.2): 8 hex, the worker script's fingerprint (SHA-256 over spacevision.py then color.py); with version, its build: a failed item is offered once more to each newer build (docs/space-vision.md#retry-failed)" sig: "base64 ECDSA P-256 / SHA-256 by the worker's device key over UTF-8 \"sv-worker\\n\\n\\n\"" response: worker: "the proved worker (the connection's peer name)" host: "this PC" dv: "int (0.14.1): the host's description version (an item done with an older one needs a worker of at least it)" errors: - message: "Ask vision.challenge first (the nonce is single use, 60 s)" shape: "refused" - message: "Not signed by {worker}'s device key" shape: "refused" example: request: | {"op":"vision.hello","nonce":"5c1e0f9a2b7d4c31a6e2f90d14b7c3a85c1e0f9a2b7d4c31a6e2f90d14b7c3a8","dv":4,"version":"0.14.2","fp":"62b67467","sig":""} response: | {"ok":true,"worker":"MARS2","host":"CHIA2","dv":3} vision.pending: manual: "10-api-peer.md#op-vision-pending" cap: "vision-lease 1" channel: "company" sender: "a worker after vision.hello" request: dest: "optional: one destination" limit: "1..5000 items, default 2000" response: dates: "[{dest, machine, date, cf, items:[{id, kind, rel, thumb, size, created, why, asset}]}], newest first, photos before videos; only items the worker's dv can do, no date it is backed off from (0.14.1); a failed item once more for a newer build (0.14.2, docs/space-vision.md#retry-failed)" total: "int" own: "true: this host's own worker does its backups (nothing offered)" waiting: "{machine: signed-out} while the host is not signed in (a host before 0.14.0 may say consent)" waitingDates: "{machine: int}, with waiting: how many plain dates of each waiting machine (since 2026-10-21; absent from older hosts)" errors: - message: "Say vision.hello first (a worker proves it is a device of this company)" shape: "refused" - message: "{host} is busy with a backup" shape: "busy, retry" example: request: | {"op":"vision.pending","limit":300} response: | {"ok":true,"dates":[{"dest":"3F9A1C07B2E4","machine":"Vlads-iPhone","date":"2026-10-20","cf":true,"items":[{"id":"9f0c1d2e3a4b5c6d7e8f90a1b2c3d4e5","kind":"photo","rel":"Photos\\2026\\10\\IMG_1234.HEIC","thumb":"Thumbs\\2026\\10\\IMG_1234.HEIC.jpg","size":2811034,"created":"2026-10-13T18:02:11Z","why":"new","asset":{"id":"a71e0c2b9d4f3e10","files":["IMG_1234.HEIC"],"kind":"photo","thumb":"IMG_1234.HEIC.jpg"}}]}],"total":1} vision.lease: manual: "10-api-peer.md#op-vision-lease" cap: "vision-lease 1" channel: "company" sender: "a worker after vision.hello" request: dest: "destination id" machine: "the phone" date: "yyyy-MM-dd: its newest complete plain date here" ttl: "seconds, 60..1800, default 600" lease: "null for a new lease; the lease id to renew" response: lease: "32 hex" expires: "ISO 8601 UTC" errors: - message: "{worker} works on it" shape: "held, by, expires" - message: "{host} analyses its own backups (its own worker comes first)" shape: "own" - message: "{worker} may not analyse {machine}'s backups ({why})" shape: "refused" - message: "The lease lapsed" shape: "lost" - message: "{machine} {date} holds nothing a worker of description version {dv} can do (it needs {DV}: update {worker})" shape: "older" - message: "{worker} gave {machine} {date} back with nothing done; not again before {time}" shape: "backoff, retry" example: request: | {"op":"vision.lease","dest":"3F9A1C07B2E4","machine":"Vlads-iPhone","date":"2026-10-20","ttl":600,"lease":null} response: | {"ok":true,"lease":"b41e0c2b9d4f3e10a71e0c2b9d4f3e10","expires":"2026-10-21T14:10:00Z"} vision.unlease: manual: "10-api-peer.md#op-vision-unlease" cap: "vision-lease 1" channel: "company" sender: "the lease's worker" request: dest: "destination id" machine: "the phone" date: "yyyy-MM-dd" lease: "the lease id" response: "{ok: true}" example: request: | {"op":"vision.unlease","dest":"3F9A1C07B2E4","machine":"Vlads-iPhone","date":"2026-10-20","lease":"b41e0c2b9d4f3e10a71e0c2b9d4f3e10"} response: | {"ok":true} vision.put: manual: "10-api-peer.md#op-vision-put" cap: "vision-lease 1" channel: "company" sender: "the lease's worker" request: body: "a JSON text: {kind: sv-put, host, dest, machine, date, lease, ts, records: [at most 64 spacevision.py export records]}" sig: "base64 ECDSA P-256 / SHA-256 by the worker's device key over the body's UTF-8 bytes" response: stored: "int: records new or changed" gone: "[ids not in that date]" older: "[ids not stored: the host has a newer analysis of them] (0.14.1)" expires: "the lease, renewed" errors: - message: "Not signed by {worker}'s device key" shape: "refused" - message: "The put's time is more than 5 minutes off" shape: "refused" - message: "No lease of this worker on that date (it lapsed?)" shape: "lost" - message: "Records of description version {dv}; this lease needs {target} (update {worker})" shape: "refused, older" example: request: | {"op":"vision.put","body":"{\"kind\":\"sv-put\",\"host\":\"CHIA2\",\"dest\":\"3F9A1C07B2E4\",\"machine\":\"Vlads-iPhone\",\"date\":\"2026-10-20\",\"lease\":\"b41e0c2b9d4f3e10a71e0c2b9d4f3e10\",\"ts\":\"2026-10-21T14:02:31Z\",\"records\":[]}","sig":""} response: | {"ok":true,"stored":0,"gone":[],"older":[],"expires":"2026-10-21T14:12:31Z"} vision.select: manual: "10-api-peer.md#op-vision-select" cap: "vision-select 1" channel: "company" sender: "as vision.status (the phone about its own machine, or another under a grant)" request: machine: "optional; default the caller's own" ticket: "optional: a grant ticket for machine, checked as grant would" query: "the user's words, up to 500 characters" candidates: "[{date: yyyy-MM-dd the backup date holding it, id: the month-index asset id or the content hash}], at most 1000" max: "optional, 1..1000: at most this many selected (default all)" day: "optional, true: only daytime pictures (iOS request #62): the query is judged with ' in daytime' unless it says day, and a candidate whose analysis says night is rejected (why: night)" response: accepted: "true: the job runs detached (vision.job)" job: "string: the job id" of: "int: candidates (an id once)" errors: - message: "Missing query" - message: "Missing candidates" - message: "At most {n} candidates" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" shape: "refused, needsGrant" example: request: | {"op":"vision.select","machine":"Vlads-iPhone","query":"night views of Chicago","candidates":[{"date":"2026-10-18","id":"a71e0c2b9d4f3e10"},{"date":"2026-10-18","id":"b20f8c1d7e6a5b49"}],"max":50} response: | {"ok":true,"accepted":true,"job":"sel_3f9a1c07b2e4d5c6a7b8c9d0","of":2} vision.job: manual: "10-api-peer.md#op-vision-job" cap: "vision-select 1" channel: "company" sender: "the device that asked vision.select" request: job: "the job id of vision.select" response: job: "string" state: "running | done | failed" done: "int: candidates judged or skipped so far" of: "int" reason: "failed only: no-worker | signed-out | gpu-busy | worker-busy | worker-lost | error: ... (the phone falls back to its own rules on any; no consent since 0.14.0)" result: "done only: {selected: [{id, score 0..1, why}] score >= 0.5, best first, at most max; rejected: int; skipped: [{id, date, why: encrypted | not-found | no-picture | vlm-answer | not-analysed-no-worker | not-judged}]}" partial: "running only, cap vision-select 2: {selected: [{id, score, why}] what the host's fast pass selected already (best first, at most max; the final result may add to it, never takes one away), decided: int candidates the fast pass settled}" timings: "cap vision-select 2: ms so far {queue, embed, fast, call, load, pictures, vlm, total} (each when it happened: queue the wait behind another selection, embed the query's vector, fast the host's pass, call the worker's process start, staging, lease and network, load its model load, pictures its SigLIP pass over pictures, vlm the VLM's judging), warm (the worker's VLM was loaded already), vectorBy (who made the query's vector: this PC, a worker PC, cached) or noVector (why none), decidedFast, toWorker (items)" errors: - message: "No such job (jobs are kept 24 hours)" shape: "notFound" example: request: | {"op":"vision.job","job":"sel_3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"job":"sel_3f9a1c07b2e4d5c6a7b8c9d0","state":"done","done":2,"of":2,"result":{"selected":[{"id":"a71e0c2b9d4f3e10","score":1,"why":"lit skyline at night"}],"rejected":1,"skipped":[]}} assistant.job: manual: "10-api-peer.md#op-assistant-job" cap: "assistant-job 1 (2: shared, no consent; 0.14.0)" channel: "company" sender: "the phone, about its own machine (an album) or another under a grant (show only); or (assistant-job 4) another computer of the phone's member, about the phone, with the job ticket it took for it" request: machine: "optional; default the caller's own; another machine only under a grant (as vision.select), and then only action show" ticket: "optional: a grant ticket for machine, checked as grant would" jobTicket: "the phone's job ticket for this PC (POST /account/api/assistant/jobs/ticket {pc, action}; 15 minutes); needed for makeAlbum / shareAlbum and for the done alert: the PC redeems it before answering (POST assistant/jobs/redeem {jobTicket, job}, bound to the job for 24 hours) and presents it with the job to assistant/jobs/album and assistant/jobs/done; held with the job in memory only, never logged" request: "the user's words (up to 2000 characters): kept with the job in memory only, never logged, never sent on" reading: "the phone's reading: {action: show | makeAlbum | shareAlbum (default makeAlbum with a name, else show), name (an album's, up to 100), share: [emails] (or {emails} / one email; shareAlbum needs it), place: {name?, lat, lon, radiusKm (default 10)}, from / to: yyyy-MM-dd (the item's own local day, inclusive), days: [yyyy-MM-dd], timeFrom / timeTo: minutes after local midnight (together, wrapping when from > to), kind: all | photos | videos, content: what the pictures show (up to 500; absent: no selection, every candidate), night: bool, day: bool (in daytime, iOS request #62; not with night), standing: the album's standing filter (as POST albums/{id}/filter), notBackedUp: [item ids the phone holds that no PC has yet], shared: [{album, ticket}] (assistant-job 2, iOS request #64: the albums shared with the user, each with the phone's album ticket; at most 100; also taken next to reading), geo: the geographic filter (cap geo 1, docs/geography.md section 2; with it the planner's bare place is not needed)}" key: "optional, true: a data key (32 bytes) follows as the next data frame (SendSecret), lent for this job only: used only to copy items held in encrypted backups into the album (as album.add), held in memory and dropped when the job ends or fails" response: accepted: "true: the job runs here, detached (assistant.job.status)" job: "string: the job id (aj_...)" errors: - message: "Missing reading (the phone's reading of the request)" - message: "reading: {why}" - message: "An album is made only from the requesting device's own backups" - message: "This PC keeps no albums" - message: "An album needs the phone's job ticket (jobTicket, from assistant/jobs/ticket)" - message: "The account service refused the job ticket: {why}" - message: "The job ticket is for show: it makes no album" - message: "This PC is not signed in to the account service" shape: "reason: signed-out (0.14.0: any job, refused before the ticket is redeemed)" - message: "No worker can judge the phone's pictures now, and none of them is analysed" shape: "reason: no-worker (0.14.0: a job with content, refused before the ticket is redeemed, when no candidate of the phone's nor of a shared album held here is analysed; a job without content runs)" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" shape: "refused, needsGrant" - message: "This PC holds no plain backup of {machine}" shape: "reason: not-here (assistant-job 4: a computer's job for its member's phone, refused before the ticket is redeemed)" example: request: | {"op":"assistant.job","machine":"Vlads-iPhone","request":"Make an album of my night Chicago views and share it with Anna","reading":{"action":"shareAlbum","name":"Night Chicago Views","share":["anna@acme.com"],"place":{"name":"Chicago","lat":41.88,"lon":-87.63,"radiusKm":18.5},"from":"2026-10-15","kind":"photos","content":"view","night":true,"standing":{"words":"Make an album of my night Chicago views","content":"view","night":true,"kind":"photos"},"notBackedUp":["9F1C2D3E"]},"jobTicket":"jt_Qm9yZ2V0LW1lLW5vdA"} response: | {"ok":true,"accepted":true,"job":"aj_3f9a1c07b2e4d5c6a7b8c9d0"} assistant.job.status: manual: "10-api-peer.md#op-assistant-job-status" cap: "assistant-job 1 (2: fromShared, sharedSkipped)" channel: "company" sender: "the device that sent assistant.job" request: job: "the job id of assistant.job" response: job: "string" state: "queued | running | done | failed | cancelled (assistant.job.cancel; one job runs at a time on a PC)" cancelling: "true while a cancelled job finishes the step it is on (state running)" action: "show | makeAlbum | shareAlbum" steps: "[{name: candidates | select | album | add | filter | share | notify, state: waiting | running | done | skipped | failed | cancelled (the step a cancel interrupted), ms?, count?, why?}] in that order; candidates.count: items matching place/days/time/kind/night; select.count: chosen by what they show; add.count: in the album" result: "done (and failed or cancelled after the selection: what the job did so far): {action, found: int, album: {id, name} or null, added: [ids in the album], encrypted: [ids held only in encrypted backups, no key lent], failed: [ids], needsPhone: [ids this PC has no file of, and the reading's notBackedUp], shared: [emails], invited?: true, shareError?: string, filter: bool, ids?: [chosen ids of the phone's own items, newest first] (show only), fromShared?: [{album, name, ids}] (the reading's shared albums: the chosen items of each, cloned into the album when one is made), sharedSkipped?: [{album, why: not on this PC | the ticket's refusal}]}" found: "int: the result's (the phone's and the shared albums' chosen), at the top as well (with album, ids, needsPhone, added, fromShared, sharedSkipped): what the phone reads" why: "failed only: why (the selection's reason: no-worker | signed-out | worker-busy, or the error)" timings: "ms: {queue, candidates, select, album, add, notify, total} (each when it happened)" errors: - message: "No such job (jobs are kept 24 hours)" shape: "notFound" example: request: | {"op":"assistant.job.status","job":"aj_3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"job":"aj_3f9a1c07b2e4d5c6a7b8c9d0","state":"done","action":"shareAlbum","steps":[{"name":"candidates","state":"done","ms":41,"count":5},{"name":"select","state":"done","ms":310,"count":3},{"name":"album","state":"done","ms":220},{"name":"add","state":"done","ms":95,"count":1},{"name":"filter","state":"done"},{"name":"share","state":"done","count":1},{"name":"notify","state":"done","ms":180}],"result":{"action":"shareAlbum","found":3,"album":{"id":"al_x7k2mq9pa4zw3n5c","name":"Night Chicago Views"},"added":["A1B2C3"],"needsPhone":["9F1C2D3E","C4D5E6F7"],"shared":["anna@acme.com"],"filter":true,"encrypted":[],"failed":[]},"timings":{"queue":0,"candidates":41,"select":310,"album":220,"add":95,"notify":180,"total":851}} assistant.job.cancel: manual: "10-api-peer.md#op-assistant-job-cancel" cap: "assistant-job 3" channel: "company" sender: "the device that sent assistant.job (the Assistant's Stop, iOS request #73)" request: job: "the job id of assistant.job" response: job: "string" state: "cancelled (a queued job: over at once; never runs) | running (with cancelling: true: it stops after the step it is on, then cancelled) | done | failed | cancelled (a job already over: answered as it is, not changed)" cancelling: "true while the job finishes its step" notes: - "the job keeps what it did (an album made stays, items added stay, the result so far in assistant.job.status)" - "the steps not run are skipped, the one interrupted cancelled (the selection stops between its vision.select jobs and while it waits for a worker; the album and add steps finish first)" - "notify is skipped: no done alert, no changed push; the lent key is dropped as at any end" errors: - message: "No such job (jobs are kept 24 hours)" shape: "notFound" example: request: | {"op":"assistant.job.cancel","job":"aj_3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"job":"aj_3f9a1c07b2e4d5c6a7b8c9d0","state":"running","cancelling":true} vision.embed: manual: "10-api-peer.md#op-vision-embed" cap: "vision-embed 1" channel: "company" sender: "a host without a text encoder of its own, for vision.select's fast pass and vision.search" request: text: "the query (what can be seen of it), up to 500 characters" response: vec: "base64 of 1152 little-endian float16: SigLIP 2's text vector, unit length" dim: "1152" ms: "int" errors: - message: "Missing text" - message: "No text encoder on {pc}" example: request: | {"op":"vision.embed","text":"night views"} response: | {"ok":true,"vec":"","dim":1152,"ms":171} vision.call: manual: "10-api-peer.md#op-vision-call" cap: "vision-select 1 (of the host that calls)" channel: "company" sender: "a host with a select job (or, 0.14.0, a phone's new backups and no worker of its own), to a worker PC that said vision.hello to it in the last 15 minutes" request: job: "the job id (a selection)" machine: "the machine the job or the new backups are of" analyse: "optional true (0.14.0, iOS request #64): no job; the host's new plain dates of machine: the worker runs one round on that host at once (vision.pending, vision.lease, reads, vision.put)" response: accepted: "true: the worker dials the host back and takes the select lease (with analyse: leases the new dates)" busy: "true (with ok false): its card is not ready, it judges another selection, or (analyse) it is busy, its worker runs, or it has none" reason: "with ok false: worker-busy | signed-out" errors: - message: "Missing job" - message: "busy with another selection" shape: "busy" - message: "{worker} may not analyse {machine}'s backups ({reason})" shape: "reason: signed-out" example: request: | {"op":"vision.call","job":"sel_3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"accepted":true} vision.selectlease: manual: "10-api-peer.md#op-vision-selectlease" cap: "vision-select 1" channel: "company" sender: "a called worker after vision.hello" request: job: "the job id" lease: "null to take it; the lease id to renew (every 30 s)" done: "int, with lease: items judged so far" response: lease: "32 hex" expires: "ISO 8601 UTC (5 minutes)" machine: "taking only: the phone" query: "taking only: the user's words" items: "taking only: [{id, kind, dest, date, cf, thumb, main, size, duration, labels, description, text}]: rels the worker may read with read/readmany while the lease lives" errors: - message: "No such job" shape: "lost" - message: "Not this lease" shape: "lost" - message: "This job was not offered to {worker}" shape: "refused" - message: "{worker} works on it" shape: "held, by" - message: "{worker} may not analyse {machine}'s backups ({why})" shape: "refused" example: request: | {"op":"vision.selectlease","job":"sel_3f9a1c07b2e4d5c6a7b8c9d0"} response: | {"ok":true,"lease":"b41e0c2b9d4f3e10a71e0c2b9d4f3e10","expires":"2026-10-21T14:07:31Z","machine":"Vlads-iPhone","query":"night views of Chicago","items":[{"id":"a71e0c2b9d4f3e10","kind":"photo","thumb":"Thumbs\\2026\\10\\IMG_1234.HEIC.jpg","main":"Photos\\2026\\10\\IMG_1234.HEIC","size":2811034,"duration":null,"labels":["city","night"],"description":"A skyline at night.","text":null,"dest":"3F9A1C07B2E4","date":"2026-10-18","cf":true}]} vision.selected: manual: "10-api-peer.md#op-vision-selected" cap: "vision-select 1" channel: "company" sender: "the worker holding the select lease" request: body: "a JSON text {kind: sv-select, host, job, lease, ts, scored: [{id, score, why}], failed: [{id, why}]} or {..., error} to give the job back" sig: "base64 ECDSA P-256 / SHA-256 by the worker's device key over the body's UTF-8 bytes" response: ok: "true" errors: - message: "Not signed by {worker}'s device key" shape: "refused" - message: "This answer is not for {host}" shape: "refused" - message: "The answer's time is more than 5 minutes off" shape: "refused" - message: "Not this lease" shape: "lost" example: request: | {"op":"vision.selected","body":"{\"kind\":\"sv-select\",\"host\":\"CHIA2\",\"job\":\"sel_3f9a1c07b2e4d5c6a7b8c9d0\",\"lease\":\"b41e0c2b9d4f3e10a71e0c2b9d4f3e10\",\"ts\":\"2026-10-21T14:02:31Z\",\"scored\":[{\"id\":\"a71e0c2b9d4f3e10\",\"score\":1,\"why\":\"lit skyline at night\"}],\"failed\":[]}","sig":""} response: | {"ok":true} remove: manual: "10-api-peer.md#op-remove" cap: "remove 1" channel: "company" sender: "the device itself; its own folder only; allowed in a finished date" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rels: "[rel], optional" index: "{rel, data: b64 of the new index file, mtime?: ticks (default now)}, optional; no data frame follows" ids: "[index id], optional (changes 3), at most 100: the items removed; the change record lists them under gone when the PC cannot read the index (encrypted) or none came" machine: "optional; another machine is refused" response: removed: "[rel]" missing: "[rel]" errors: - message: "Nothing to remove" - message: "Missing index path" - message: "Missing index data" - message: "{peer} may remove only from its own backups, not {other}'s" shape: "refused" notes: - "the whole request fits one 4 MiB frame (about 3 MB of index)" example: request: | {"op":"remove","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-16","rels":["Photos\\2026\\10\\IMG_1234.HEIC"],"index":{"rel":"Index\\2026-10.json","data":"eyJ2IjoxLCJpdGVtcyI6W119","mtime":639279090000000000}} response: | {"ok":true,"removed":["Photos\\2026\\10\\IMG_1234.HEIC"],"missing":[]} backups.changes: manual: "10-api-peer.md#op-backups-changes" cap: "changes 1" channel: "company" sender: "the device itself; another machine's only under a grant (a ticket here or an earlier grant on the connection), as reading its backups" request: machine: "string, optional: the machine whose backups (default: the caller)" device: "\"d_…\", optional: its device id; another device's is refused" ticket: "string, optional: a peer ticket for another member's backups" since: "\":\", optional: absent = only this PC's counter now" response: v: "\":\": this PC's counter of backups:, null before its first change" changes: "[record]: oldest first, the records after since, this PC's origin only" full: "true instead of changes: since older than the last 1000, newer than v, malformed or of another origin; read the whole backups" errors: - message: "{device} is not the device of {machine}'s backups" shape: "refused" - message: "{machine} is not known to the account service" notes: - "a record: {part: backups:, v, prev, at, moved?: {Deleted?, Archived?, Photos?: [index id]}, gone?: [index id]} or full past 100 ids" - "recorded from the month index before and after each move and remove of that device on this PC (the ids whose group changed, the ids gone); the same change again within 10 minutes (another date, another drive) is not a new record; an encrypted index, which the PC never reads, is recorded from the request's ids (changes 3: a remove's as gone, a move's as moved.; the ids never go to the service or APNs); no ids, more than 100, or a move without its group: a full record; a plain index decides by itself" changes.watch: manual: "10-api-peer.md#op-changes-watch" cap: "changes 2" channel: "company, guest (its album's part only)" sender: "an open app on its own channel to one PC; each part as reading it: an album with its album ticket (as album.list), a device's backups by machine (its own, or another's under a grant)" request: parts: "[{part: album:|backups:, ticket?: album ticket or peer ticket, machine?: the backups' machine (default: the caller)}]" response: v: "{part: [\":\", …]}: the newest v per origin this PC knows, its own first (only the parts it may serve)" refused: "then, once per part it may not serve: {part, error}" change: "then, for every record of a watched part made on this PC or arriving from another PC: the record" ping: "true, every 30 s with nothing else sent" errors: - message: "Missing parts" notes: - "the frames after the first come unasked while the watch lasts; the right to a part is checked again before each record (a revoked ticket: refused for it, the others go on)" - "another changes.watch on the channel replaces the parts (a new first answer); any other request ends the watch and is answered; closing the channel ends it" - "a watch belongs to its channel, not its machine: one machine may watch on several channels at once; a new watch, another request or closing on one channel never ends another channel's watch" - "neither a job nor a short request: an update does not wait for a watch" changes.push: manual: "10-api-peer.md#op-changes-push" cap: "changes 2" channel: "company" sender: "another company PC, with records of its own origin only (v names its instance id)" request: records: "[record]: change records made on the sender (as backups.changes / album.changes give them)" response: taken: "int: records new to this PC (well formed, of the sender's origin, newer than what it knew)" errors: - message: "Missing records" notes: - "a taken record goes to this PC's watches, its Space Vision worker (moved.Deleted and gone leave its queue) and its public links (read again); this PC keeps only the newest v per origin and never passes it on" - "each PC sends its own records to the company's other online PCs (not phones) as it makes them; a PC that answers Unknown request is not asked again until its version changes" move: manual: "10-api-peer.md#op-move" cap: "move 1" channel: "company" sender: "the device itself; its own folder only; allowed in a finished date, refused while the date is being written" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" moves: "[{from: rel, to: rel}] in the date folder (encrypted rels for an encrypted drive)" index: "[{rel, data: b64 of the new index file (already encrypted for an encrypted drive), mtime?: ticks (default now)}], optional (one object is taken too); no data frame follows" ids: "[index id], optional (changes 3), at most 100: the items moved; with group, the change record lists them under moved. when the PC cannot read the index (encrypted)" group: "\"Deleted\"|\"Archived\"|\"Photos\", optional (changes 3): where the ids went (Photos = put back or unarchived); one group per request" machine: "optional; another machine is refused" response: moved: "int: renames done" already: "int: found done (to there and from gone, or the same bytes)" missing: "[rel]: empty on success" errors: - message: "{date} is being written on {pc}:{path}; retry when it is complete" shape: "waiting: {ok:false, waiting:true, error, moved:0, already:0, missing:[]}" - message: "{N} item(s) to move are not in {date}" shape: "{ok:false, error, moved:0, already:0, missing:[froms not found]}; nothing changed" - message: "{rel} is already in {date} with other content" shape: "{ok:false, error, moved:0, already:0, missing:[]}; nothing changed" - message: "Nothing to move" - message: "Missing moves" - message: "Two items are moved to the same place" - message: "{peer} may move only in its own backups, not {other}'s" shape: "refused" notes: - "one step per date: on any failure the renames done so far are undone and nothing is written" - "renames keep the file: other dates' hard links keep their old names (the phone sends a move per date)" - "one request per date and destination; not fanned out to the PC's other drives (as remove)" - "the whole request fits one 4 MiB frame" example: request: | {"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}]} response: | {"ok":true,"moved":1,"already":0,"missing":[]} link: manual: "10-api-peer.md#op-link" cap: "dated" channel: "company" sender: "the backing-up device; own folder; to must not be a finished date" request: dest: "string" drives: "[string], optional (multidrive 1): several destinations instead of dest, at most 64; the answer is then {ok:true, drives:{id: this answer for that drive, or {ok:false, error}}}" cf: "bool" from: "yyyy-MM-dd, earlier date" to: "yyyy-MM-dd, this date" rels: "[rel]" response: errors: "[null or text], one per rel" copied: "bool: the PC copied instead of hard-linking" errors: - message: "{date} is complete on {pc}:{path}; mark it incomplete before writing into it" - message: "{rel} is not in {from}" shape: "per rel, inside errors[]" - message: "Missing drives" shape: "drives:[] (multidrive 1)" - message: "Too many drives (at most {max})" shape: "more than 64 drives (multidrive 1)" notes: - "with drives (multidrive 1) the same rels are linked on each drive at once; a finished date, an unknown or offline drive is that drive's {ok:false, error} in drives" example: request: | {"op":"link","dest":"3F9A1C07B2E4","cf":true,"from":"2026-10-16","to":"2026-10-17","rels":["C\\a.txt"]} response: | {"ok":true,"errors":[null],"copied":false} mark: manual: "10-api-peer.md#op-mark" cap: "resume" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" run: "string, the run id" uploads: "bool, optional (upload 1): uploads through the relay's HTTPS door are on their way; dead runs close the date only 24 h after its last write, not 2 h (docs/relay-upload.md)" drives: "[string], optional (multidrive 2): several destinations instead of dest, at most 64; the answer is then {ok:true, drives:{id:{ok:true}, the nearly-full refusal, or {ok:false, error}}}" response: ok: "true" notes: - "allowed on any date: a complete or partial one is re-opened; a stale marker of a dead run is replaced by this run's" - "with drives (multidrive 2) each drive is marked at once; a nearly full, unknown or offline drive is that drive's {ok:false, ...} in drives; unmark takes only dest" errors: - message: "Invalid date folder: {date}" unmark: manual: "10-api-peer.md#op-mark" cap: "resume" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" run: "string" partial: "bool, optional (partial 1): the run stopped with items left and the device closed the date; the partial marker replaces the incomplete one" fanoutWait: "number, optional (2026-10-31, iOS request #81): seconds (0 to 120, default 0) to wait for the date's fan-out copies to that destination before answering fanoutFailed" response: ok: "true" fanoutFailed: "[rel], optional (2026-10-31, iOS request #81): the date's fan-out copies to that destination that failed, as the put named them; each answered once. The date is closed there without them: the device rewrites that drive's index without them (mark, the writes, unmark partial)" fanoutPending: "int, optional: copies to that destination still queued (after fanoutWait); their failures are left to recheck on the next prepare" notes: - "the marker goes when this PC's fan-out copies of that date to that destination are done (the answer waits only fanoutWait); writes the date's manifest" - "without partial (or false): both markers go, the date is complete" put: manual: "10-api-peer.md#op-put" cap: "dated; dests: fanout; resume: resume; hash on commit: e2e" channel: "company" sender: "the backing-up device; own folder; not a finished date" request: dest: "string" dests: "[id], optional (fan-out; ignored by a PC without a fan-out queue)" cf: "bool" date: "yyyy-MM-dd" rel: "string" size: "int bytes" mtime: "ticks" resume: "bool, optional (the engine asks only for files of at least 64 MiB)" response: first: "{ok:true} or, with resume, {ok:true, have:, block:8388608, blocks:[hash hex]}" final: "{ok:true, error:null, checked?} or {ok:true, error:null, checked:false, damaged, resend} (arrival 1: arrived cut short or not decoding; kept, re-send request filed) or {ok:false, error}" streaming: "after the first answer: optional {op:'from', offset} (with resume; 0 or a block boundary up to have), data frames (1 MiB), then {op:'commit', hash?} or {op:'abort'}; abort always answers ok:true" streamFrames: from: "{op:'from', offset:int}" commit: "{op:'commit', hash?: 32 hex}" abort: "{op:'abort'}" errors: - message: "{date} is complete on {pc}:{path}; mark it incomplete before writing into it" - message: "Verification failed: {detail}" - message: "Unknown destination {dest}" - message: "No destination" - message: "Bad message: {detail}" shape: "channel error: a stream frame that is not JSON closes the connection" example: request: | {"op":"put","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-17","rel":"D\\Video\\Holiday.mp4","size":2147483648,"mtime":639278252430000000,"resume":true} response: | {"ok":true,"have":16777216,"block":8388608,"blocks":["9c1e4be0d22f4a7f8b3c6d5e4f3a2b1c","0f1e2d3c4b5a69788796a5b4c3d2e1f0"]} putsmall: manual: "10-api-peer.md#op-putsmall" cap: "putsmall; dests: fanout; hash: e2e" channel: "company" sender: "the backing-up device; own folder; not a finished date" request: dest: "string" dests: "[id], optional" cf: "bool" date: "yyyy-MM-dd" rel: "string" size: "int" mtime: "ticks" hash: "32 hex, optional" streaming: "exactly one data frame (the whole file) follows the request; the PC always reads it first" response: ok: "true" checked: "bool (arrival 1): the copy is confirmed good (hash matched; a photo or video decodes)" damaged: "string, optional (arrival 1): what is wrong with the copy (kept)" resend: "rs_ id, optional (arrival 1): the re-send request filed for it" kept: "string, optional (arrival 1, with checked:true): damaged, but its origin has nothing better (these bytes were answered same or gone, or given up): it counts as backed up" errors: - message: "Expected file data" shape: "channel error (connection closed) when the next frame is not a data frame" - message: "{date} is complete on {pc}:{path}; mark it incomplete before writing into it" - message: "Verification failed: {detail}" notes: - "pipelined: the engine sends up to 64 files / 2 MiB, then reads the answers" prunedate: manual: "10-api-peer.md#op-prunedate" cap: "dated" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" response: ok: "true" errors: - message: "Missing date" prunefolder: manual: "10-api-peer.md#op-prunefolder" cap: "placement" channel: "company" sender: "the backing-up device; own folder" request: dest: "string" cf: "bool" date: "yyyy-MM-dd" rel: "string, the folder in the date folder" response: ok: "true" errors: - message: "Invalid date folder: {date}" placement: manual: "10-api-peer.md#op-placement" cap: "placement" channel: "company" sender: "the backing-up device; describes only its own folders (Computer and Inst overwritten with the caller's)" request: dest: "string" doc: "string: the placement document as JSON text" response: ok: "true" errors: - message: "Bad placement" notes: - "stored as /.spacebackup-placement-.json" fetch: manual: "10-api-peer.md#op-fetch" cap: "fetch" channel: "company" sender: "a PC repairing a file" request: hash: "32 hex" size: "int, -1 if unknown" rel: "string, optional hint" response: head: "{ok:true, size} (size as asked)" end: "{ok:true, done:true, sent}" streaming: "head, data frames (1 MiB), end frame" errors: - message: "No copy with that hash here" - message: "Missing hash" dates: manual: "10-api-peer.md#op-dates" cap: "read 1" channel: "company" sender: "any device; own folder or a grant" request: dest: "string" cf: "bool" machine: "string, optional" response: dates: "[yyyy-MM-dd] in the cf layout asked" incomplete: "[yyyy-MM-dd]" partial: "[yyyy-MM-dd] closed after a stopped run (partial 1)" errors: - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" example: request: | {"op":"dates","dest":"3F9A1C07B2E4","cf":true,"machine":"Annas-iPhone"} response: | {"ok":true,"dates":["2026-10-15","2026-10-16","2026-10-17"],"incomplete":["2026-10-17"]} read: manual: "10-api-peer.md#op-read" cap: "read 1" channel: "company" sender: "any device; own folder or a grant" request: dest: "string" cf: "bool" machine: "string, optional" date: "yyyy-MM-dd" rel: "string" offset: "int, default 0" length: "int, default -1 (to the end)" response: head: "{ok:true, size:, offset, length:, mtime:ticks}" end: "{ok:true, done:true, sent}" streaming: "head, data frames (at most 1 MiB), end; a read error after the head ends with {ok:false, error} instead of the end" errors: - message: "No such file: {rel}" shape: "{ok:false, missing:true, error}" - message: "Invalid range" - message: "Offset {offset} is past the end ({size} bytes): {rel}" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" example: request: | {"op":"read","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-16","rel":"Photos\\2026\\10\\IMG_1234.HEIC","offset":0,"length":1048576} response: | {"ok":true,"size":2381044,"offset":0,"length":1048576,"mtime":639277705310000000} video.copy: manual: "10-api-peer.md#op-video-copy" cap: "video-copy 1" channel: "company" sender: "any device; own folder or a grant (as read), or an album ticket (as album.read)" request: dest: "string" cf: "bool" machine: "string, optional" date: "yyyy-MM-dd" rel: "string" ticket: "string: an album file instead (with album, name, dest?), as album.read" album: "string, with ticket" name: "string, with ticket" start: "bool, default true: start making the copy when it is not there" decodes: "object, optional: {hevc10: false} = this phone cannot decode 10-bit HEVC: the PC makes the copies ahead as for a TV; alone (no rel, no name) it is answered {ok:true, ahead:true}" response: ok: "true" ahead: "true: only decodes was sent" state: "ready | making | none" size: "ready: the copy's length in bytes (what video.copy.read sends)" seconds: "the video's length, when known" done: "making: seconds of the video encoded so far" width: "ready: the copy's picture width (at most 1920)" height: "ready: the copy's picture height" why: - "encrypted" - "no ffmpeg" - "not a video" - "failed" - "too long" - "not made" errors: - message: "No such file: {rel}" shape: "{ok:false, missing:true, error}" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" notes: - "the copy: the TV copy (H.264 8-bit yuv420p SDR, HDR tone-mapped when this ffmpeg can, AAC, at most 1920 px, upright, 6 Mbit/s cap); a normal MP4 with its moov first (seekable; the fragmented encode if the remux fails; a fragmented TV copy made ahead is remuxed once when a phone first asks); one copy for the TVs and the phones (the file looked up in the PC's photo library, kept under the TV copy's key): a copy made ahead for the TVs is ready at once; kept in the TV copies' store, encrypted at rest" - "made at the priority of someone waiting (ahead of the TV copies made in the background), at most two at a time (a third: making, done 0, started when one ends); the phone asks again every ~2 s" - "an encrypted file is decrypted with a data key this PC holds: the caller's own backups, another machine's under a valid grant, an album's (its ticket); without the key: none/encrypted, even when a copy exists" - "decodes {hevc10:false}, or asking for an HDR HEVC video: the TV copies are made ahead on this PC (every HEVC/HDR video of its library up to 5 minutes, album videos first, then the newest)" - "start:false and no copy yet: none/not made; a copy that failed stays none/failed until the PC restarts; longer than 10 minutes: none/too long" example: request: | {"op":"video.copy","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-22","rel":"Photos\\2026\\10\\IMG_4713.MOV"} response: | {"ok":true,"state":"making","seconds":18.4,"done":6.2} video.copy.read: manual: "10-api-peer.md#op-video-copy-read" cap: "video-copy 1" channel: "company" sender: "as video.copy" request: dest: "string (or ticket, album, name as video.copy)" cf: "bool" machine: "string, optional" date: "yyyy-MM-dd" rel: "string" offset: "int, default 0" length: "int, default -1 (to the end); the phone asks 1 MiB" response: head: "{ok:true, size:, offset, length:}" end: "{ok:true, done:true, sent}" streaming: "head, data frames (at most 1 MiB), end, as read" errors: - message: "The copy is still being made" shape: "{ok:false, making:true, error}" - message: "No copy of this video here (ask video.copy first)" shape: "{ok:false, missing:true, error}" - message: "This video is encrypted and is not decrypted here for you" shape: "{ok:false, encrypted:true, error}" - message: "No such file: {rel}" shape: "{ok:false, missing:true, error}" - message: "Invalid range" - message: "Offset {offset} is past the end of the copy ({size} bytes)" example: request: | {"op":"video.copy.read","dest":"3F9A1C07B2E4","cf":true,"date":"2026-10-22","rel":"Photos\\2026\\10\\IMG_4713.MOV","offset":0,"length":1048576} response: | {"ok":true,"size":9817342,"offset":0,"length":1048576} readmany: manual: "10-api-peer.md#op-readmany" cap: "read 3" channel: "company" sender: "any device; own folder or a grant (checked once)" request: dest: "string" cf: "bool" machine: "string, optional" date: "yyyy-MM-dd" rels: "[rel], at most 64" response: head: "{ok:true, rel, size, mtime}" end: "{ok:true, done:true, sent} (or {ok:false, done:true, sent, error} when the disk failed mid-file)" fileError: "{ok:false, rel, missing?:true, error}: that file only" last: "{ok:true, done:true, all:true}" cancelled: "{ok:true, done:true, sent, cancelled:true} for a file cut short, then {ok:true, done:true, all:true, cancelled:true}" streaming: "for each rel in order: head, data frames, end; then last" errors: - message: "At most {max} files in one readmany, not {n}" - message: "Missing paths" - message: "No such file: {rel}" shape: "per file" - message: "{machine}'s backups are served only after a grant (a ticket from the account service)" cancel: manual: "10-api-peer.md#op-cancel" cap: "read 3" channel: "company" sender: "the device reading a readmany" request: "no fields" response: "never answered" notes: - "never answered; stops the readmany being sent after its current frame; ignored when no readmany is running" grant: manual: "10-api-peer.md#op-grant" cap: "read 2" channel: "company" sender: "a reader device holding a read ticket" request: ticket: "string" response: machine: "string, the source's folder name, now readable on this connection" until: "date-time UTC, when the PC asks the service again" errors: - message: "Missing ticket" - message: "This PC is not signed in to the account service and cannot confirm a ticket" - message: "The account service did not confirm a share or approved restore of these backups for this device (or the ticket expired)" shape: "refused" - message: "This ticket was given to {requester}, not to {peer}" shape: "refused" - message: "The account service cannot be asked right now: {detail}" shape: "not refused: retry later" example: request: | {"op":"grant","ticket":"pt_Q2x7mR4vK9"} response: | {"ok":true,"machine":"ANNA-PC","until":"2026-10-17T10:12:00Z"} replicate: manual: "10-api-peer.md#op-replicate" cap: "replicate 1" channel: "company" sender: "the source machine (the grant's machine) to the grant's primary" request: dest: "string, the primary's drive holding the date" cf: "bool" date: "yyyy-MM-dd, default the grant's" grant: "{payload, sig}" alsoTo: "[{pc, dest}], optional, each in the grant's targets, none on this PC; default all targets" wait: "int seconds 0..600, default 0" response: progress: "{ok:true, progress:true, replicas:[Replica]} every second while waiting" final: "{ok:true, machine, date, replicas:[Replica]}" Replica: "{pc, dest, drive, state: done|waiting|failed|resend, since, error?, full?, files?, bytes?, copying?, grantExpired?, keep? (that drive's PC max number of backups)}" errors: - message: "{name} keeps no replication jobs" - message: "A rearrange grant does not allow a replication" - message: "A replication grant of {machine} is used only by {machine} itself, not by {peer}" - message: "This replication grant names {primary} as the primary, not {name}" - message: "This replication grant is for {grantDate}, not {date}" - message: "{drive} is not in {machine}'s replication grant" - message: "{drive} is on {name} itself: send it with dests (fan-out)" - message: "{machine} has no {date} on {drive}" - message: "{machine}'s {date} is not complete on {drive} (its run has not finished there; it is copied once the run finishes or this PC closes it)" shape: "{ok:false, waiting:true, error}: accepted, not a failure; the job is kept and copies the date once the run finishes or this PC closes it (dead run), while the grant is good. Test waiting, not the text" - message: "alsoTo without pc" - message: "alsoTo without dest" replicas: manual: "10-api-peer.md#op-replicas" cap: "replicate 1 (rearrange:true: rearrange 1)" channel: "company" sender: "the machine itself" request: date: "yyyy-MM-dd (not with rearrange:true)" machine: "string, optional, must be the caller" rearrange: "bool, optional: the rearrangement's status instead (see rearrange)" response: replication: "{ok:true, machine, date, replicas:[Replica]} ([] for an unknown date)" rearrangement: "the rearrange answer, or {ok:true, machine, state:'none', dates:[]}" errors: - message: "Only {machine} itself asks where its dates were replicated" - message: "Only {machine} itself asks about its rearrangement" - message: "Missing date" rearrange: manual: "10-api-peer.md#op-rearrange" cap: "rearrange 1" channel: "company" sender: "the source machine (the grant's machine) to the grant's primary" request: grant: "{payload, sig} of a rearrange grant" cf: "bool, default true" wait: "int seconds 0..600" response: ok: "true" machine: "string" issued: "yyyy-MM-ddTHH:mm:ssZ" state: "done | working | waiting | grantExpired | none (grantExpired comes before working: an ended grant something needs reads grantExpired while a pass runs)" dates: "[{date, state, from, to:[{pc, dest, drive, state, error?, full?, items?, keep?}], dropped:[drive], error?}]" rearranged: "[{drive, items}]" elsewhere: "[{date, drives:[drive]}], optional" superseded: "string, optional: a later rearrangement of the machine on another PC ended this job" progress: "true on progress frames during wait" errors: - message: "{name} keeps no replication jobs" - message: "A replication grant does not allow a rearrangement" - message: "A rearrange grant of {machine} is used only by {machine} itself, not by {peer}" - message: "This rearrange grant names {primary} as the primary, not {name}" - message: "A later rearrangement of {machine} (issued {issued}Z) is in progress" forms: manual: "10-api-peer.md#op-forms" cap: "forms 1" channel: "company" sender: "a phone to any PC it reaches (after a 'forms' changed push, and when it connects for a run)" request: answers: "[{pc, dest, requested, accepted, error?}], optional: accepted:false declines that request (error: the phone's words); an answer for another requested time is ignored" response: ok: "true" machine: "string: the caller" wanted: "[{pc, dest, drive, plain, requested}]: this PC's pending requests for the caller; plain:true = Not encrypted, false = Encrypted; requested yyyy-MM-ddTHH:mm:ssZ" errors: - message: "forms: the caller has no machine name" photos.work: manual: "10-api-peer.md#op-photos-work" cap: "work-mark 1" channel: "company" sender: "a member's phone or tablet without an account connection at the moment (otherwise it calls POST work/marks itself)" request: marks: "[{source, id, work}]: source the backups' device name, id the item's id there (each 1-200 characters, no control character), work true (work) or false (not work); at most 5,000" response: ok: "true" changed: "int: the marks the account service changed (one equal to the stored one is not counted)" v: "int: the company's mark version after it" errors: - message: "This PC is not signed in to the account service" - message: "marks: an array of {source, id, work}" - message: "marks: work is true or false" photos.requests: manual: "10-api-peer.md#op-photos-requests" cap: "photoreq 1 (ops archive, unarchive: photoreq 2)" channel: "company" sender: "a phone to any PC it reaches (after a 'forms' changed push, and when it connects for a run)" request: answers: "[{id, accepted, error?, url?}], optional: accepted:false declines that request (error: the phone's words); url: the public link a link request made; an id that is not a pending request of the caller is ignored" response: ok: "true" machine: "string: the caller" wanted: "[{id, op, item, caption?, requested}]: this PC's pending requests for the caller (resend 1: also {id:'rs_…', op:'resend', date, rel, size, cause, requested, hash?, item?}: a file of its backup damaged here with no good copy anywhere, to read from its library again and upload; answered {id, accepted:true} once the new copy verified, {id, accepted:false, gone:true, error} when the library no longer has it, {id, accepted:false, same:true} when the library's bytes have the same hash; docs/resend.md); op delete (move to Deleted, as its viewer's Delete), caption (set it to caption; empty clears it), link (make a public link, answer its url), archive (archive it in its backups, kept on the phone: the next backup moves it into Archived), unarchive (its Put back out of Archived; one request per item with archive, the later replacing the earlier); a phone declines an op it does not know; item: the phone's asset id (the index's id); requested yyyy-MM-ddTHH:mm:ssZ" errors: - message: "photos.requests: the caller has no machine name" resend.answer: manual: "10-api-peer.md#op-resend-answer" cap: "resend 1" channel: "company" sender: "a PC or Mac source after its run, to the PC whose prepare listed resend" request: sent: "[id], optional: copied again (the copy landed and verified)" gone: "[id], optional: no longer in the source folder" same: "[id], optional: the source's bytes have the same hash as the damaged copy" error: "string, optional: the source's words" response: ok: "true" answered: "int: the pending requests of the caller these ids matched" notes: - "only the source a request is for answers it; an unknown id is ignored" replica.begin: manual: "10-api-peer.md#op-replica-begin" cap: "replicate 1 (date: rearrange 1)" channel: "company" sender: "the grant's primary to a target PC" request: grant: "{payload, sig}" dest: "string, this PC's drive (in targets, or to)" cf: "bool" date: "yyyy-MM-dd, rearrangement only" partial: "bool, optional (partial 1): the source copy is partial; replica.end closes this one partial" response: prev: "yyyy-MM-dd or null: latest complete (or partial) earlier date there" errors: - message: "{machine}'s {grant} names {primary} as the primary, not {peer}" - message: "{drive} is not in {machine}'s {grant}" - message: "{date} is not in {machine}'s {grant}" - message: "{machine}'s {date} is being written on {drive} already" - message: "{id} is not a destination of {name}" - message: "Destination offline: {drive} is not connected" replica.files: manual: "10-api-peer.md#op-replica-files" cap: "replicate 1" channel: "company" sender: "the primary, after replica.begin on the same connection" request: files: "[[rel, size, mtimeTicks, hash]], at most 2000 per frame" last: "bool" response: notLast: "{ok:true}" last: "{ok:true, need:[rel], linked:int, kept:int}" errors: - message: "No replica.begin on this connection" - message: "Not enough room on {drive}: {mb} MB to copy, {free} MB free" shape: "{ok:false, full:true, error}" - message: "Bad file entry" - message: "Bad path {rel}" - message: "{machine}'s {grant} has expired" replica.put: manual: "10-api-peer.md#op-replica-put" cap: "replicate 1" channel: "company" sender: "the primary, after replica.files" request: rel: "string, in the list" size: "int" mtime: "ticks" hash: "32 hex" response: first: "{ok:true, have, block:8388608, blocks:[hash]}" final: "{ok:true} | {ok:false, verify:true, error} | {ok:false, error}" streaming: "{op:'from', offset}, data frames, {op:'commit'}" errors: - message: "{rel} is not in the list" - message: "No replica.begin on this connection" - message: "Expected file data or commit, got {op}" shape: "channel error" - message: "Verification failed: {detail}" shape: "{ok:false, verify:true, error}" replica.end: manual: "10-api-peer.md#op-replica-end" cap: "replicate 1" channel: "company" sender: "the primary" request: "no fields" response: files: "int" bytes: "int" errors: - message: "{rel} is not complete on {drive}" - message: "No replica.begin on this connection" replica.dates: manual: "10-api-peer.md#op-replica-dates" cap: "rearrange 1" channel: "company" sender: "a rearrange grant's primary" request: grant: "{payload, sig}" dest: "string, in from or to" cf: "bool" response: dates: "[{date, complete:bool, partial:bool}] covered by the grant (partial: partial 1)" errors: - message: "Not a rearrange grant" - message: "{machine}'s rearrange grant names {primary} as the primary, not {peer}" - message: "{drive} is not in {machine}'s rearrange grant" - message: "replaced by {machine}'s later rearrangement on {name} (issued {issued})" replica.has: manual: "10-api-peer.md#op-replica-has" cap: "rearrange 1" channel: "company" sender: "a rearrange grant's primary" request: grant: "{payload, sig}" dest: "string" cf: "bool" date: "yyyy-MM-dd, in the grant's dates" response: exists: "bool" complete: "bool" form: "plain | encrypted | mixed | null (an encrypted date's plain Index/matchkeys.json is of the encrypted form)" files: "int" completed: "date-time UTC (round-trip 'o'), absent when no manifest" errors: - message: "{date} is not in {machine}'s rearrange grant" - message: "Missing date" replica.drop: manual: "10-api-peer.md#op-replica-drop" cap: "rearrange 1" channel: "company" sender: "a rearrange grant's primary" request: grant: "{payload, sig}" dest: "string" cf: "bool" date: "yyyy-MM-dd" form: "plain | encrypted, optional: drop only that (old) form" response: dropped: "bool" missing: "int (rearrange 3, with form): files of the old form without a twin in the new one; > 0: nothing dropped" errors: - message: "{drive} is not a drive {machine}'s rearrange grant moves dates from" - message: "{drive} is one of {machine}'s new drives: it keeps its dates" - message: "{drive} is not one of {machine}'s new drives" - message: "{drive} is {wanted} in {machine}'s rearrange grant: its {form} form stays" - message: "{machine}'s {date} is not complete in its {wanted} form on {drive}: the {form} one stays" replica.list: manual: "10-api-peer.md#op-replica-list" cap: "rearrange 2" channel: "company" sender: "a rearrange grant's primary" request: grant: "{payload, sig}" dest: "string, in from or to" cf: "bool" date: "yyyy-MM-dd, in the grant's dates" skip: "int, files already listed (pages of 2000)" any: "bool (rearrange 3): whatever is there, either form or both, hashes 0" response: form: "plain | encrypted (mixed with any)" total: "int" files: "[[rel, size, mtimeTicks, hash]]" partial: "bool (partial 1): the copy is partial; the copy made from it is closed partial too" errors: - message: "{machine}'s {date} is not complete in one form on {drive}" - message: "{machine}'s {date} is being written on {drive}" replica.read: manual: "10-api-peer.md#op-replica-read" cap: "rearrange 2" channel: "company" sender: "a rearrange grant's primary" request: grant: "{payload, sig}" dest: "string, in from or to" cf: "bool" date: "yyyy-MM-dd, in the grant's dates" rel: "string" offset: "int" count: "int, at most 1 MiB" response: n: "int, then one data frame of n bytes (none when 0)" errors: - message: "Bad path {rel}" replica.spread.dates: manual: "10-api-peer.md#op-replica-spread-dates" cap: "spread 1" channel: "company" sender: "any company PC holding a date of the machine" request: grant: "{payload, sig}: a destinations grant, or a rearrange grant (within its catch-up time)" dest: "string, a drive the grant names (targets, or to)" cf: "bool" response: dates: "[{date, complete:bool, partial:bool, digest?:string}]: every date of the machine on that drive; digest (spread 2): hex XxHash128 of a complete date's manifest paths and sizes, sorted" errors: - message: "A {grant} names its primary: an onward copy needs a destinations or a rearrange grant" - message: "{drive} is not in {machine}'s {grant}" - message: "replaced by {machine}'s later rearrangement on {name} (issued {issued})" replica.spread.files: manual: "10-api-peer.md#op-replica-spread-files" cap: "spread 2" channel: "company" sender: "any company PC holding the date complete, when the drive's digest differs from one of its copies" request: grant: "{payload, sig}: as replica.spread.dates" dest: "string, a drive the grant names" cf: "bool" date: "yyyy-MM-dd" response: files: "[[rel, size]]: the date's files there as its manifest lists them (empty: none, or being written)" errors: - message: "{drive} is not in {machine}'s {grant}" - message: "Missing date" audit.local: manual: "10-api-peer.md#op-audit-local" cap: "audit 1" channel: "company" sender: "the PC putting the company's backup audit together (spacebackup audit, the daily audit; docs/audit.md)" request: device: "string, optional: only that machine's backups" date: "yyyy-MM-dd, optional: only that date" lists: "bool, optional: each copy's file list, and each manifest file's size checked on the drive" response: local: "AuditLocal {pc, version, atUtc, drives:[{pc, dest, drive, online}], copies:[{pc, dest, drive, machine, date, complete, partial, writing, form, files, bytes, digest, damaged, missingFiles, badSize, list}], intents:[{machine, date, firstSeenUtc, updatedUtc, source, grantIssuedUtc, keep, targets:[{pc, dest, drive, form, rels}], changes}], keeps:[{pc, dest, machine, keep}], limited}: what this PC's drives hold, and its placement records (recorded first)" errors: - message: "Unknown request {op}" audit.fix: manual: "10-api-peer.md#op-audit-fix" cap: "audit 1" channel: "company" sender: "the PC whose audit found copies this PC can repair (spacebackup audit --fix, the daily audit)" request: machines: "[string]: the machines whose onward copies start now" response: queued: "[string]: those this PC keeps a destinations or rearrange grant of (it copies them now: missing dates, holes, the wanted form beside a wrong one; nothing deleted or converted)" errors: - message: "Unknown request {op}" replica.spread.begin: manual: "10-api-peer.md#op-replica-spread-begin" cap: "spread 1" channel: "company" sender: "any company PC holding the date complete; then replica.files, replica.put, replica.end on the same connection" request: grant: "{payload, sig}: as replica.spread.dates" dest: "string, a drive the grant names" cf: "bool" date: "yyyy-MM-dd" partial: "bool, optional: the source copy is partial" response: prev: "yyyy-MM-dd or null: latest complete earlier date there" errors: - message: "{drive} is not in {machine}'s {grant}" - message: "{machine}'s {date} is being written on {drive}: copied once that run finishes" - message: "{machine}'s {date} is being written on {drive} already" replica.destinations: manual: "10-api-peer.md#op-replica-destinations" cap: "spread 1" channel: "company" sender: "the machine itself (a phone with its runs), or a PC handing it on" request: grant: "{payload, sig}: a destinations grant, within its time" response: kept: "bool: later than the one this PC kept (its drives are looked at at once)" errors: - message: "Not a destinations grant: {grant}" album.add: manual: "10-api-peer.md#op-album-add" cap: "album 1 (pushed states: 2)" channel: "company" sender: "the ticket's own device, access owner or member-add; items from the caller's own backups" request: ticket: "string" album: "al_ + 16 of [a-z2-7]" dests: "[id] this PC's album drives" items: "[{id (1-64 of A-Za-z0-9-_), files:[plain rel], thumb?, kind (default photo), created?, place?:{lat,lon}, modified?, w?, h?, duration?, types?, camera?, labels?, text?, colors?, bright?, description?, transcript?, frames?, analysed?}] (index fields: album 8, month-index shapes; a plain source's index here wins; other fields dropped)" key: "bool: one data frame of the 32 data-key bytes follows" date: "yyyy-MM-dd, optional" alsoTo: "[{pc, dest}]" detach: "bool, optional (album 7): answered at once {ok, accepted:true, job, of, notifies}; the job runs on without the caller; notifies (0.13.9, iOS #63): this PC binds the job to the ticket with the account service (albums/{id}/jobs/accept) and reports its end (albums/{id}/jobs/done: the sender's member gets an album-job alert, the album's people the count)" streaming: "with key:true one data frame of exactly 32 bytes right after the request; progress frames {ok:true, progress:true, done, of, job} at most once a second, sent best-effort (album 7: the add runs to its end without the caller)" response: added: "[id]" already: "[id]" thumbs: "[id] (album 11, iOS request #103): of already, those that had no thumbnail here and got the one now in the backup (also sent on to alsoTo)" failed: "[{id, error}]" pushed: "[{pc, dest, drive, state, ok, error, added, waiting}]" count: "int or null" job: "string, job_ + 16 hex (album 7): read later with album.job" errors: - message: "A data key is 32 bytes" - message: "Missing items" - message: "Missing item id" - message: "Invalid item id: {id}" - message: "This PC cannot send albums to other PCs" - message: "Invalid album id: {id}" - message: "not in this PC's backups of {machine}: {file}" shape: "per item, in failed[]" album.put: manual: "10-api-peer.md#op-album-put" cap: "album 1 (queued: 2, caption: 5, meta: 6, meta into any album its member owns: 9)" channel: "company" sender: "a PC passing on an owner's or member-add member's add, a relay ticket's own PC, or the owner's device; never a member's device. With meta (album 6): only the device owning a public album; album 9: also a device of the member who owns an ordinary album, never an album shared with them (10-api-peer.md#op-album-put-public)" request: ticket: "string" album: "string" dest: "string (with meta: optional, default every connected album drive of this PC)" item: "{id, source, kind, created?, place?, files:[names], thumb, addedBy?, caption?, ? (album 8)} (not with meta)" queued: "date-time, default now" fillThumb: "bool, optional (album 11, iOS request #103): the item brings a thumbnail; an item here without one takes it (first answer thumbOnly)" batch: "bool, optional (album 12): one of a large put's items; recorded in album.json once per batch here until album.flush or the connection's end (10-api-peer.md#op-album-flush)" id: "string, with meta: the item's id" meta: "{name, size, mtime:ticks|ISO 8601, hash?:XxHash128 32 hex (else on each commit), kind:photo|video|live, month:yyyy-MM, created?, place?, caption?, ? (album 8)}: the owning device's plain copy into its public album, or (album 9) an owner's device's file into an album its member owns" dests: "[string], with meta, optional: the album drives of this PC to write" created: "ISO 8601, with meta, optional" thumb: "{size, hash?, mtime?}, with meta, optional: a thumbnail follows the file" alsoTo: "[{pc, dest}], with meta, optional: default every album drive on other PCs" response: first: "{ok:true, already:true} | {ok:true, already:true, removed:true} | {ok:true, files:[names], thumb} | {ok:true, thumbOnly:true, thumb} (fillThumb, album 11: send only the thumbnail)" final: "{ok:true, count} (with meta: {ok:true, added, count, pushed:[{pc, dest, drive, state, ok, error?, added, waiting}]})" streaming: "per file then thumbnail: data frames, then {op:'end', mtime, hash} (with meta: {op:'commit'}); {op:'abort'} answers {ok:true, aborted:true}" streamFrames: end: "{op:'end', mtime:ticks, hash:32 hex}" commit: "{op:'commit', hash} (with meta; hash may be left out when meta has it)" abort: "{op:'abort'}" errors: - message: "only the album's owner puts into it from a device" shape: "refused, with meta, an ordinary album (album 9; before: album is not public)" - message: "not the album's device" shape: "refused, with meta, a public album" - message: "{name} is {size}; {pc} takes files of up to {max} into an album from a phone" shape: "refused, with meta, reason too-big, max (bytes): meta.size plus the thumbnail's over the setting album-put-max-gb (default 4 GB; 0.14.3)" - message: "Not enough free space on {pc}'s drive {path} for {name} ({size}; {free} free, {reserve} MB must stay free). Try again when there is room." shape: "with meta, reason no-space, free, need (not refused: send again later): an album drive here would keep under 256 MB free (0.14.3)" - message: "{name} is not a photo or video; only these go into an album from a phone: {accepted}" shape: "refused, with meta, reason not-media, after the commits ({accepted}: HEIC, HEIF, JPEG, PNG, GIF, WebP, TIFF, DNG, RAW, MOV, MP4, M4V): the file's first bytes are no photo or video (the thumbnail: no picture); nothing kept (0.14.3)" - message: "{n} bytes arrived, meta says {size}" - message: "None of the album's drives is connected to {pc}" - message: "Missing item" - message: "Expected the end of a file" shape: "channel error" - message: "Verification failed: what arrived differs from what was sent" album.list: manual: "10-api-peer.md#op-album-list" cap: "album 1" channel: "company, guest" sender: "the ticket's own device (owner, member); a guest on its channel" request: ticket: "string (guest: optional)" album: "string" dest: "string, optional" response: dests: "[id] holding it" dest: "id" album: "album.json (guest: without items' source, removed, deleted and analysed.by; album 10: deleted, the album's Deleted area, the owner's all of it, a member's what they removed); album 8: each item with its index fields, filled first from a plain source date on this PC" files: "[[name, size, mtimeTicks]]" errors: - message: "Invalid album id: {id}" album.changes: manual: "10-api-peer.md#op-album-changes" cap: "changes 1" channel: "company, guest" sender: "as album.list (the album's owner or a member, with the album ticket; a guest on the guest channel, add items without source)" request: ticket: "string" album: "string" since: "\":\", optional: absent = only this PC's counter now" response: v: "\":\": this PC's counter of album:, null before its first change" changes: "[record]: oldest first, the records after since, this PC's origin only" full: "true instead of changes: since older than the last 1000, newer than v, malformed or of another origin; read the whole album" errors: - message: "This ticket is for another album" shape: "refused" notes: - "a record: {part, v, prev, at, add?: [items as album.list returns them], remove?: [index id]} or {part, v, prev, at, full: true} past 100 ids" album.read: manual: "10-api-peer.md#op-album-read" cap: "album 1" channel: "company, guest" sender: "as album.list" request: ticket: "string" album: "string" dest: "string, optional" name: "stored name or Thumbs/; album 10: Deleted/ or Deleted/Thumbs/ (the owner, or the member who removed it; never a guest)" offset: "int" length: "int" response: head: "{ok:true, size, offset, length, mtime}" end: "{ok:true, done:true, sent}" streaming: "as read" errors: - message: "This album is not on this PC" shape: "missing" - message: "No such file: {name}" shape: "missing" - message: "Invalid album file name: {name}" - message: "Missing name" album.readmany: manual: "10-api-peer.md#op-album-readmany" cap: "album 4" channel: "company, guest" sender: "as album.list" request: ticket: "string" album: "string" dest: "string, optional" names: "[name], at most 64" response: head: "{ok:true, name, size, mtime}" end: "{ok:true, done:true, sent}" fileError: "{ok:false, name, missing?, error} or {ok:false, name, error, sent} mid-file" last: "{ok:true, done:true, all:true}" errors: - message: "Missing names" - message: "At most {max} files per album.readmany" - message: "{name} is too large for album.readmany; use album.read" album.remove: manual: "10-api-peer.md#op-album-remove" cap: "album 1" channel: "company" sender: "owner or member-add device, a PC passing it on, a relay ticket" request: ticket: "string" album: "string" dests: "[id]" ids: "[item id]" source: "string, optional (ignored for a member)" alsoTo: "[{pc, dest}]" by: "string, optional (album 10: who removed it, from a PC passing on the owner's remove; a member's is the member)" permanent: "bool, optional (album 10: the owner's; gone at once, not kept in the album's Deleted)" response: removed: "int" count: "int" pushed: "[Pushed]" refused: "[{id, error}] (members only)" errors: - message: "Missing ids" - message: "You can remove only what you added" - message: "Only the album's owner deletes from it permanently" shape: "refused" album.deleted: manual: "10-api-peer.md#op-album-deleted" cap: "album 10" channel: "company" sender: "as album.list (never a guest)" request: ticket: "string" album: "string" dest: "string, optional" response: dests: "[id] holding it" dest: "id" items: "[album item + removedBy (email or null), removedAt, purgeAt], newest first: the owner's all, a member's what they removed" files: "[[Deleted/, size, mtimeTicks]]" errors: - message: "A guest sees no album's Deleted" shape: "refused" album.restore: manual: "10-api-peer.md#op-album-restore" cap: "album 10" channel: "company" sender: "as album.remove; without ids: the owner's device (the album put back by the service first); with from: the owner's device" request: ticket: "string" album: "string" ids: "[item id], optional: absent = the whole deleted album back on dests" source: "string, optional (ignored for a member)" from: "album id, optional: a deleted album of the same owner whose items go into album (From Other Apps)" dests: "[id]" alsoTo: "[{pc, dest}]" response: restored: "int (ids: items put back; none: drives)" count: "int (ids)" pushed: "[Pushed]" refused: "[{id, error}] (members only)" added: "[id] (from)" already: "[id] (from)" failed: "[{id, error}] (from)" errors: - message: "You can put back only what you removed" shape: "refused" - message: "Only the album's owner can put it back" shape: "refused" - message: "Only the owner of the deleted album can put its items back" shape: "refused" - message: "The deleted album {id} is not kept on {pc}" shape: "missing" album.purge: manual: "10-api-peer.md#op-album-purge" cap: "album 10" channel: "company" sender: "as album.remove" request: ticket: "string" album: "string" dests: "[id]" ids: "[item id]" source: "string, optional (ignored for a member)" alsoTo: "[{pc, dest}]" response: purged: "int" pushed: "[Pushed]" refused: "[{id, error}] (members only)" errors: - message: "Missing ids" - message: "You can delete permanently only what you removed" shape: "refused" album.excluded: manual: "10-api-peer.md#op-album-excluded" cap: "album 14" channel: "company" sender: "as album.list (never a guest)" request: ticket: "string" album: "string" dest: "string, optional" response: dests: "[id] holding it" dest: "id" items: "[album item + label {conf, why}, excludedAt]: the album's Excluded folder (owner and members)" files: "[[Excluded/, size, mtimeTicks]]" errors: - message: "A guest sees no album's Excluded" shape: "refused" album.return: manual: "10-api-peer.md#op-album-return" cap: "album 14" channel: "company" sender: "as album.remove (the owner's)" request: ticket: "string" album: "string" dests: "[id]" ids: "[item id]" source: "string, optional" alsoTo: "[{pc, dest}]" response: returned: "int" count: "int or null: the album's items here after it" pushed: "[Pushed]" refused: "[{id, error}] (a member who may add: only the owner returns items)" errors: - message: "Missing ids" album.flush: manual: "10-api-peer.md#op-album-flush" cap: "album 12" channel: "company" sender: "a PC at the end of a large put (albums put, albums import) whose album.put requests on this connection were marked batch" request: album: "string" response: ok: "true once album.json on this PC's drives of the album, and on the PCs this connection's batch puts went on to, has every item" album.caption: manual: "10-api-peer.md#op-album-caption" cap: "album 5" channel: "company" sender: "as album.remove" request: ticket: "string" album: "string" dests: "[id]" id: "item id" source: "string, optional" caption: "string, at most 2000 chars, '' clears" alsoTo: "[{pc, dest}]" response: captioned: "int" pushed: "[Pushed]" errors: - message: "Missing caption ('' clears it)" - message: "A caption is at most {max} characters" - message: "A caption holds no control characters (only newlines)" - message: "You can caption only what you added" album.delete: manual: "10-api-peer.md#op-album-delete" cap: "album 1" channel: "company" sender: "the owner's device, a PC passing it on, the owner's relay ticket" request: ticket: "string" album: "string" dests: "[id], any destination of this PC" alsoTo: "[{pc, dest}]" permanent: "bool, optional (album 10: gone at once, also a copy kept in the deleted albums; else kept 30 days)" response: deleted: "int" pushed: "[Pushed]" album.copy: manual: "10-api-peer.md#op-album-copy" cap: "album 2" channel: "company" sender: "the owner's device" request: ticket: "string" album: "string" from: "id, optional" dests: "[id]" alsoTo: "[{pc, dest}]" response: copied: "int" already: "int" failed: "[{id, error}]" pushed: "[Pushed]" count: "int or null" errors: - message: "This album is not on {name}" - message: "The album is not on {drive}" album.clone: manual: "10-api-peer.md#op-album-clone" cap: "album 3" channel: "company" sender: "the ticket's own device: owner or member-add of album, and from.ticket for the same device" request: ticket: "string" album: "string" dests: "[id]" alsoTo: "[{pc, dest}]" from: "{ticket, album, dest?}" ids: "[id], optional" detach: "bool, optional (album 7): answered at once {ok, accepted:true, job, of}" response: added: "[id]" already: "[id]" failed: "[{id, error}]" pushed: "[Pushed]" count: "int or null" job: "string (album 7)" errors: - message: "album.clone needs from: {ticket, album}" - message: "The album {albumName} is not on {name}" - message: "not in the album {albumName}" shape: "per id, in failed[]" album.merge: manual: "10-api-peer.md#op-album-merge" cap: "album 13" channel: "company" sender: "the ticket's own device: owner of album (the new one) and of both from albums (the same owner)" request: ticket: "string" album: "string" dests: "[id]" alsoTo: "[{pc, dest}]" from: "[{ticket, album, dest?}, {ticket, album, dest?}]: the two albums, the first's items first" detach: "bool, optional: answered at once {ok, accepted:true, job, of, notifies}" quiet: "bool, optional: a detached helper that alerts nobody" response: added: "[id]" already: "[id]" duplicates: "[{id, source, as}]: items left out as the same as the one taken (as: its id)" failed: "[{id, error}]" pushed: "[Pushed]" count: "int or null" job: "string" errors: - message: "album.merge needs from: [{ticket, album}, {ticket, album}], the two albums to merge" - message: "Only albums you own can be merged" shape: "refused" - message: "Merge two different albums into a new one" - message: "The album {albumName} is not on {name}" album.status: manual: "10-api-peer.md#op-album-status" cap: "album 2" channel: "company" sender: "the ticket's own device, owner or member" request: ticket: "string" album: "string" response: drives: "[{pc, dest, drive, state: done|waiting|failed|missing|offline, items?, waiting?, error?, since?}]" jobs: "[Job] (album 7): the album's adds and clones on this PC, newest first; see album.job" album.job: manual: "10-api-peer.md#album-jobs" cap: "album 7" channel: "company" sender: "the ticket's own device, owner or member" request: ticket: "string" album: "string" job: "string, optional: without it every job of the album (jobs)" response: job: "{job, op: add|clone, state: running|done|failed, by, detached, done, of, started, finished|null, result: null|{added, already, failed, pushed, count}, error|null}" jobs: "[Job], without job" errors: - message: "No job {id} of this album on {name} (an ended job is kept 24 hours, until the PC restarts)" shape: "missing: true" gdrive-speed: manual: "10-api-peer.md#op-gdrive-speed" cap: "gdrive 1" channel: "company" sender: "a PC backing up a Google account" request: token: "string, short-lived Google access token" response: mbps: "number or null" free: "int bytes" error: "string or null" errors: - message: "no access token" guestOps: manual: "10-api-peer.md#guest-ops" allowed: - "album.list" - "album.read" - "album.readmany" - "album.changes" - "changes.watch" rules: - "only the handshake's album; ticket may be left out (the handshake's is used)" - "album.changes and changes.watch (#70, a PC keeping a change log): add items without source or analysed.by; a watch serves only album:, any other part refused once" - "dest must be one of the album's drives on this PC; default: the first holding it" - "20 requests/s, burst 100; then busy" - "the ticket is confirmed again when its last yes is older than 5 min; a no ends the connection" - "closed after 100 refused requests" errors: - message: "A guest may only view the album shared with them" - message: "Too many requests; try again in a second" - message: "That drive is not one of this album's" - message: "This ticket is not a guest's any more" examples: manual: "10-api-peer.md#frame-format" note: "byte lengths recomputed by PeerProtocolSchemaTests with the real SecureChannel and grant signer" capsRequest: plaintextJson: | {"op":"caps"} jsonBytes: 13 plaintextBytes: 14 lengthPrefixValue: 30 wireBytes: 34 layout: "00 00 00 1E | 30 bytes: AES-GCM(0x00 | {\"op\":\"caps\"}) 14 + tag 16" capsAnswer: note: "a PC with every host (fan-out queue, Google Drive service, album host, replication host)" plaintextJson: | {"ok":true,"putsmall":true,"dated":true,"jobs":true,"fanout":true,"resume":true,"e2e":true,"fetch":true,"placement":true,"gdrive":1,"read":3,"album":15,"replicate":2,"rearrange":3,"forms":1,"spread":2,"photoreq":0,"resend":1,"arrival":1,"remove":1,"move":1,"partial":1,"changes":0,"upload":1,"audit":1,"work-mark":0,"multidrive":2,"links":3,"vision":0,"analyze":0,"vision-worker":0,"vision-lease":0,"vision-coverage":0,"vision-audit":0,"vision-progress":0,"vision-fleet":0,"faces":0,"vision-select":0,"vision-search":0,"search-index":0,"vision-embed":0,"assistant-job":0,"video-copy":0,"geo":1} jsonBytes: 594 wireBytes: 615 handshake: note: "client ANNA-PC (instance 5f0c2a9e8b7d4c31a6e2f90d14b7c3a8) to server OFFICE-NAS (instance a07d4c1e9b2f4e6d8c3a5b7f9e1d2c4a)" escapes: "lengths without escapes: a '+' in a base64 nonce or MAC is sent as \\u002B (5 more bytes each)" clientHelloJson: "{\"v\":1,\"name\":\"ANNA-PC\",\"inst\":\"5f0c2a9e8b7d4c31a6e2f90d14b7c3a8\",\"nonce\":\"<44 base64 chars>\"}" clientHelloJsonBytes: 121 clientHelloWireBytes: 125 serverHelloJsonBytes: 124 serverHelloWireBytes: 128 macJson: "{\"mac\":\"<44 base64 chars>\"}" macJsonBytes: 54 macWireBytes: 58 totalClientToServer: 183 totalServerToClient: 186 replicationGrant: payloadJson: | {"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"} payloadBytes: 260 payloadBase64Chars: 348 signatureBytes: 64 signatureBase64Chars: 88 grantJsonBytesWithoutEscapes: 459 grantJsonNote: "{\"payload\":\"<348>\",\"sig\":\"<88>\"} = 23 + 348 + 88 = 459 bytes; each '+' in the base64 is sent as \\u002B (5 more bytes); this payload's base64 has none, a random signature's base64 usually has one or two" rearrangeGrant: payloadJson: | {"v":1,"kind":"spacebackup-rearrange","machine":"Annas-iPhone","primary":"ANNA-PC","from":[{"pc":"ANNA-PC","dest":"5B7E19A0C3D2"}],"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"} payloadBytes: 310 payloadBase64Chars: 416 signatureBytes: 64 signatureBase64Chars: 88 companyKey: passphrase: "SCHEMA-TEST-KEY-2026" fingerprint: "696C-C21C"