A VM serves its files at https://<id>.slashinfra.dev, its own API rather than the control API at https://api.slashinfra.com. You can upload, read, patch and watch them without a terminal; every request runs as your VM’s user, user, and the first one wakes a sleeping VM.
The samples use a VM named files. Create it once and keep the id:
si create --name files6f1c0f0e8aSet VM to the id in the reply and SI_API_KEY to a key from API keys:
export VM=6f1c0f0e8aexport SI_API_KEY=si_...Upload a file
Section titled “Upload a file”PUT writes the request body to one file. It answers 201 for a new file and 204 for a replaced one, and the body of the answer is empty. The parent folder must exist, because the API does not create it. A new file gets mode 0644 and belongs to user; a replaced file keeps its mode and owner. The write is atomic, so a reader sees the old file or the new one.
si cp writes one file. It prints nothing when the copy succeeds.
si cp notes.txt files:notes.txtsi exec files -- cat notes.txtfirst linesecond linecurl -sS -i -X PUT "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY" --data-binary @notes.txtHTTP/2 201content-type: text/plain; charset=utf-8content-length: 0...import os, requests
with open("notes.txt", "rb") as file: res = requests.put( f"https://{os.environ['VM']}.slashinfra.dev/home/user/notes.txt", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, data=file, )res.raise_for_status()print(res.status_code)201import { readFile } from 'node:fs/promises'
const body = await readFile('notes.txt')const res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/notes.txt`, { method: 'PUT', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` }, body,})if (!res.ok) throw new Error(await res.text())console.log(res.status)201Send the same request again to replace the file; the answer is 204. A Content-Type on the request is ignored, and the body is the file’s bytes. A body above 95 MiB answers 413.
If-None-Match: * creates only a missing file and answers 412 when the path exists. If-Match with the ETag of a read replaces only that version and answers 412 when the file changed. Use the ETag from your own read; this stale value is refused:
curl -sS -i -X PUT "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY" -H 'If-Match: W/"1-1-1"' \ --data-binary @notes.txtHTTP/2 412...Read a file
Section titled “Read a file”GET returns the file’s bytes. Content-Type comes from the file extension; without a known extension the API sends text/plain; charset=utf-8 for UTF-8 bytes and application/octet-stream otherwise. A 200 file reply carries a weak ETag, Last-Modified and Accept-Ranges: bytes.
si cp writes the file to standard output with -; it does not show the headers.
si cp files:notes.txt -first linesecond linecurl -sS -i "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY"HTTP/2 200content-type: text/plain; charset=utf-8content-length: 23etag: W/"73-23-1795959288819621052"accept-ranges: bytes...first linesecond lineimport os, requests
res = requests.get( f"https://{os.environ['VM']}.slashinfra.dev/home/user/notes.txt", headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},)res.raise_for_status()print(res.status_code, res.headers["ETag"])print(res.text, end="")200 W/"73-23-1795959288819621052"first linesecond lineconst res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/notes.txt`, { headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },})if (!res.ok) throw new Error(await res.text())console.log(res.status, res.headers.get('ETag'))process.stdout.write(await res.text())200 W/"73-23-1795959288819621052"first linesecond lineRange returns one part with 206 and Content-Range: bytes <first>-<last>/<size>. Use bytes=10-19, bytes=90- for the rest, or bytes=-5 for the last 5 bytes. Any other form returns the whole file, and a range on a folder is ignored.
curl -sS -i "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY" -H "Range: bytes=0-4"HTTP/2 206content-type: text/plain; charset=utf-8content-length: 5content-range: bytes 0-4/23...firstIf-None-Match with the ETag answers 304 with no body when the file did not change. The answer still carries the ETag and Last-Modified.
ETAG=$(curl -sS -D - -o /dev/null "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY" | awk -F': ' 'tolower($1)=="etag"{print $2}' | tr -d '\r')curl -sS -i "https://$VM.slashinfra.dev/home/user/notes.txt" \ -H "Authorization: Bearer $SI_API_KEY" -H "If-None-Match: $ETAG"HTTP/2 304etag: W/"73-23-1795959288819621052"last-modified: Sun, 29 Nov 2026 13:34:48 GMT...Read a folder
Section titled “Read a folder”GET a folder returns a listing. Without Accept, it is the text form of ls -la: a total line, then permissions, owner, group, size, date and name. With Accept: application/json, it is an array of {name, type, size, mode, mtime}. The type is file, dir, symlink or other; mode is the Unix permission bits as a decimal number, and mtime is seconds since the Unix epoch. A folder’s size is its own metadata size, not the total of its contents.
The API has no tar response. To copy a tree, use si cp -r, which builds a tar on the VM and extracts it on the other side.
Create the logs folder with one file for the next sections. The command prints nothing.
si exec files -- sh -c 'mkdir -p logs && printf "started\n" > logs/job.log'si exec files -- ls -la logstotal 16drwxr-xr-x 2 user user 4096 Nov 29 13:35 .drwxr-xr-x 1 user user 4096 Nov 29 13:35 ..-rw-r--r-- 1 user user 8 Nov 29 13:35 job.logcurl -sS "https://$VM.slashinfra.dev/home/user/logs/" \ -H "Authorization: Bearer $SI_API_KEY"total 16drwxr-xr-x 2 user user 4096 Nov 29 13:35 .drwxr-xr-x 1 user user 4096 Nov 29 13:35 ..-rw-r--r-- 1 user user 8 Nov 29 13:35 job.logimport os, requests
res = requests.get( f"https://{os.environ['VM']}.slashinfra.dev/home/user/logs/", headers={ "Authorization": f"Bearer {os.environ['SI_API_KEY']}", "Accept": "application/json", },)res.raise_for_status()for entry in res.json(): print(entry["name"], entry["type"], entry["size"], entry["mode"])job.log file 8 420const res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/logs/`, { headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, Accept: 'application/json', },})if (!res.ok) throw new Error(await res.text())const entries = (await res.json()) as { name: string; type: string; size: number; mode: number }[]for (const entry of entries) console.log(entry.name, entry.type, entry.size, entry.mode)job.log file 8 420A listing is capped at 16 MiB. A larger listing answers 413.
Watch a folder
Section titled “Watch a folder”?watch streams changes under a path as Server-Sent Events. A folder watches its whole tree, a file path watches that file, and changes to one path within 100 ms coalesce. Each event is data: {"path":"/home/user/logs/job.log","kind":"modified"}; kind is created, modified, deleted or moved. The stream stays open for up to one hour, the plan’s stream limit, and keeps the VM awake while it runs.
Run the watch in one terminal, then change a file in the folder from another.
curl -sS -N "https://$VM.slashinfra.dev/home/user/logs/?watch" \ -H "Authorization: Bearer $SI_API_KEY"data: {"kind":"modified","path":"/home/user/logs/job.log"}
...import os, requests
with requests.get( f"https://{os.environ['VM']}.slashinfra.dev/home/user/logs/", params={"watch": ""}, headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"}, stream=True, timeout=10,) as res: res.raise_for_status() for line in res.iter_lines(decode_unicode=True): if line: print(line) breakdata: {"kind":"modified","path":"/home/user/logs/job.log"}const res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/logs/?watch`, { headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` }, signal: AbortSignal.timeout(10_000),})if (!res.ok || !res.body) throw new Error(await res.text())const reader = res.body.getReader()const decoder = new TextDecoder()for (;;) { const { done, value } = await reader.read() if (done) break const text = decoder.decode(value, { stream: true }) if (text.includes('data: ')) { process.stdout.write(text) await reader.cancel() break }}data: {"kind":"modified","path":"/home/user/logs/job.log"}Write at an offset
Section titled “Write at an offset”PATCH writes the body at a byte offset instead of replacing the file. The file must exist. Content-Range must be bytes <start>-*/*; an append starts at the current size. The API never leaves a hole: an offset past the end answers 416 and nothing is written. Concurrent PATCH and PUT requests in one folder do not interleave.
The CLI has no offset write. Append with si exec:
si exec files -- sh -c 'printf "done\n" >> logs/job.log; cat logs/job.log'starteddonecurl -sS -i -X PATCH "https://$VM.slashinfra.dev/home/user/logs/job.log" \ -H "Authorization: Bearer $SI_API_KEY" -H "Content-Range: bytes 8-*/*" \ --data-binary 'done'HTTP/2 204...import os, requests
res = requests.patch( f"https://{os.environ['VM']}.slashinfra.dev/home/user/logs/job.log", headers={ "Authorization": f"Bearer {os.environ['SI_API_KEY']}", "Content-Range": "bytes 8-*/*", }, data=b"done\n",)res.raise_for_status()print(res.status_code)204const res = await fetch(`https://${process.env.VM!}.slashinfra.dev/home/user/logs/job.log`, { method: 'PATCH', headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}`, 'Content-Range': 'bytes 8-*/*', }, body: 'done\n',})if (!res.ok) throw new Error(await res.text())console.log(res.status)204A body above 95 MiB answers 413, and a write that would pass 95 MiB answers 413 too.
Delete a file or folder
Section titled “Delete a file or folder”The VM API has no DELETE. A DELETE request answers 405 method_not_allowed with an SVM is deleted through the control plane, not on its own host. Delete files and folders with si exec, which starts in /home/user.
si exec files -- rm -rf notes.txt logssi exec files -- ls notes.txt logsls: cannot access 'notes.txt': No such file or directoryls: cannot access 'logs': No such file or directoryTo delete from HTTP, POST to /bin/rm with one arg for each argument; Files and programs over HTTP shows how POST runs a program.
Copy between your laptop and the VM
Section titled “Copy between your laptop and the VM”si cp copies one file in either direction and prints nothing when it succeeds. The remote side is <svm>:<path>; a relative path is from /home/user, and - is standard input or output. -r copies a folder tree, and --project names a project other than default.
Upload one file:
si cp report.txt files:report.txtsi exec files -- cat report.txtuploaded by si cpDownload one file:
si cp files:report.txt report-copy.txtcat report-copy.txtuploaded by si cpThe tree samples use a local project folder with README.md and src/main.py.
Copy a tree up:
si cp -r project files:projectsi exec files -- find project -type f | sortproject/README.mdproject/src/main.pyCopy a tree down:
si cp -r files:project project-copyfind project-copy -type f | sortproject-copy/README.mdproject-copy/src/main.pyName the destination file for one file; -r creates the destination folder. A tree copy is one tar archive, so a tree whose archive is above 95 MiB fails.
Who can read and write files
Section titled “Who can read and write files”A key must belong to the VM’s organization and include its project. The VM host checks the key and the project scope; it does not check a key action on a file request. A key that reaches the VM can read and write every file user can.
A grant is a token for one set of methods and paths. The gate checks the method and decoded path before the request wakes the VM, and the guest resolves paths beneath the grant root, so a symlink cannot leave it. Creating a grant takes svm:write. Send the token as Authorization: Bearer <token>. See Grants.
Options
Section titled “Options”Every request body is raw bytes; the API accepts no JSON body. The path is in the URL, not a field.
Upload
Section titled “Upload”| Field | Type | Default | Allowed values | What it changes |
|---|---|---|---|---|
path (path) |
string | Required | At most 4096 bytes, no NUL byte; / is the root, and . and .. resolve |
The file to write. Its parent folder must exist. |
If-None-Match |
string | Empty | * |
Creates the file only when the path is free; an existing file answers 412. |
If-Match |
string | Empty | A weak ETag, or * |
Replaces only that version; a changed or missing file answers 412. * requires the file. |
Content-Length |
integer | Computed from the body | 0 to 99614720 | The body size. A value above 95 MiB answers 413 before the body is read. |
Scroll horizontally to see all columns.
Read and watch
Section titled “Read and watch”| Field | Type | Default | Allowed values | What it changes |
|---|---|---|---|---|
path (path) |
string | Required | At most 4096 bytes, no NUL byte; a trailing / names a folder |
The file or folder to read. |
Range |
string | Empty | bytes=10-19, bytes=90-, bytes=-5 |
One byte range. Any other form returns the whole file, and a range on a folder is ignored. |
If-None-Match |
string | Empty | A weak ETag, or * |
Answers 304 with no body when the file did not change. |
Accept |
string | Text listing | application/json, or any other value for the text listing |
A folder answers a JSON array instead of the text listing; an error becomes {error, code}. |
watch (query) |
boolean | false |
?watch in the query |
Streams changes as Server-Sent Events instead of returning the path. |
Scroll horizontally to see all columns.
Write at an offset
Section titled “Write at an offset”| Field | Type | Default | Allowed values | What it changes |
|---|---|---|---|---|
path (path) |
string | Required | At most 4096 bytes, no NUL byte | The file to write. It must exist. |
Content-Range |
string | Required | bytes <start>-*/* |
The byte offset of the first body byte. A bounded range or a suffix answers 400. |
Content-Length |
integer | Computed from the body | 0 to 99614720 | The body size. |
Scroll horizontally to see all columns.
Errors
Section titled “Errors”| Code | When | Fix |
|---|---|---|
bad_request |
The path has a NUL byte, or Content-Range has another form. |
Remove the NUL byte; send bytes <start>-*/*. |
not_found |
The file, folder or parent folder does not exist, or the host is not a VM. | Check the path with si exec files -- ls -la <dir>, and VM with si ls. |
method_not_allowed |
The request uses DELETE or HEAD. |
Use GET, PUT, PATCH or POST; delete with si exec. |
conflict |
PUT or PATCH names a folder. |
Use a file path. |
precondition_failed |
If-None-Match or If-Match did not hold. |
Read the file again and use its new ETag; a create-only write needs a path that does not exist. |
payload_too_large |
The body is above 95 MiB, or a listing is above 16 MiB. | Send less, split the file, read a part with Range, or copy with si cp. |
range_not_satisfiable |
A Range starts at or past the end, or a PATCH offset is past the end. |
Read Content-Range: bytes */<size> and start at or before the end. |
timeout |
An upload or body stalled for more than 30 seconds. | Retry on a stable connection. |
file_read_failed |
The VM could not read the file’s data. | Retry; if it repeats, copy the file with si cp. |
disk_full |
The VM’s disk is full. | Remove files with si exec files -- rm. |
Scroll horizontally to see all columns.
Errors that any request can return are in the error catalog.
Permissions
Section titled “Permissions”| Operation | Who can | Key action |
|---|---|---|
| Read a file or folder | Any member with a key that includes the VM’s project | None |
| Upload or replace a file | Any member with a key that includes the VM’s project | None |
| Write at an offset | Any member with a key that includes the VM’s project | None |
| Watch a file or folder | Any member with a key that includes the VM’s project | None |
| Copy a file or tree | Any member with a key that includes the VM’s project | None |
| Create a grant | Any member | svm:write |
Scroll horizontally to see all columns.
Limits
Section titled “Limits”- A file upload or download is at most 95 MiB (99,614,720 bytes). A larger upload answers
413;si cprefuses it before sending. - A folder listing is at most 16 MiB. A larger listing answers
413. - A path is at most 4096 bytes and has no NUL byte. With a grant, the path and the grant scope share the 4096 bytes.
- A new file gets mode
0644and belongs touser, your VM’s user. A replaced file keeps its mode and owner. - A stalled transfer ends after 30 seconds. The transfer rate is 16 MiB/s per VM and 32 MiB/s per client address.
- A file request wakes a sleeping VM. A watch keeps it awake until the stream ends, for up to one hour. See Sleep and wake.
- A single file write does not create parent folders.
si cp -rcreates the destination folder for a tree. - A tree copy is one tar archive, so a tree whose archive is above 95 MiB fails. Split it or use
si execwithtar. - A file that
usermay not read or write answers403; change its mode withsi exec files -- chmod. - The VM API has no
DELETE; delete withsi execorPOST /bin/rm.
The full list is in Limits.
- Files and programs over HTTP: run a program with the file you uploaded.
- Grants: give another service one method and path without a key.
- Sleep and wake: what a file request wakes and how long a watch holds it.