Skip to content

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:

Terminal window
si create --name files
Output
6f1c0f0e8a

Set VM to the id in the reply and SI_API_KEY to a key from API keys:

Terminal window
export VM=6f1c0f0e8a
export SI_API_KEY=si_...

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.

Terminal window
si cp notes.txt files:notes.txt
si exec files -- cat notes.txt
Output
first line
second line

Send 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:

Terminal window
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.txt
Output
HTTP/2 412
...

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.

Terminal window
si cp files:notes.txt -
Output
first line
second line

Range 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.

Terminal window
curl -sS -i "https://$VM.slashinfra.dev/home/user/notes.txt" \
-H "Authorization: Bearer $SI_API_KEY" -H "Range: bytes=0-4"
Output
HTTP/2 206
content-type: text/plain; charset=utf-8
content-length: 5
content-range: bytes 0-4/23
...
first

If-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.

Terminal window
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"
Output
HTTP/2 304
etag: W/"73-23-1795959288819621052"
last-modified: Sun, 29 Nov 2026 13:34:48 GMT
...

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.

Terminal window
si exec files -- sh -c 'mkdir -p logs && printf "started\n" > logs/job.log'
Terminal window
si exec files -- ls -la logs
Output
total 16
drwxr-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.log

A listing is capped at 16 MiB. A larger listing answers 413.

?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.

Terminal window
curl -sS -N "https://$VM.slashinfra.dev/home/user/logs/?watch" \
-H "Authorization: Bearer $SI_API_KEY"
Output
data: {"kind":"modified","path":"/home/user/logs/job.log"}
...

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:

Terminal window
si exec files -- sh -c 'printf "done\n" >> logs/job.log; cat logs/job.log'
Output
started
done

A body above 95 MiB answers 413, and a write that would pass 95 MiB answers 413 too.

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.

Terminal window
si exec files -- rm -rf notes.txt logs
si exec files -- ls notes.txt logs
Output
ls: cannot access 'notes.txt': No such file or directory
ls: cannot access 'logs': No such file or directory

To delete from HTTP, POST to /bin/rm with one arg for each argument; Files and programs over HTTP shows how POST runs a program.

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:

Terminal window
si cp report.txt files:report.txt
si exec files -- cat report.txt
Output
uploaded by si cp

Download one file:

Terminal window
si cp files:report.txt report-copy.txt
cat report-copy.txt
Output
uploaded by si cp

The tree samples use a local project folder with README.md and src/main.py.

Copy a tree up:

Terminal window
si cp -r project files:project
si exec files -- find project -type f | sort
Output
project/README.md
project/src/main.py

Copy a tree down:

Terminal window
si cp -r files:project project-copy
find project-copy -type f | sort
Output
project-copy/README.md
project-copy/src/main.py

Name 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.

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.

Every request body is raw bytes; the API accepts no JSON body. The path is in the URL, not a field.

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.

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.

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.

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.

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.

  • A file upload or download is at most 95 MiB (99,614,720 bytes). A larger upload answers 413; si cp refuses 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 0644 and belongs to user, 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 -r creates 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 exec with tar.
  • A file that user may not read or write answers 403; change its mode with si exec files -- chmod.
  • The VM API has no DELETE; delete with si exec or POST /bin/rm.

The full list is in Limits.