Skip to content

Files and programs over HTTP

You write a file to your VM, run a program over HTTP, and read the program’s exit code. Each step is one request.

  • An approved account. New accounts need approval first; the dashboard shows your status.
  • An API key from the API keys page. The dashboard shows the secret once, so copy it when it appears.
  • Python 3.12 with requests, or Node 22, for the Python and TypeScript tabs. The curl tab needs only curl.

The first request to a VM starts it, so the create request is the only setup.

Terminal window
export SI_API_KEY=si_...
curl -sS -X POST "https://api.slashinfra.com/svms" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"name":"files-example"}'
Output
{"id":"6f1c0f0e8a","generation":1,...}

Set VM to the id in the reply. The examples below use it.

Terminal window
export VM=6f1c0f0e8a

Send the file as the body of a PUT. The parent directory must exist. A new file has mode 0644, so it is not executable.

Terminal window
curl -sS -X PUT "https://$VM.slashinfra.dev/home/user/report.py" \
-H "Authorization: Bearer $SI_API_KEY" --data-binary @- <<'PY'
import sys
month = sys.stdin.read().strip()
print(f"report written for {month}")
PY

The reply is 201 for a new file and 204 for a replaced one. The body is empty.

POST the program’s input as the body. The path picks the executable. /usr/bin/env finds python3 in the PATH, so the file does not need the executable bit. Arguments go in the query, one arg each.

Terminal window
curl -sS -X POST "https://$VM.slashinfra.dev/usr/bin/env?arg=python3&arg=/home/user/report.py" \
-H "Authorization: Bearer $SI_API_KEY" --data-binary '2026-11'
Output
report written for 2026-11

Each request starts a new process as user in /home/user. A cd or export in one request does not carry into the next. Keep state in files.

A 200 means the request reached the VM. It does not mean the program succeeded. The program’s exit code is in the X-Exit-Code header.

Terminal window
curl -sS -i -X POST "https://$VM.slashinfra.dev/usr/bin/env?arg=python3&arg=/home/user/report.py" \
-H "Authorization: Bearer $SI_API_KEY" --data-binary '2026-11'
Output
HTTP/2 200
X-Exit-Code: 0
...

For output that takes a while, ask for an event stream with Accept: text/event-stream. The stream sends one stdout or stderr event for each chunk. It ends with one exit event that carries the code. A stream keeps the VM awake while it runs.

Terminal window
curl -sSN -X POST "https://$VM.slashinfra.dev/usr/bin/env?arg=python3&arg=/home/user/report.py" \
-H "Authorization: Bearer $SI_API_KEY" -H "Accept: text/event-stream" --data-binary '2026-12'
Output
event: stdout
data: "report written for 2026-12\n"
event: exit
data: {"code":0,"timed_out":false}

You should now see report written for 2026-11 in the reply to step 3. The header in step 4 reads X-Exit-Code: 0. The stream in step 5 ends with an exit event whose code is 0.

Symptom Cause Fix
401 unauthorized The key is missing, wrong or deleted. Set SI_API_KEY to a key from the API keys page.
404 not_found on any request The VM id is wrong, or the VM is deleted. Check VM against the id from step 1.
X-Exit-Code is not 0 with status 200 The program failed. The reply still has 200. Read the output of that request, fix the program and upload it again.

Scroll horizontally to see all columns.

Terminal window
curl -sS -i -X DELETE "https://api.slashinfra.com/svms/$VM" \
-H "Authorization: Bearer $SI_API_KEY"
Output
HTTP/2 204
  • Give an agent a shell: run these requests from an agent loop that keeps its files between calls.
  • Background work: run a command that takes longer than one request.
  • Sleep and wake: what the VM keeps while it sleeps between requests.
  • Files: every file operation, header and limit.