> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# boxd API reference

> API reference for the boxd plugin in Corsair: every `boxd.api.*` operation with its input and output types, taken from the plugin's Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Checkpoints

### create

`checkpoints.create`

Save a running machine (memory and disk) as a named checkpoint, e.g. before a risky change; the machine keeps running. checkpoints.restore puts the machine back to it. Waits until it is "ready" unless waitUntilReady is false.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.checkpoints.create({ machineId: 'ci-runner', name: 'before-migration' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | Yes | Checkpoint name, unique per machine. |
| `waitUntilReady` | `boolean` | No | Wait until the checkpoint is "ready" (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for "ready", in ms (default 300000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `string` | Yes | "pending" while it is saved, then "ready" or "failed". |
| `sizeBytes` | `number \| null` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `createdBy` | `string \| null` | Yes | — |
| `available` | `boolean \| null` | Yes | Whether checkpoints.restore can use it right now. |

***

### delete

`checkpoints.delete`

Delete a checkpoint of a machine. The machine is not affected.

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.boxd.api.checkpoints.delete({ machineId: 'ci-runner', name: 'before-migration' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | Yes | Checkpoint name, unique per machine. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `deleted` | `true` | Yes | — |
| `machineId` | `string` | Yes | — |
| `name` | `string` | Yes | — |

***

### list

`checkpoints.list`

List a machine's checkpoints and whether each can be restored now.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.checkpoints.list({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `checkpoints` | `object[]` | Yes | — |

> [accordion] checkpoints full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   status: string,
>   sizeBytes: number | null,
>   createdAt: string | null,
>   createdBy: string | null,
>   available: boolean | null
> }[]
> ```

***

### restore

`checkpoints.restore`

Put a machine back to a "ready" checkpoint: it reboots into the saved memory and disk, and everything since the checkpoint is lost. Returns once the machine runs again.

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.boxd.api.checkpoints.restore({ machineId: 'ci-runner', name: 'before-migration' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | Yes | Checkpoint name, unique per machine. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `restored` | `true` | Yes | — |
| `machineId` | `string` | Yes | — |
| `name` | `string` | Yes | — |

***

## Files

### download

`files.download`

Read a file from a machine, as UTF-8 text or base64 for binary files.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.files.download({ machineId: 'ci-runner', path: '/home/boxd/app/report.json' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `encoding` | `utf8 \| base64` | No | "utf8" for text, "base64" for binary content. Defaults to "utf8". |
| `maxBytes` | `number` | No | Fail with 413 instead of returning a file larger than this (default 5000000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `path` | `string` | Yes | — |
| `encoding` | `utf8 \| base64` | Yes | — |
| `content` | `string` | Yes | — |
| `size` | `number` | Yes | — |

***

### list

`files.list`

List a directory on a machine (not recursive).

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.files.list({ machineId: 'ci-runner', path: '/home/boxd/app' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `limit` | `number` | No | Most entries to return (1-10000, default 1000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `entries` | `object[]` | Yes | — |
| `truncated` | `boolean` | Yes | True when the directory has more entries than `limit`. |

> [accordion] entries full type
>
> ```ts theme={null}
> {
>   name: string,
>   path: string,
>   type: string,
>   isDir: boolean,
>   size: number,
>   mode: number,
>   modifiedAt: string | null,
>   symlinkTarget: string | null
> }[]
> ```

***

### makeDirectory

`files.makeDirectory`

Create a directory on a machine, with any missing parents. An existing directory is fine.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.files.makeDirectory({ machineId: 'ci-runner', path: '/home/boxd/app/out' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `path` | `string` | Yes | — |
| `created` | `true` | Yes | — |

***

### remove

`files.remove`

Delete a file, or a directory with `recursive`. 404 if the path does not exist.

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.boxd.api.files.remove({ machineId: 'ci-runner', path: '/home/boxd/app/out', recursive: true });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `recursive` | `boolean` | No | Delete a directory and everything in it. Without it a directory fails with 400. Defaults to false. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `path` | `string` | Yes | — |
| `removed` | `true` | Yes | — |

***

### stat

`files.stat`

Get the type, size, mode and modification time of a path on a machine. 404 if it does not exist.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.files.stat({ machineId: 'ci-runner', path: '/home/boxd/app/report.json' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | — |
| `path` | `string` | Yes | — |
| `type` | `string` | Yes | "file", "directory", "symlink", or another file type. |
| `isDir` | `boolean` | Yes | A directory, or a symlink to one. |
| `size` | `number` | Yes | Size in bytes. |
| `mode` | `number` | Yes | Permission bits, e.g. 420 for 0644. |
| `modifiedAt` | `string \| null` | Yes | — |
| `symlinkTarget` | `string \| null` | Yes | — |

***

### upload

`files.upload`

Write a file on a machine, replacing any file at that path. Missing parent directories are created.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.files.upload({
	machineId: 'ci-runner',
	path: '/home/boxd/app/run.sh',
	content: '#!/bin/sh
echo hi
',
	mode: 493,
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `path` | `string` | Yes | Absolute path on the machine, e.g. /home/boxd/app/main.py. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `content` | `string` | Yes | File content: text, or padded base64 with encoding "base64". |
| `encoding` | `utf8 \| base64` | No | "utf8" for text, "base64" for binary content. Defaults to "utf8". |
| `mode` | `number` | No | Permission bits for the file, e.g. 493 (0755) for a script. A new file gets 420 (0644) by default; an existing file keeps its mode unless this is set. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | — |
| `path` | `string` | Yes | — |
| `type` | `string` | Yes | "file", "directory", "symlink", or another file type. |
| `isDir` | `boolean` | Yes | A directory, or a symlink to one. |
| `size` | `number` | Yes | Size in bytes. |
| `mode` | `number` | Yes | Permission bits, e.g. 420 for 0644. |
| `modifiedAt` | `string \| null` | Yes | — |
| `symlinkTarget` | `string \| null` | Yes | — |

***

## Machines

### create

`machines.create`

Create a machine: a fresh Ubuntu 24.04 VM (user boxd with sudo, Docker, Node, Python, Go, git), or a copy of a snapshot with `fromSnapshot`. It runs, and bills, until it is stopped, hibernated or deleted. Isolated by default.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.create({
	name: 'ci-runner',
	size: '4x16',
	labels: { env: 'ci' },
	autoSuspendTimeout: 600,
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | No | Machine name, unique per owner; it is also the subdomain of its URL. Generated when omitted. |
| `org` | `string` | No | Org name or id. Defaults to the plugin option, else the API key's own org. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `fromSnapshot` | `string` | No | Snapshot name or id to restore: disk, memory and running processes as they were saved. |
| `snapshotVersion` | `number` | No | A version the snapshot keeps, instead of its current one. Only with fromSnapshot. |
| `size` | `1x4 \| 2x8 \| 4x16 \| 8x32` | No | Machine size as vCPU x GiB of memory. Defaults to the org's default size (2x8 unless the org changed it), up to the org's quota. |
| `labels` | `Record<string, string>` | No | Labels (key=value metadata) for grouping and finding machines, e.g. \{"env": "ci"}. Keys are 1-63 characters of a-z 0-9 . \_ / -. |
| `isolated` | `boolean` | No | Isolate the machine (default true): it joins no network with the org's other machines and holds no boxd credentials, so code it runs can't reach them. Can't be turned off later. With fromSnapshot, true (the default) isolates the restored machine even if the snapshot was not; false keeps the snapshot's own setting, since a restore can add isolation but not remove it. |
| `autoSuspendTimeout` | `number` | No | Seconds without network traffic before the machine goes to standby (0 is never). Standby wakes on the next request. |
| `waitUntilReady` | `boolean` | No | Wait until the machine is running and answers a command before returning (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for the machine to be ready, in ms (default 90000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### delete

`machines.delete`

Delete a machine for good: its disk, memory and processes are gone. Its snapshots stay.

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.boxd.api.machines.delete({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `deleted` | `true` | Yes | — |
| `machineId` | `string` | Yes | — |

***

### exec

`machines.exec`

Run a command on a machine as user boxd and wait for it: returns the exit code, stdout and stderr. Pass a shell line ("cd app && npm test") or an argv array. A standby or hibernated machine wakes by itself; a stopped one needs machines.start first (409 otherwise). stdin is closed.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.exec({
	machineId: 'ci-runner',
	command: ['python3', '-c', 'import sys; print(sys.version)'],
	env: { CI: '1' },
	cwd: '/home/boxd',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `command` | `string \| string[]` | Yes | A shell command line, or program and arguments (quoted for you), e.g. \["python3", "-c", "print(1)"]. |
| `env` | `Record<string, string>` | No | Environment variables for this command. Names must be shell variable names. |
| `cwd` | `string` | No | Working directory (default /home/boxd). The command fails with exit code 2 if it does not exist. |
| `timeoutMs` | `number` | No | Kill the command (its whole process group) after this long, in ms: default 300000 (5 minutes), at most 1800000. Fails with 504. |
| `maxOutputBytes` | `number` | No | Keep at most this many bytes of stdout and of stderr (default 1000000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `exitCode` | `number` | Yes | — |
| `stdout` | `string` | Yes | — |
| `stderr` | `string` | Yes | — |
| `stdoutTruncated` | `boolean` | Yes | — |
| `stderrTruncated` | `boolean` | Yes | — |

***

### fork

`machines.fork`

Fork a running machine: a new machine with a copy of its disk, memory and running processes. The fork keeps the source's labels (merged with `labels`) and its isolation.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.fork({
	machineId: 'ci-runner',
	name: 'ci-runner-try-2',
	labels: { attempt: '2' },
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | No | Name for the fork. Generated when omitted. |
| `labels` | `Record<string, string>` | No | Labels merged over the ones the fork inherits from the source. |
| `isolated` | `boolean` | No | Isolate the fork even if the source is not. A fork of an isolated machine is always isolated. |
| `waitUntilReady` | `boolean` | No | Wait until the machine is running and answers a command before returning (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for the machine to be ready, in ms (default 90000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### get

`machines.get`

Get one machine by id or name: status, size, region, labels, URL and where it came from.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.machines.get({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### hibernate

`machines.hibernate`

Hibernate a running or standby machine: memory and running processes go to disk and it stops using compute. machines.wake, machines.exec or a request to its URL bring it back as it was. The status can read "suspended" for a moment before "hibernated".

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.machines.hibernate({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### list

`machines.list`

List the org's machines in one region, optionally only those with given labels.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.machines.list({
	labels: { env: 'ci' },
	region: 'all',
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `org` | `string` | No | Org name or id. Defaults to the plugin option, else the API key's own org. |
| `region` | `string` | No | Region to list ("fra", "nyc", ...), or "all" for every region. Defaults to the plugin option, else the region the API serves. |
| `labels` | `Record<string, string>` | No | Only machines with every one of these labels, e.g. \{"env": "ci"}. |
| `limit` | `number` | No | Most machines to return (1-1000, default 100). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `machines` | `object[]` | Yes | — |
| `truncated` | `boolean` | Yes | True when there were more machines than `limit`. |
| `elsewhere` | `object[]` | Yes | How many of the org's machines are in each other region. |
| `unavailable` | `string[]` | Yes | Regions that could not be reached for an "all" listing; their items are missing. |

> [accordion] machines full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   status: pending | starting | running | suspended | hibernated | stopped | failed | destroyed | migrating | string,
>   region: string | null,
>   org: {
>     id: string,
>     name: string
>   } | null,
>   shared: boolean,
>   isolated: boolean,
>   networks: string[],
>   labels: Record<string, string>,
>   vcpu: number,
>   memoryBytes: number,
>   diskBytes: number,
>   url: string,
>   sshPort: number | null,
>   botProtection: string | null,
>   imageRef: string,
>   source: {
>     kind: string,
>     name: string,
>     id: string | null,
>     version: number | null
>   } | null,
>   idle: {
>     suspendAfter: number,
>     hibernateAfter: number
>   },
>   createdAt: string | null,
>   hibernatedAt: string | null,
>   deleteAt: string | null,
>   bootTimeMs: number | null
> }[]
> ```

> [accordion] elsewhere full type
>
> ```ts theme={null}
> {
>   region: string,
>   count: number
> }[]
> ```

***

### pause

`machines.pause`

Put a running machine in standby: memory stays in place and it resumes in about a millisecond, by itself on the next request or with machines.resume.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.machines.pause({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |
| `suspendUs` | `number` | Yes | How long the freeze took, in µs. |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### resume

`machines.resume`

Resume a machine in standby (see machines.pause). Fails with 409 if it is not in standby.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.resume({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |
| `resumeUs` | `number` | Yes | How long the thaw took, in µs. |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### start

`machines.start`

Boot a stopped machine (a cold boot: the disk is kept, memory is not). Does nothing to a running one.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.start({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `waitUntilReady` | `boolean` | No | Wait until the machine is running and answers a command before returning (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for the machine to be ready, in ms (default 90000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### stop

`machines.stop`

Shut a machine down. The disk is kept; memory and running processes are lost. machines.start boots it again. To keep processes, use machines.hibernate.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.stop({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### updateLabels

`machines.updateLabels`

Add, change or remove a machine's labels in one change. Returns the labels now in effect.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.machines.updateLabels({
	machineId: 'ci-runner',
	set: { env: 'staging' },
	remove: ['attempt'],
});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `set` | `Record<string, string>` | No | Labels to add or overwrite. |
| `remove` | `string[]` | No | Label keys to remove. A key the machine lacks is fine. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |

***

### waitUntilReady

`machines.waitUntilReady`

Wait until a machine is running and answers a command, e.g. after create or fork with waitUntilReady false.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.machines.waitUntilReady({ machineId: 'ci-runner', timeoutMs: 60000 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `timeoutMs` | `number` | No | How long to wait for the machine to be ready, in ms (default 90000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

### wake

`machines.wake`

Wake a hibernated machine with its memory and processes as they were. Does nothing to a running one.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.machines.wake({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `waitUntilReady` | `boolean` | No | Wait until the machine is running and answers a command before returning (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for the machine to be ready, in ms (default 90000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `status` | `pending \| starting \| running \| suspended \| hibernated \| stopped \| failed \| destroyed \| migrating \| string` | Yes | "running", "suspended" (standby, wakes on the next request), "hibernated" (on disk, wakes on exec or wake), "stopped" (needs start), "pending", "starting", ... |
| `region` | `string \| null` | Yes | — |
| `org` | `object \| null` | Yes | — |
| `shared` | `boolean` | Yes | Whether the org's members can see and reach the machine. |
| `isolated` | `boolean` | Yes | Isolated machines join no default network and hold no boxd credentials of their own. |
| `networks` | `string[]` | Yes | — |
| `labels` | `Record<string, string>` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `diskBytes` | `number` | Yes | — |
| `url` | `string` | Yes | Public HTTPS URL, forwarded to the port the machine serves on (8000 by default). |
| `sshPort` | `number \| null` | Yes | — |
| `botProtection` | `string \| null` | Yes | "on" (a browser check before every request to the default URL, so API clients and webhooks are stopped; use proxies.create for those), "sleep\_only" (only a request that would wake the machine is checked) or "off". |
| `imageRef` | `string` | Yes | — |
| `source` | `object \| null` | Yes | What the machine was forked or restored from; null for a fresh machine. |
| `idle` | `object` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `hibernatedAt` | `string \| null` | Yes | — |
| `deleteAt` | `string \| null` | Yes | When boxd deletes the machine by itself; null for never. |
| `bootTimeMs` | `number \| null` | Yes | — |

> [accordion] org full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string
> } | null
> ```

> [accordion] source full type
>
> ```ts theme={null}
> {
>   kind: string,
>   name: string,
>   id: string | null,
>   version: number | null
> } | null
> ```

> [accordion] idle full type
>
> ```ts theme={null}
> {
>   suspendAfter: number,
>   hibernateAfter: number
> }
> ```

***

## Ports

### expose

`ports.expose`

Forward a raw TCP or UDP port of a machine (a database, SSH-like or game server, anything not HTTP) to a public port on the internet; at most 3 per machine. For HTTP use proxies.create. Exposing the same machine port again keeps its public port and changes only the protocol.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.ports.expose({ machineId: 'ci-runner', port: 5432, protocol: 'tcp' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `port` | `number` | Yes | Port in the machine. |
| `protocol` | `tcp \| udp \| both` | No | "tcp" (default), "udp" or "both" on one public port. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | — |
| `machineName` | `string` | Yes | — |
| `host` | `string` | Yes | Public host name; connect to host:publicPort. |
| `publicPort` | `number` | Yes | — |
| `machinePort` | `number` | Yes | — |
| `protocol` | `string` | Yes | "tcp", "udp" or "both". |

***

### list

`ports.list`

List raw TCP/UDP port forwards: one machine's, or every machine's when machineId is omitted.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.ports.list({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | No | Machine id or name; omit for every machine. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `ports` | `object[]` | Yes | — |

> [accordion] ports full type
>
> ```ts theme={null}
> {
>   machineId: string,
>   machineName: string,
>   host: string,
>   publicPort: number,
>   machinePort: number,
>   protocol: string
> }[]
> ```

***

### unexpose

`ports.unexpose`

Remove a raw port forward and free its public port; exposing it again may get another public port. Returns the forward that was removed.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.ports.unexpose({ machineId: 'ci-runner', port: 5432 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `port` | `number` | Yes | Port in the machine, as given to ports.expose. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | — |
| `machineName` | `string` | Yes | — |
| `host` | `string` | Yes | Public host name; connect to host:publicPort. |
| `publicPort` | `number` | Yes | — |
| `machinePort` | `number` | Yes | — |
| `protocol` | `string` | Yes | "tcp", "udp" or "both". |

***

## Proxies

### create

`proxies.create`

Publish a port of a machine on its own public HTTPS URL, https\://\<name>.\<machine>.boxd.sh, e.g. an API next to the app on the default route. Anyone with the URL can reach it: unlike the default route, a named route has no bot protection, so webhooks and API clients get through. A new route answers once its TLS certificate is issued, about 15 seconds.

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.proxies.create({ machineId: 'ci-runner', name: 'api', port: 3001 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | Yes | Route name, a subdomain label: lowercase letters, digits and hyphens, not starting or ending with a hyphen. |
| `port` | `number` | Yes | Port in the machine to forward to. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string \| null` | Yes | Route name; null for the machine's default route. |
| `machineId` | `string` | Yes | — |
| `machineName` | `string \| null` | Yes | — |
| `domain` | `string \| null` | Yes | null if the route was made but the listing did not show it yet. |
| `url` | `string \| null` | Yes | — |
| `port` | `number` | Yes | Port in the machine the route forwards to. |
| `portMode` | `string \| null` | Yes | — |
| `isDefault` | `boolean` | Yes | — |

***

### delete

`proxies.delete`

Remove a named HTTPS route from a machine. The default route stays; the port keeps running in the machine.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.proxies.delete({ machineId: 'ci-runner', name: 'api' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `name` | `string` | Yes | Route name, a subdomain label: lowercase letters, digits and hyphens, not starting or ending with a hyphen. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `deleted` | `true` | Yes | — |
| `machineId` | `string` | Yes | — |
| `name` | `string` | Yes | — |

***

### list

`proxies.list`

List a machine's HTTPS routes: its default route (https\://\<machine>.boxd.sh) and every named one, with the port each forwards to.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.proxies.list({ machineId: 'ci-runner' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `proxies` | `object[]` | Yes | — |

> [accordion] proxies full type
>
> ```ts theme={null}
> {
>   name: string | null,
>   machineId: string,
>   machineName: string,
>   domain: string,
>   url: string,
>   port: number,
>   portMode: string,
>   isDefault: boolean
> }[]
> ```

***

### setPort

`proxies.setPort`

Point a route at another port in the machine. Without `name` it changes the default route, which also takes "auto": boxd then follows the port the app listens on (80, 443, 8080, 8000, 3000, 5000, 5173).

**Risk:** `write`

```ts theme={null}
await corsair.boxd.api.proxies.setPort({ machineId: 'ci-runner', port: 'auto' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `port` | `number \| auto` | Yes | Port in the machine, or "auto" (default route only). |
| `name` | `string` | No | Named route to change; omit for the default route. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `proxies` | `object[]` | Yes | — |

> [accordion] proxies full type
>
> ```ts theme={null}
> {
>   name: string | null,
>   machineId: string,
>   machineName: string,
>   domain: string,
>   url: string,
>   port: number,
>   portMode: string,
>   isDefault: boolean
> }[]
> ```

***

## Snapshots

### create

`snapshots.create`

Save a running machine's disk and memory as a named snapshot; the machine keeps running. Saving over an existing name makes a new version that new machines get from then on, and the org keeps only its newest versions, so an old one can be dropped. machines.create with fromSnapshot makes new machines from it.

**Risk:** `destructive`

```ts theme={null}
await corsair.boxd.api.snapshots.create({ machineId: 'ci-runner', name: 'ci-base' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `machineId` | `string` | Yes | Machine id, as returned by machines.create or machines.list. A machine name works too. |
| `name` | `string` | Yes | Snapshot name, unique in the org. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |
| `waitUntilReady` | `boolean` | No | Wait until the snapshot is "ready" before returning (default true). |
| `readyTimeoutMs` | `number` | No | How long to wait for "ready", in ms (default 300000). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `version` | `number` | Yes | The version this save made. |
| `status` | `string` | Yes | "pending" while it is being saved, then "ready" (or "failed"). |
| `storage` | `string \| null` | Yes | "local" when machines can be created from it; null while this version is not listed yet. |
| `sizeBytes` | `number \| null` | Yes | Size of this version; null while it is not listed yet. |
| `vcpu` | `number \| null` | Yes | — |
| `memoryBytes` | `number \| null` | Yes | — |
| `region` | `string \| null` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `updatedAt` | `string \| null` | Yes | When this version was saved; null while it is not listed yet. |

***

### delete

`snapshots.delete`

Delete a snapshot and every version it keeps. Machines made from it are not affected.

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.boxd.api.snapshots.delete({ name: 'ci-base' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Snapshot name (or id), as given to snapshots.create. |
| `org` | `string` | No | Org name or id. Defaults to the plugin option, else the API key's own org. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `deleted` | `true` | Yes | — |
| `name` | `string` | Yes | — |

***

### get

`snapshots.get`

Get one snapshot by name or id.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.snapshots.get({ name: 'ci-base' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | Snapshot name (or id), as given to snapshots.create. |
| `org` | `string` | No | Org name or id. Defaults to the plugin option, else the API key's own org. |
| `region` | `string` | No | Region the machine or snapshot lives in ("fra", "nyc", ...). Defaults to the plugin option, else the region the API serves. A machine returned by another call carries its region. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string` | Yes | — |
| `version` | `number \| null` | Yes | The current version; saving over a name makes a new one. |
| `status` | `string` | Yes | "pending" while it is being saved, then "ready" (or "failed"). |
| `storage` | `string` | Yes | "local" when machines can be created from it; "archived" or "unarchiving" otherwise. |
| `sizeBytes` | `number` | Yes | — |
| `vcpu` | `number` | Yes | — |
| `memoryBytes` | `number` | Yes | — |
| `region` | `string \| null` | Yes | — |
| `createdAt` | `string \| null` | Yes | — |
| `updatedAt` | `string \| null` | Yes | — |

***

### list

`snapshots.list`

List the org's snapshots in one region.

**Risk:** `read`

```ts theme={null}
await corsair.boxd.api.snapshots.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `org` | `string` | No | Org name or id. Defaults to the plugin option, else the API key's own org. |
| `region` | `string` | No | Region to list ("fra", "nyc", ...), or "all" for every region. Defaults to the plugin option, else the region the API serves. |
| `limit` | `number` | No | Most snapshots to return (1-1000, default 100). |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `snapshots` | `object[]` | Yes | — |
| `truncated` | `boolean` | Yes | — |
| `elsewhere` | `object[]` | Yes | How many of the org's snapshots are in each other region. |
| `unavailable` | `string[]` | Yes | Regions that could not be reached for an "all" listing; their items are missing. |

> [accordion] snapshots full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   version: number | null,
>   status: string,
>   storage: string,
>   sizeBytes: number,
>   vcpu: number,
>   memoryBytes: number,
>   region: string | null,
>   createdAt: string | null,
>   updatedAt: string | null
> }[]
> ```

> [accordion] elsewhere full type
>
> ```ts theme={null}
> {
>   region: string,
>   count: number
> }[]
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.