# SVM API

Interactive reference for the SlashInfra SVM API.

Source: https://slashinfra.com/docs/api-reference/svm
Last modified: 2026-11-30T16:36:19.000Z

Resource, request and plan limits are listed on [Limits](https://slashinfra.com/docs/reference/limits).

Run programs, read and write files, and open a terminal on one SVM. Each SVM has a host at `https://<id>.slashinfra.dev`. Send an API key with each request. The first request starts the SVM. A request also wakes an SVM that is stopped or paused. A preview host is `https://<port>-<id>.slashinfra.dev`. It sends requests to the TCP port in the SVM. The app keeps its own `Authorization` header, so send the API key in `X-Si-Authorization`. A `closed` port accepts organization members. An `authenticated` port also accepts an expiring preview link. A `public` port accepts anyone. Requests to a preview host go to the app on that port. Use the control API to create, list or delete an SVM and run its `start`, `stop` or `pause` action: [Create an SVM](https://slashinfra.com/docs/api-reference/control/svms#postSvms), [Delete an SVM](https://slashinfra.com/docs/api-reference/control/svms#deleteSvmsById).

## Authentication

Send the key as `Authorization: Bearer si_...` on an SVM host. On a preview host, send it as `X-Si-Authorization: Bearer si_...`.

`si login` saves a device key. The [dashboard](https://app.slashinfra.com/keys) creates an organization key and shows its secret once. A key starts with `si_` and has 43 base64url characters after the prefix.

## API responses

- `401`: no key, an invalid key, or a deleted key. The body is `unauthorized`, and the reply carries `WWW-Authenticate: Bearer`. 
- `404`: the host label is not an SVM id, no such SVM, an SVM that is being deleted, or an SVM of another organization. The body is `not_found` in each case. 
- `503`: the SVM could not be reached. The body is `the SVM could not be reached`.

Deletion and key revocation follow the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

## Bodies

Request bodies are raw bytes. `POST` uses the body as the program's standard input; `PUT` writes it as a file. Replies use `text/plain; charset=utf-8` by default. File replies use the type from the file extension. Arguments and settings go in the query string; the API does not accept JSON request bodies. Send `Accept: application/json` for JSON directory listings and errors. A directory is an array of `{name, type, size, mode, mtime}`. An error is `{error, code}`; see [Errors](https://slashinfra.com/docs/reference/errors). A file GET returns a weak `ETag` and `Last-Modified`. `If-None-Match` can return `304`; a `PUT` with `If-Match` returns `412` if the file changed. Every response includes `Cache-Control: private` and `Referrer-Policy: no-referrer`.

[Download OpenAPI specification](https://slashinfra.com/docs/svm.openapi.yaml) · Version 0.1.0

[Files](https://slashinfra.com/docs/api-reference/svm#tag-files)

Files and directories of one SVM.

[GETRead a path](https://slashinfra.com/docs/api-reference/svm#readPath)[PUTUpload a file](https://slashinfra.com/docs/api-reference/svm#uploadFile)[PATCHWrite at an offset](https://slashinfra.com/docs/api-reference/svm#writeAtOffset)

[Exec](https://slashinfra.com/docs/api-reference/svm#tag-exec)

Run a program in one SVM.

[POSTRun a program](https://slashinfra.com/docs/api-reference/svm#runProgram)

[Terminal](https://slashinfra.com/docs/api-reference/svm#tag-terminal)

The interactive terminals of one SVM.

[GETOpen a terminal](https://slashinfra.com/docs/api-reference/svm#openTerminal)

## Files

Files and directories of one SVM.

### Read a path

GET

/{path}

Returns a file or a directory listing, and wakes the SVM if it sleeps. A file above the [file listing limit](https://slashinfra.com/docs/reference/limits#files) gets `413` when the API reads it as a listing; read a part with `Range`, or copy it with `si cp`.

#### Authorization

`apiKey`

header`Authorization``Bearer <token>`

An API key on an SVM host: `si_` and 43 base64url characters, sent as `Authorization: Bearer si_...`; the [dashboard](https://app.slashinfra.com/keys) shows an organization key once, and a deleted key stops working after the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

#### Path Parameters

`path*`string

The path in the SVM, without the first `/` (`/` is the root); the API percent-decodes it, resolves `.` and `..`, and a trailing `/` names a directory.

#### Query Parameters

`watch?`boolean

`?watch` streams the changes of this path as Server-Sent Events for up to the plan's stream limit, each with `path` and `kind` (`created`, `modified`, `deleted` or `moved`); a directory watches its whole tree, changes to one path within 100 ms coalesce, and the stream keeps the SVM awake.

#### Header Parameters

`Range?`string

One byte range of a file: `bytes=10-19` (bytes 10 to 19), `bytes=90-` (byte 90 to the end) or `bytes=-5` (the last 5 bytes); any other form returns the whole file, and a range on a directory is ignored.

`If-None-Match?`string

A weak `ETag` from an earlier GET; when the file did not change, the answer is `304` with the same `ETag` and no content, and `*` matches any file.

`Accept?`"application/json"

`application/json` makes a directory listing a JSON array and an error a `{error, code}` body; any other value keeps the text listing.

Value in`"application/json"`

#### Response Body

The file, or the listing of a directory as `ls -la` does it, or a JSON array with `Accept: application/json`.

`response?`string

Example Request

```
curl -X GET 'https://6f1c0f0e8a.slashinfra.dev/string'
```

Example ResponseSchema

```
[  {    "name": "string",    "type": "file",    "size": 0,    "mode": 0,    "mtime": 0  }]
```

### Upload a file

PUT

/{path}

Writes the request body to a file atomically, within the [file transfer limit](https://slashinfra.com/docs/reference/limits#files). The parent directory must exist and a replaced file keeps its mode and owner; see [files and programs](https://slashinfra.com/docs/build/files-and-programs) for new-file modes and the executable bit.

#### Authorization

`apiKey`

header`Authorization``Bearer <token>`

An API key on an SVM host: `si_` and 43 base64url characters, sent as `Authorization: Bearer si_...`; the [dashboard](https://app.slashinfra.com/keys) shows an organization key once, and a deleted key stops working after the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

#### Path Parameters

`path*`string

The path of the file; its parent directory must exist.

#### Header Parameters

`If-None-Match?`"*"

`*` creates the file only if it does not exist, and an existing file gets `412`.

Value in`"*"`

`If-Match?`string

A weak `ETag` from an earlier GET; if the file changed, the API returns `412` and does not write, and `*` requires the file to exist.

`Content-Length?`integer

The size of the body in bytes; without it the API reads until the body ends, and a value above the [file transfer limit](https://slashinfra.com/docs/reference/limits#files) gets `413` before the body is read.

Range`0 <= value <= 99614720`

#### Request Body

The raw bytes of the file. The `Content-Type` of the request is ignored.

`body*`string`application/octet-stream`

#### Response Body

The file did not exist and is now written. The body is empty.

Example Request

```
curl -X PUT 'https://6f1c0f0e8a.slashinfra.dev/string' \  -H 'Content-Type: application/octet-stream' \  -d 'string'
```

Example Response

Empty

### Write at an offset

PATCH

/{path}

Writes the request body at a byte offset instead of replacing the file, and an append starts at the current size. Concurrent PATCH and PUT requests in one directory do not interleave, and an offset past the end of the file or the [file transfer limit](https://slashinfra.com/docs/reference/limits#files) returns `416`; PATCH never leaves a hole.

#### Authorization

`apiKey`

header`Authorization``Bearer <token>`

An API key on an SVM host: `si_` and 43 base64url characters, sent as `Authorization: Bearer si_...`; the [dashboard](https://app.slashinfra.com/keys) shows an organization key once, and a deleted key stops working after the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

#### Path Parameters

`path*`string

The file to write; it must exist, and a missing file gets `404`.

#### Header Parameters

`Content-Range*`string

`bytes <start>-*/*`, the byte offset of the first body byte; only this form is accepted, and a bounded range or a suffix gets `400`.

`Content-Length?`integer

The size of the body in bytes.

Range`0 <= value <= 99614720`

#### Request Body

The bytes to write at the offset.

`body*`string`application/octet-stream`

#### Response Body

The bytes are written. The body is empty.

Example Request

```
curl -X PATCH 'https://6f1c0f0e8a.slashinfra.dev/string' \  -H 'Content-Range: string' \  -H 'Content-Type: application/octet-stream' \  -d 'string'
```

Example Response

Empty

## Exec

Run a program in one SVM.

### Run a program

POST

/{path}

Runs the executable at `path` as a new process of `user`: the request body is its standard input, and the reply is its standard output and error together. A non-zero `X-Exit-Code` still answers `200`, the [command limits](https://slashinfra.com/docs/reference/limits#commands) set the timeouts and stream sizes, and [background work](https://slashinfra.com/docs/build/background-work) covers longer jobs.

#### Authorization

`apiKey`

header`Authorization``Bearer <token>`

An API key on an SVM host: `si_` and 43 base64url characters, sent as `Authorization: Bearer si_...`; the [dashboard](https://app.slashinfra.com/keys) shows an organization key once, and a deleted key stops working after the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

#### Path Parameters

`path*`string

The executable file, where a directory gets `405` and `/usr/bin/env` finds the program in `PATH`.

#### Query Parameters

`arg?`array<string>

One argument of the program, repeated for each in order; the query is form-encoded (`+` is a space and `%2B` a plus), with at most 512 KiB of arguments together and `400` for a NUL byte.

`cwd?`string

The working directory, an absolute path that exists and that `user` may enter, else `404` or `403`; the default is `/home/user`.

Default`"/home/user"`

`env?`array<string>

One environment variable of this process as `KEY=value`, repeated for each; the value is split at its first `=`. A name may appear once per request and follows the environment rules of the SVM (`400` otherwise, and for a NUL byte). It overrides the stored environment of the SVM for this process only and never changes it.

`timeout?`integer

The timeout of the program in seconds, from 1 to 30 with a default of 30: a value outside the range gets `400`, and at the timeout the API ends the process group and returns the output so far.

Range`1 <= value <= 30`

Default`30`

#### Request Body

The standard input of the program, within the [command input and output limits](https://slashinfra.com/docs/reference/limits#commands). Without `Content-Length` the API reads until the body ends. With `Accept: text/event-stream` the body streams under the [transfer rates](https://slashinfra.com/docs/reference/limits#files) and has no 1 MiB cap.

`body?`string`application/octet-stream`

#### Response Body

The output of the program. A non-zero `X-Exit-Code` is a failed program, not a failed request. A timeout sets `X-Timeout: 1` and `X-Exit-Code: 124`.

`response?`string

Example Request

```
curl -X POST 'https://6f1c0f0e8a.slashinfra.dev/string' \  -H 'Content-Type: application/octet-stream' \  -d 'string'
```

Example ResponseSchema

```
{  "exit": 0,  "stdout": "string",  "stderr": "string",  "truncated": true,  "timed_out": true}
```

## Terminal

The interactive terminals of one SVM.

### Open a terminal

GET

/bin/{program}

Opens a terminal of the SVM as `user` in `/home/user` over a WebSocket upgrade; the path picks the program, such as `bash` or an agent. Closing the connection ends the program unless it is an `hc` terminal, and a presence message counts as a person for the [sleep policy](https://slashinfra.com/docs/how/sleep-and-wake), and the [shell tool](https://slashinfra.com/docs/build/shell-tool) covers the protocol.

#### Authorization

`apiKey`

header`Authorization``Bearer <token>`

An API key on an SVM host: `si_` and 43 base64url characters, sent as `Authorization: Bearer si_...`; the [dashboard](https://app.slashinfra.com/keys) shows an organization key once, and a deleted key stops working after the [credential propagation period](https://slashinfra.com/docs/reference/limits#credentials).

#### Path Parameters

`program*`string

The terminal program. `bash` is a login shell. `zellij`, `tmux` and `herdr` are multiplexers and `hc` is the herdr-core API. `claude`, `codex` and `opencode` are coding agents that take their arguments from `arg`.

Value in`"bash"``"zellij"``"tmux"``"herdr"``"hc"``"claude"``"codex"``"opencode"`

#### Query Parameters

`arg?`array<string>

One argument of an agent program (`claude`, `codex` or `opencode`), repeated in order for up to 16 values; `arg` holds only the agent's own options and prompt, and each value is passed as one argument with the quoting that the agent's own parser needs.

Items`items <= 16`

#### Header Parameters

`Upgrade?`"websocket"

`websocket` opens the interactive terminal, and without this header the request returns the terminal page or the program file.

Value in`"websocket"`

#### Response Body

The protocol switches to WebSocket. Binary frames carry terminal input and output; a text frame with `{"cols":80,"rows":24}` resizes the terminal.

Example Request

```
curl -X GET 'https://6f1c0f0e8a.slashinfra.dev/bin/bash'
```

Example Response

Empty

GET

/{path}

Example Request

```
curl -X GET 'https://6f1c0f0e8a.slashinfra.dev/string'
```

```
[
{
"name": "string",
"type": "file",
"size": 0,
"mode": 0,
"mtime": 0
}
]
```

PUT

/{path}

Example Request

```
curl -X PUT 'https://6f1c0f0e8a.slashinfra.dev/string' \
-H 'Content-Type: application/octet-stream' \
-d 'string'
```

PATCH

/{path}

Example Request

```
curl -X PATCH 'https://6f1c0f0e8a.slashinfra.dev/string' \
-H 'Content-Range: string' \
-H 'Content-Type: application/octet-stream' \
-d 'string'
```

POST

/{path}

Example Request

```
curl -X POST 'https://6f1c0f0e8a.slashinfra.dev/string' \
-H 'Content-Type: application/octet-stream' \
-d 'string'
```

```
{
"exit": 0,
"stdout": "string",
"stderr": "string",
"truncated": true,
"timed_out": true
}
```

GET

/bin/{program}

Example Request

```
curl -X GET 'https://6f1c0f0e8a.slashinfra.dev/bin/bash'
```
