# Spaceyard API docs

> Spaceyard gives an AI agent a computer of its own: a Linux or Windows cloud desktop it starts with one API call, runs commands on and uses like a person through computer use (screenshots, clicks, typing). Sandboxes are billed by the minute, in euros.

Base URL: https://api.spaceyard.dev/v1. Web page: https://spaceyard.dev/docs. OpenAPI spec: https://spaceyard.dev/openapi.json.

## Overview

### Introduction

A sandbox is a cloud computer for an agent: a Linux or Windows machine with a full desktop, a browser and a shell, started in seconds and billed by the minute. Your agent runs commands on it, and through computer use it sees the screen and clicks, types and scrolls like a person.

The API covers a sandbox's whole life: create it, run commands on it, use its desktop, stop it and destroy it. It takes and returns JSON, at one address:

Base URL:

```text
https://api.spaceyard.dev/v1
```

### Quickstart

1. [Create an account](https://console.spaceyard.dev/auth/register) and add credit. A new account adds at least €10 before its first sandbox.
2. Make an API key on the console's [API key](https://console.spaceyard.dev/api-key) page, and keep it in an environment variable, `SPACEYARD_API_KEY`.
3. Start a sandbox, run a command on it, look at its screen, and destroy it:

cURL:

```bash
# 1. Pick an image: its id, and whether your account may start it.
curl https://api.spaceyard.dev/v1/sandboxes/images \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"

# 2. Start a sandbox from it.
curl -X POST https://api.spaceyard.dev/v1/sandboxes \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_id": 1}'

# 3. Ask again until its status is "running".
curl https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"

# 4. Run a command on it.
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/exec \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "uname -a"}'

# 5. Look at its screen.
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/computer \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "screenshot"}'

# 6. Destroy it when you are done.
curl -X DELETE https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import base64
import os
import time

import requests

API = "https://api.spaceyard.dev/v1"
headers = {"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"}

# 1. Pick a Linux desktop your account may start.
images = requests.get(f"{API}/sandboxes/images", headers=headers).json()["data"]
image = next(i for i in images if i["os"] == "linux" and i["desktop"] and i["allowed"] and i["in_stock"])

# 2. Start a sandbox from it.
sandbox = requests.post(f"{API}/sandboxes", headers=headers, json={"image_id": image["id"]}).json()["data"]

try:
    # 3. Wait until it runs.
    while sandbox["status"] != "running":
        if sandbox["status"] == "failed":
            raise RuntimeError(sandbox["error"])
        time.sleep(2)
        sandbox = requests.get(f"{API}/sandboxes/{sandbox['uuid']}", headers=headers).json()["data"]

    # 4. Run a command on it.
    result = requests.post(
        f"{API}/sandboxes/{sandbox['uuid']}/exec", headers=headers, json={"command": "uname -a"}
    ).json()["data"]
    print(result["exit_code"], result["stdout"])

    # 5. Look at its screen.
    shot = requests.post(
        f"{API}/sandboxes/{sandbox['uuid']}/computer", headers=headers, json={"action": "screenshot"}
    ).json()["data"]
    with open("screen.jpg", "wb") as file:
        file.write(base64.b64decode(shot["image"]))
finally:
    # 6. Destroy it, whatever happened: it is billed while it exists.
    requests.delete(f"{API}/sandboxes/{sandbox['uuid']}", headers=headers)
```

JavaScript:

```javascript
import { writeFile } from "node:fs/promises";

const API = "https://api.spaceyard.dev/v1";
const headers = {
  Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  "Content-Type": "application/json",
};
const call = async (method, path, body) => {
  const response = await fetch(API + path, { method, headers, body: body && JSON.stringify(body) });
  const json = await response.json();
  if (!response.ok) throw new Error(json.error.message);
  return json.data;
};

// 1. Pick a Linux desktop your account may start.
const images = await call("GET", "/sandboxes/images");
const image = images.find((i) => i.os === "linux" && i.desktop && i.allowed && i.in_stock);

// 2. Start a sandbox from it.
let sandbox = await call("POST", "/sandboxes", { image_id: image.id });

try {
  // 3. Wait until it runs.
  while (sandbox.status !== "running") {
    if (sandbox.status === "failed") throw new Error(sandbox.error);
    await new Promise((resolve) => setTimeout(resolve, 2000));
    sandbox = await call("GET", `/sandboxes/${sandbox.uuid}`);
  }

  // 4. Run a command on it.
  const result = await call("POST", `/sandboxes/${sandbox.uuid}/exec`, { command: "uname -a" });
  console.log(result.exit_code, result.stdout);

  // 5. Look at its screen.
  const shot = await call("POST", `/sandboxes/${sandbox.uuid}/computer`, { action: "screenshot" });
  await writeFile("screen.jpg", Buffer.from(shot.image, "base64"));
} finally {
  // 6. Destroy it, whatever happened: it is billed while it exists.
  await call("DELETE", `/sandboxes/${sandbox.uuid}`);
}
```

### Use with AI agents

Building with a coding agent such as Claude Code, Cursor or Codex? Paste this prompt, finish its last line with what you want, and it has what it needs:

Prompt:

```text
I want to use the Spaceyard API. It gives an AI agent a cloud computer (a Linux or Windows desktop) that it can run commands on and use like a person, with screenshots, clicks and typing.

Read the full reference first: https://spaceyard.dev/docs.md
The OpenAPI spec is at https://spaceyard.dev/openapi.json

Key facts:
- If you can run shell commands, the Spaceyard CLI is the shortest way: install it with `curl -fsSL https://spaceyard.dev/install.sh | sh` (on Windows, in PowerShell: `irm https://spaceyard.dev/install.ps1 | iex`), then run "spaceyard help". It reads the key from SPACEYARD_API_KEY. "spaceyard run <command>" runs one command in a fresh ephemeral sandbox and destroys it after; "spaceyard create" waits until the sandbox runs and prints its id; "spaceyard cp" copies files in and out; "spaceyard exec <id> <command>" exits with the command's exit code; "spaceyard fork <id>" snapshots and clones a sandbox; --json on any command gives JSON.
- Base URL https://api.spaceyard.dev/v1. JSON in and out.
- Authenticate every request with the header "Authorization: Bearer <key>". Read the key from the SPACEYARD_API_KEY environment variable; never put it in code.
- The flow: GET /sandboxes/images to pick an image, POST /sandboxes with {"image_id": ...}, then poll GET /sandboxes/{uuid} every 2 seconds until "status" is "running" (stop if it is "failed"). Then POST /sandboxes/{uuid}/exec with {"command": "..."} to run commands, and POST /sandboxes/{uuid}/computer with {"action": "screenshot"} (or click, type, key, scroll, open...) to use the desktop. DELETE /sandboxes/{uuid} when done.
- Errors are {"error": {"code": "...", "message": "..."}}. 409 means the sandbox is not running yet, 422 is a refusal or bad input (read the message), 429 means wait for the seconds in the Retry-After header.
- Sandboxes are billed by the minute while they exist, so always destroy them, also when something fails.

What I want to build: 
```

These docs are also in plain text, for agents and tools to read:

- [https://spaceyard.dev/docs.md](https://spaceyard.dev/docs.md): this page as Markdown.
- [https://spaceyard.dev/llms.txt](https://spaceyard.dev/llms.txt): an index of Spaceyard for language models.
- [https://spaceyard.dev/llms-full.txt](https://spaceyard.dev/llms-full.txt): everything in one file.
- [https://spaceyard.dev/openapi.json](https://spaceyard.dev/openapi.json): the API as an OpenAPI 3.1 spec, for code generators and tool calling.

### Authentication

Every request carries your API key as a bearer token:

Header:

```text
Authorization: Bearer <your API key>
```

An account has one key. Making a new one on the [API key](https://console.spaceyard.dev/api-key) page replaces the old one, which stops working at once, and the key is shown only when it is made. It can do everything your account can, so keep it on your server: never in a browser or an app you hand out.

A request without a key, or with one that is not valid, gets `401` with the code `UNAUTHENTICATED` or `INVALID_TOKEN`. A suspended account gets `403` with `ACCOUNT_BANNED`.

### Errors

Success is a `2xx` status. Anything else carries an `error` object with a code you can branch on and a message you can show. A validation error lists what is wrong with each field in `details`.

Validation:

```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The image id field is required.",
    "details": {
      "image_id": [
        "The image id field is required."
      ]
    }
  }
}
```

Refused:

```json
{
  "error": {
    "code": "UNPROCESSABLE",
    "message": "As a first time user, we require you to top up a total of 10€ to start sandboxes."
  }
}
```

| Status | Code | Means |
| --- | --- | --- |
| 401 | `UNAUTHENTICATED`, `INVALID_TOKEN` | No key, or not a valid one. |
| 403 | `ACCOUNT_BANNED` | The account is suspended. |
| 404 | `NOT_FOUND` | No such sandbox on your account, or no such endpoint. |
| 409 | `CONFLICT` | The sandbox is not running: start it first. |
| 422 | `VALIDATION_ERROR` | A parameter is missing or wrong; see `details`. |
| 422 | `UNPROCESSABLE` | Valid, but refused: not enough credit, over your account's limits, or out of stock. The message says which. |
| 429 | `RATE_LIMITED` | Too many requests; wait for `Retry-After` seconds. |
| 503 | `UNAVAILABLE` | The sandbox did not answer, usually because it has only just started. Try again in a few seconds. |
| 500 | `INTERNAL_ERROR` | Something went wrong on our side. |

### Rate limits

Requests are counted per minute. Computer use and commands come in bursts, so they have limits of their own:

| Requests | Per minute |
| --- | --- |
| Computer use | 600 |
| Run a command | 120 |
| Create, start and stop | 30, and they count toward the 60 below too |
| Everything else | 60 |

Over a limit, a request gets `429`. Its `Retry-After` header says how many seconds to wait, and `X-RateLimit-Limit` and `X-RateLimit-Remaining` say where you stand.

### Lifecycle

A sandbox's `status` is one of these:

|  |  |
| --- | --- |
| `creating` | Being made. Ask again in a few seconds. |
| `starting` | Booting after a start. |
| `running` | Up: commands and computer use work. |
| `stopping`, `stopped` | Shut down. Its disk is kept, and start brings it back as it was. |
| `deleting`, `deleted` | Destroyed, disk and all. |
| `failed` | Could not start; `error` says why. Destroyed after an hour. |

A sandbox looks after itself. With `auto_stop_minutes` it stops after that long without commands or computer use (`0` never stops it; otherwise 5 to 43,200). With `auto_destroy_minutes` it is destroyed after being stopped that long: `-1` keeps it, and `0` makes it ephemeral, destroyed as soon as it stops. The defaults are in [List images](https://spaceyard.dev/docs#list-images), under `lifecycle`.

Some sandboxes are handed over already running, from a pool kept warm for each image: then `from_pool` is true and the status is `running` straight away.

How many sandboxes you can run at once, and how large, depends on your account's level, which rises with the credit you have added. [List images](https://spaceyard.dev/docs#list-images) shows your limits and marks the images you may start.

### Environment variables

Give a sandbox secrets and settings when you create it, as `env`: an object of names and values. They are set for every command you run on it.

Request body:

```json
{
  "image_id": 1,
  "env": {
    "OPENAI_API_KEY": "sk-...",
    "TARGET_URL": "https://example.com"
  }
}
```

- Up to 50 variables, 32 KB in all.
- Names are letters, digits and underscores, not starting with a digit.
- Values are text or numbers.
- They are stored encrypted. The API only ever shows their names, never the values.
- They are set when the sandbox is created and cannot be changed afterwards.

### Billing

Sandboxes are paid from your credit, by the minute. A running sandbox pays its `hourly_price`: its vCPUs, memory and disk. A stopped one pays only for its disk, the `stopped_hourly_price`. Prices are in euros, and both are on every image and sandbox.

- A new account adds at least €10 before its first sandbox.
- Creating or starting a sandbox needs credit for an hour of it, at least €0.10.
- When your credit runs out, running sandboxes stop, and ephemeral ones are destroyed.
- Stopped sandboxes keep paying for their disk, and are destroyed after 72 hours without credit.

Add credit, or turn on auto-recharge, on the console's [Billing](https://console.spaceyard.dev/billing) page.

### Live desktop

To watch what an agent is doing, or to take over, open the sandbox in the [console](https://console.spaceyard.dev/auth/login): its Desktop tab shows the screen live, and you can use it with your own mouse and keyboard while the agent works through the API.

To embed a live screen in your own app or connect a VNC client directly, call [Stream the screen](https://spaceyard.dev/docs#stream-sandbox) for a tokenized `embed_url` (ready for an `<iframe>`) and a one-time VNC WebSocket URL.

## API

### The sandbox object

Every endpoint that acts on a sandbox answers with it, as `data`. Timestamps are ISO 8601, in UTC.

|  |  |  |
| --- | --- | --- |
| `uuid` | string | Its id, in every path. |
| `name` | string \| null | The name you gave it. |
| `image` | string | The image it was started from. |
| `desktop` | boolean | It has a desktop, so computer use works. |
| `status` | string | See [Lifecycle](https://spaceyard.dev/docs#lifecycle). |
| `os` | string | `linux` or `windows`. |
| `vcpu` | integer | Its vCPUs. |
| `memory_mb` | integer | Its memory, in MB. |
| `disk_gb` | integer | Its disk, in GB. |
| `private_ip` | string \| null | Its address on the private network. |
| `location` | object | `id`, `name`, `short_code` and `icon` (a URL, or null). |
| `error` | string \| null | Why it failed, when it did. |
| `hourly_price` | number | Euros an hour while it runs. |
| `stopped_hourly_price` | number | Euros an hour while it is stopped: its disk. |
| `current_hourly_price` | number | What it pays now: the stopped price while stopped. |
| `billed_total` | number | Euros charged for it so far. |
| `billed_until` | timestamp \| null | How far it has been billed. |
| `from_pool` | boolean | Handed over already running from the warm pool. |
| `env` | string[] | The names of its environment variables, never the values. |
| `auto_stop_minutes` | integer | Stops after this long without activity; 0 never. |
| `auto_destroy_minutes` | integer | Destroyed after being stopped this long; -1 never, 0 at once. |
| `ephemeral` | boolean | It is destroyed as soon as it stops. |
| `created_at` | timestamp | When it was created. |
| `stops_at` | timestamp \| null | While running: when it stops by itself if left idle. |
| `destroys_at` | timestamp \| null | While stopped: when it is destroyed by itself. |

### List images

`GET /v1/sandboxes/images`

The images you can start a sandbox from, with their size and prices. `allowed` says whether your account's level may start it, and `in_stock` whether there is room for one right now. `limits` is how many sandboxes you run and may run, and the largest size you may start; `lifecycle` holds the defaults a new sandbox gets.

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes/images \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes/images",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/images", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": [
    {
      "id": 1,
      "name": "Ubuntu 24.04 desktop",
      "slug": "ubuntu-desktop",
      "os": "linux",
      "desktop": true,
      "vcpu": 2,
      "memory_mb": 4096,
      "disk_gb": 16,
      "location": {
        "id": 1,
        "name": "Salt Lake City",
        "short_code": "UT01",
        "icon": null
      },
      "hourly_price": 0.0377,
      "stopped_hourly_price": 0.0017,
      "allowed": true,
      "in_stock": true
    }
  ],
  "limits": {
    "used": 1,
    "max": 2,
    "cpu": 2,
    "memory_mb": 4096
  },
  "currency": "EUR",
  "lifecycle": {
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "min_auto_stop_minutes": 5,
    "max_minutes": 43200
  }
}
```

### Create a sandbox

`POST /v1/sandboxes`

Starts a new sandbox. Most often it comes back `creating`: ask for it with [Get a sandbox](https://spaceyard.dev/docs#get-sandbox) until it is `running`, usually a few seconds. One handed over from the warm pool is `running` at once.

It is refused with `422` when your credit is short, when your account is at its limits, or when the image is out of stock.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `image_id` | integer | yes | The image to start from, from [List images](https://spaceyard.dev/docs#list-images). |
| `name` | string | no | A name of your own, up to 60 characters. |
| `auto_stop_minutes` | integer | no | Stop after this long without activity: 5 to 43,200, or `0` never. Defaults to the image list's `lifecycle`. |
| `auto_destroy_minutes` | integer | no | Destroy after being stopped this long: up to 43,200, `-1` never, `0` as soon as it stops. |
| `ephemeral` | boolean | no | Destroy it as soon as it stops. The same as `auto_destroy_minutes: 0`. |
| `env` | object | no | Environment variables, names to values. See [Environment variables](https://spaceyard.dev/docs#environment). |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_id":1,"name":"browser-agent","auto_stop_minutes":15,"env":{"OPENAI_API_KEY":"sk-..."}}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "image_id": 1,
        "name": "browser-agent",
        "auto_stop_minutes": 15,
        "env": {
            "OPENAI_API_KEY": "sk-...",
        },
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    image_id: 1,
    name: "browser-agent",
    auto_stop_minutes: 15,
    env: {
      OPENAI_API_KEY: "sk-...",
    },
  }),
});
console.log(await response.json());
```

Response (201 Created):

```json
{
  "data": {
    "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    "name": "browser-agent",
    "image": "Ubuntu 24.04 desktop",
    "desktop": true,
    "status": "creating",
    "os": "linux",
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "private_ip": null,
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "error": null,
    "hourly_price": 0.0377,
    "stopped_hourly_price": 0.0017,
    "current_hourly_price": 0.0377,
    "billed_total": 0,
    "billed_until": null,
    "from_pool": false,
    "env": [
      "OPENAI_API_KEY"
    ],
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "ephemeral": false,
    "created_at": "2026-11-25T18:00:12+00:00",
    "stops_at": null,
    "destroys_at": null
  }
}
```

### List sandboxes

`GET /v1/sandboxes`

Your sandboxes that are not destroyed, newest first, with how many you run and may run.

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": [
    {
      "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
      "name": "browser-agent",
      "image": "Ubuntu 24.04 desktop",
      "desktop": true,
      "status": "running",
      "os": "linux",
      "vcpu": 2,
      "memory_mb": 4096,
      "disk_gb": 16,
      "private_ip": "10.77.0.14",
      "location": {
        "id": 1,
        "name": "Salt Lake City",
        "short_code": "UT01",
        "icon": null
      },
      "error": null,
      "hourly_price": 0.0377,
      "stopped_hourly_price": 0.0017,
      "current_hourly_price": 0.0377,
      "billed_total": 0.01257,
      "billed_until": "2026-11-25T18:20:00+00:00",
      "from_pool": true,
      "env": [
        "OPENAI_API_KEY"
      ],
      "auto_stop_minutes": 15,
      "auto_destroy_minutes": -1,
      "ephemeral": false,
      "created_at": "2026-11-25T18:00:12+00:00",
      "stops_at": "2026-11-25T18:35:00+00:00",
      "destroys_at": null
    }
  ],
  "meta": {
    "ever_used": true,
    "used": 1,
    "max": 2
  }
}
```

### Get a sandbox

`GET /v1/sandboxes/{uuid}`

One sandbox, with the user its desktop runs as: `root` on Linux, `Administrator` on Windows. Its `password` is set the first time the desktop is opened in the console, and empty until then. Use this to follow a sandbox through its [lifecycle](https://spaceyard.dev/docs#lifecycle).

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    "name": "browser-agent",
    "image": "Ubuntu 24.04 desktop",
    "desktop": true,
    "status": "running",
    "os": "linux",
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "private_ip": "10.77.0.14",
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "error": null,
    "hourly_price": 0.0377,
    "stopped_hourly_price": 0.0017,
    "current_hourly_price": 0.0377,
    "billed_total": 0.01257,
    "billed_until": "2026-11-25T18:20:00+00:00",
    "from_pool": true,
    "env": [
      "OPENAI_API_KEY"
    ],
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "ephemeral": false,
    "created_at": "2026-11-25T18:00:12+00:00",
    "stops_at": "2026-11-25T18:35:00+00:00",
    "destroys_at": null,
    "username": "root",
    "password": null
  }
}
```

### Start a sandbox

`POST /v1/sandboxes/{uuid}/start`

Starts a stopped sandbox, disk as it was. It goes through `starting` to `running`. Starting one that is not stopped changes nothing and answers with it as it is.

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/start \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/start",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/start", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    "name": "browser-agent",
    "image": "Ubuntu 24.04 desktop",
    "desktop": true,
    "status": "starting",
    "os": "linux",
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "private_ip": "10.77.0.14",
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "error": null,
    "hourly_price": 0.0377,
    "stopped_hourly_price": 0.0017,
    "current_hourly_price": 0.0377,
    "billed_total": 0.01257,
    "billed_until": "2026-11-25T18:20:00+00:00",
    "from_pool": true,
    "env": [
      "OPENAI_API_KEY"
    ],
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "ephemeral": false,
    "created_at": "2026-11-25T18:00:12+00:00",
    "stops_at": null,
    "destroys_at": null
  }
}
```

### Stop a sandbox

`POST /v1/sandboxes/{uuid}/stop`

Shuts a running sandbox down. It keeps its disk and pays only for that while stopped. An ephemeral sandbox is destroyed instead. While a sandbox is still `creating`, stopping it is refused: try again in a moment.

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stop \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stop",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stop", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    "name": "browser-agent",
    "image": "Ubuntu 24.04 desktop",
    "desktop": true,
    "status": "stopping",
    "os": "linux",
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "private_ip": "10.77.0.14",
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "error": null,
    "hourly_price": 0.0377,
    "stopped_hourly_price": 0.0017,
    "current_hourly_price": 0.0377,
    "billed_total": 0.01257,
    "billed_until": "2026-11-25T18:20:00+00:00",
    "from_pool": true,
    "env": [
      "OPENAI_API_KEY"
    ],
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "ephemeral": false,
    "created_at": "2026-11-25T18:00:12+00:00",
    "stops_at": null,
    "destroys_at": null
  }
}
```

### Destroy a sandbox

`DELETE /v1/sandboxes/{uuid}`

Destroys a sandbox, disk and all, and bills its last minute. This cannot be undone.

Request:

cURL:

```bash
curl -X DELETE https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.delete(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "uuid": "7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90",
    "name": "browser-agent",
    "image": "Ubuntu 24.04 desktop",
    "desktop": true,
    "status": "deleting",
    "os": "linux",
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "private_ip": "10.77.0.14",
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "error": null,
    "hourly_price": 0.0377,
    "stopped_hourly_price": 0.0017,
    "current_hourly_price": 0.0377,
    "billed_total": 0.01257,
    "billed_until": "2026-11-25T18:20:00+00:00",
    "from_pool": true,
    "env": [
      "OPENAI_API_KEY"
    ],
    "auto_stop_minutes": 15,
    "auto_destroy_minutes": -1,
    "ephemeral": false,
    "created_at": "2026-11-25T18:00:12+00:00",
    "stops_at": null,
    "destroys_at": null
  }
}
```

### Run a command

`POST /v1/sandboxes/{uuid}/exec`

Runs a command on a running sandbox and answers with its output. The request waits up to 60 seconds: a command still going after that keeps running, and comes back with `finished` false. Each of `stdout` and `stderr` is cut at 64 KB, and then `truncated` is true.

A command that fails still answers `200`: look at `exit_code`. A sandbox that is not running answers `409`.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `command` | string | yes | Up to 8,000 characters. On Linux it runs with `/bin/sh -c` as root; on Windows in PowerShell. |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/exec \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":"uname -a"}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/exec",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "command": "uname -a",
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/exec", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    command: "uname -a",
  }),
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "finished": true,
    "exit_code": 0,
    "stdout": "Linux sandbox 6.8.0-49-generic #49-Ubuntu SMP x86_64 GNU/Linux\n",
    "stderr": "",
    "truncated": false,
    "seconds": 0.31
  }
}
```

### Computer use

`POST /v1/sandboxes/{uuid}/computer`

Uses the desktop of a running sandbox the way a person would: look at the screen, move the mouse, click, type, press keys and scroll. Coordinates are screen pixels from the top left; the Linux desktop is 1280 by 800. Each action has parameters of its own, in the same body, and the answer's `data` has `ok` and what the action reports.

| action | Parameters (defaults in brackets) | Answers with |
| --- | --- | --- |
| `screenshot` | `format` jpeg or png (jpeg), `quality` 10 to 100 (75) | `width`, `height`, `format`, `image` (base64) |
| `size` | None | `width`, `height` |
| `cursor` | None | `x`, `y` |
| `move` | `x`, `y` (required) | `x`, `y` |
| `click` | `x`, `y` (both or neither), `button` left, middle or right (left), `count` 1 to 3 (1) | Where the cursor is: `x`, `y` |
| `mouse_down` | `x`, `y` (optional), `button` | `x`, `y` |
| `mouse_up` | `x`, `y` (optional), `button` | `x`, `y` |
| `drag` | `from` and `to`, each an object with `x` and `y` (required) | Where it ended: `x`, `y` |
| `scroll` | `x`, `y` (optional), `direction` up, down, left or right (down), `amount` 1 to 30 (3) | `x`, `y` |
| `type` | `text`, up to 20,000 characters (required) | `typed`: how many characters |
| `key` | `keys`: a combination like `ctrl+l`, or a list of up to 20; `repeat` 1 to 50 (1) | `pressed`, `repeat` |
| `open` | `target`: a URL, a file or an app (required); `wait` 0 to 30 seconds (2 on Linux) | The open windows |
| `windows` | None | `windows`: each with `id`, `title`, `pid`, `active` |
| `focus` | `window`: an id from windows, or part of a title (required) | The open windows |
| `read_screen` | `window` (optional), `max_nodes` 20 to 1,500 (300) | The window, and its controls as `nodes`: role, name, position and box |
| `wait` | `seconds` 0 to 30 (1) | Nothing more |

An action the desktop could not carry out answers `422` with the reason, and what the desktop reported in `data`. Computer use needs a desktop image: a sandbox without one answers `422`.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | string | yes | What to do: one of the actions above. |
| `screenshot` | boolean | no | On an action that changes the screen, answer with a screenshot taken after it, as `screenshot`. Saves a second request. |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/computer \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"click","x":640,"y":400,"screenshot":true}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/computer",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "action": "click",
        "x": 640,
        "y": 400,
        "screenshot": True,
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/computer", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    action: "click",
    x: 640,
    y: 400,
    screenshot: true,
  }),
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "ok": true,
    "x": 640,
    "y": 400,
    "screenshot": {
      "width": 1280,
      "height": 800,
      "format": "jpeg",
      "image": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
    }
  }
}
```

### Stream the screen

`POST /v1/sandboxes/{uuid}/stream`

Opens a live VNC stream of a running sandbox's screen and returns both:

- `url` and `password`: a one-time VNC WebSocket (`binary` subprotocol, valid for `expires_in` seconds) for noVNC or native clients.
- `embed_url`: a standalone viewer page you can place in an `<iframe>`. It stays valid and reconnectable until `embed_expires_at` (or until the sandbox stops), and never exposes the sandbox's OS login password.

Pass `view_only: true` to lock the embed viewer to watch-only mode. A sandbox that is not running answers `409`.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `view_only` | boolean | no | Lock the embedded viewer to read-only mode (default `false`). |
| `ttl` | integer | no | How long `embed_url` stays valid, in seconds: 60 to 43,200 (default `3600`). |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stream \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"view_only":false,"ttl":3600}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stream",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "view_only": False,
        "ttl": 3600,
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/stream", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    view_only: false,
    ttl: 3600,
  }),
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "protocol": "vnc",
    "url": "wss://console.spaceyard.dev/sandbox-console/aBcDeFgH1234567890aBcDeFgH1234567890aBcDeFgH1234",
    "password": "PVEVNC:ticket...",
    "expires_in": 30,
    "embed_url": "https://console.spaceyard.dev/embed/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90?token=xYz0123456789xYz0123456789xYz0123456789xYz012345",
    "embed_expires_at": "2026-11-25T19:01:03+00:00",
    "view_only": false,
    "username": "root",
    "login_password": "..."
  }
}
```

### Logs

`GET /v1/sandboxes/{uuid}/logs`

What happened to a sandbox, newest first: who started and stopped it, every command and computer use action, and what it did by itself. `source` is `api`, `panel` for the console, or `system`. When `meta.more` is true there are older entries.

Query parameters:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | no | `all` (the default), `lifecycle`, `commands`, `computer` or `screen`. |
| `limit` | integer | no | How many, 1 to 100 (50). |
| `before` | integer | no | For the next page: the smallest `id` you have so far. |

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/logs?type=commands&limit=20 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/logs?type=commands&limit=20",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/logs?type=commands&limit=20", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": [
    {
      "id": 1042,
      "at": "2026-11-25T18:01:03.120+00:00",
      "source": "api",
      "action": "command",
      "status": "ok",
      "message": "uname -a",
      "detail": {
        "command": "uname -a",
        "exit_code": 0
      },
      "duration_ms": 312
    }
  ],
  "meta": {
    "more": false
  }
}
```

### List snapshots

`GET /v1/sandboxes/snapshots`

Official snapshots (`data`) and your own custom snapshots (`custom`), grouped by slug across regions, together with all sandbox-capable `locations` and your warm pool limits.

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes/snapshots \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes/snapshots",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/snapshots", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": [],
  "custom": [
    {
      "slug": "snap-a1b2c3d4",
      "name": "python-chrome",
      "custom": true,
      "os": "linux",
      "desktop": true,
      "vcpu": 2,
      "memory_mb": 4096,
      "disk_gb": 16,
      "hourly_price": 0.0377,
      "stopped_hourly_price": 0.0017,
      "allowed": true,
      "created_at": "2026-11-25T18:10:00+00:00",
      "regions": [
        {
          "image_id": 42,
          "location": {
            "id": 1,
            "name": "Salt Lake City",
            "short_code": "UT01",
            "icon": null
          },
          "status": "ready",
          "build_step": null,
          "build_error": null,
          "used_bytes": 2684354560,
          "used_gb": 2.5,
          "storage_hourly_price": 0.0005,
          "billed_total": 0.001,
          "in_stock": true,
          "warm_pool": null,
          "created_at": "2026-11-25T18:10:00+00:00"
        }
      ]
    }
  ],
  "locations": [
    {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    }
  ],
  "warm_pool_limits": {
    "used": 0,
    "max": 2
  },
  "sizing": {
    "max_vcpu": 4,
    "max_memory_mb": 8192,
    "max_disk_gb": 200,
    "memory_step_mb": 512,
    "min": {
      "linux": {
        "server": {
          "vcpu": 1,
          "memory_mb": 1024
        },
        "desktop": {
          "vcpu": 1,
          "memory_mb": 2048
        }
      },
      "windows": {
        "server": {
          "vcpu": 2,
          "memory_mb": 2048
        },
        "desktop": {
          "vcpu": 2,
          "memory_mb": 4096
        }
      }
    }
  },
  "rates": {
    "cpu_hour": 0.0108,
    "windows_cpu_hour": 0.0144,
    "ram_gb_hour": 0.0036,
    "disk_gb_hour": 0.000108,
    "currency": "EUR"
  },
  "snapshot_gb_hour_price": 0.0002,
  "open": true
}
```

### Capture a snapshot

`POST /v1/sandboxes/{uuid}/snapshots`

Captures a reusable custom snapshot (disk and saved memory state) from a running or stopped sandbox. Pass optional `vcpu`, `memory_mb`, and `disk_gb` to size the new custom snapshot differently from the source sandbox (disk can grow up to 200 GB, never shrink). Starts with `status: "building"`; poll [List snapshots](https://spaceyard.dev/docs#list-snapshots) until it is `ready`, then pass its `image_id` to [Create a sandbox](https://spaceyard.dev/docs#create-sandbox).

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | A name for the snapshot, up to 80 characters. |
| `vcpu` | integer | no | Optional vCPU count, within your account level limit. Defaults to the sandbox. |
| `memory_mb` | integer | no | Optional memory in MB (512 MB increments), within your account level limit. Defaults to the sandbox. |
| `disk_gb` | integer | no | Optional disk in GB, at least the sandbox disk and up to 200 GB. Defaults to the sandbox. |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/snapshots \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"python-chrome","vcpu":4,"memory_mb":8192,"disk_gb":32}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/snapshots",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "name": "python-chrome",
        "vcpu": 4,
        "memory_mb": 8192,
        "disk_gb": 32,
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/7f3c2a10-5b1e-4c2d-9a7e-2f1d8c4b6e90/snapshots", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "python-chrome",
    vcpu: 4,
    memory_mb: 8192,
    disk_gb: 32,
  }),
});
console.log(await response.json());
```

Response (201 Created):

```json
{
  "data": {
    "image_id": 42,
    "slug": "snap-a1b2c3d4",
    "name": "python-chrome",
    "os": "linux",
    "desktop": true,
    "vcpu": 4,
    "memory_mb": 8192,
    "disk_gb": 32,
    "hourly_price": 0.0755,
    "stopped_hourly_price": 0.0035,
    "status": "building",
    "build_step": "queued",
    "build_error": null,
    "used_bytes": 0,
    "used_gb": 0,
    "storage_hourly_price": 0,
    "billed_total": 0,
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "created_at": "2026-11-25T18:10:00+00:00"
  }
}
```

### Deploy a snapshot

`POST /v1/sandboxes/snapshots/{id}/deploy`

Replicates a ready custom snapshot to a sandbox node in another region so you can boot sandboxes and warm pools from it there.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `location_id` | integer | yes | Target location id from [List snapshots](https://spaceyard.dev/docs#list-snapshots). |

Request:

cURL:

```bash
curl -X POST https://api.spaceyard.dev/v1/sandboxes/snapshots/42/deploy \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"location_id":2}'
```

Python:

```python
import os
import requests

response = requests.post(
    "https://api.spaceyard.dev/v1/sandboxes/snapshots/42/deploy",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "location_id": 2,
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/snapshots/42/deploy", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    location_id: 2,
  }),
});
console.log(await response.json());
```

Response (201 Created):

```json
{
  "data": {
    "image_id": 43,
    "slug": "snap-a1b2c3d4",
    "name": "python-chrome",
    "os": "linux",
    "desktop": true,
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "status": "building",
    "build_step": "queued",
    "build_error": null,
    "used_bytes": 0,
    "used_gb": 0,
    "storage_hourly_price": 0,
    "billed_total": 0,
    "location": {
      "id": 2,
      "name": "Amsterdam",
      "short_code": "NL01",
      "icon": null
    },
    "created_at": "2026-11-25T18:15:00+00:00"
  }
}
```

### Delete a snapshot

`DELETE /v1/sandboxes/snapshots/{id}`

Deletes a custom snapshot copy from its region, settles its final storage billing and tears down the template. Drain its warm pool and destroy any live sandboxes using it first.

Request:

cURL:

```bash
curl -X DELETE https://api.spaceyard.dev/v1/sandboxes/snapshots/42 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.delete(
    "https://api.spaceyard.dev/v1/sandboxes/snapshots/42",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/snapshots/42", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (204 No Content):

```json
{}
```

### List warm pools

`GET /v1/sandboxes/warm-pools`

Your active custom warm pools, with ready and warming counts, hourly price and your account's warm pool quota.

Request:

cURL:

```bash
curl https://api.spaceyard.dev/v1/sandboxes/warm-pools \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.spaceyard.dev/v1/sandboxes/warm-pools",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/warm-pools", {
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": [
    {
      "id": 7,
      "image_id": 42,
      "image_name": "python-chrome",
      "image_slug": "snap-a1b2c3d4",
      "custom": true,
      "os": "linux",
      "desktop": true,
      "vcpu": 2,
      "memory_mb": 4096,
      "disk_gb": 16,
      "location": {
        "id": 1,
        "name": "Salt Lake City",
        "short_code": "UT01",
        "icon": null
      },
      "size": 2,
      "ready": 2,
      "warming": 0,
      "paused_reason": null,
      "hourly_price_per_vm": 0.0377,
      "hourly_price_total": 0.0754
    }
  ],
  "limits": {
    "used": 2,
    "max": 5
  }
}
```

### Set a warm pool

`PUT /v1/sandboxes/warm-pools`

Creates or resizes a warm pool of pre-booted sandboxes for one of your custom snapshots. Set `size` to `0` to drain it. Official images use the shared platform pool.

Body (JSON):

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `image_id` | integer | yes | A ready custom snapshot `image_id` from [List snapshots](https://spaceyard.dev/docs#list-snapshots). |
| `size` | integer | yes | Number of pre-warmed sandboxes to keep ready, 0 to 100 (capped by account limits). |

Request:

cURL:

```bash
curl -X PUT https://api.spaceyard.dev/v1/sandboxes/warm-pools \
  -H "Authorization: Bearer $SPACEYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_id":42,"size":2}'
```

Python:

```python
import os
import requests

response = requests.put(
    "https://api.spaceyard.dev/v1/sandboxes/warm-pools",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
    json={
        "image_id": 42,
        "size": 2,
    },
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/warm-pools", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    image_id: 42,
    size: 2,
  }),
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "data": {
    "id": 7,
    "image_id": 42,
    "image_name": "python-chrome",
    "image_slug": "snap-a1b2c3d4",
    "custom": true,
    "os": "linux",
    "desktop": true,
    "vcpu": 2,
    "memory_mb": 4096,
    "disk_gb": 16,
    "location": {
      "id": 1,
      "name": "Salt Lake City",
      "short_code": "UT01",
      "icon": null
    },
    "size": 2,
    "ready": 0,
    "warming": 2,
    "paused_reason": null,
    "hourly_price_per_vm": 0.0377,
    "hourly_price_total": 0.0754
  },
  "limits": {
    "used": 2,
    "max": 5
  }
}
```

### Delete a warm pool

`DELETE /v1/sandboxes/warm-pools/{id}`

Drains a warm pool back to `0` and returns your updated warm pool quota.

Request:

cURL:

```bash
curl -X DELETE https://api.spaceyard.dev/v1/sandboxes/warm-pools/7 \
  -H "Authorization: Bearer $SPACEYARD_API_KEY"
```

Python:

```python
import os
import requests

response = requests.delete(
    "https://api.spaceyard.dev/v1/sandboxes/warm-pools/7",
    headers={"Authorization": f"Bearer {os.environ['SPACEYARD_API_KEY']}"},
)
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.spaceyard.dev/v1/sandboxes/warm-pools/7", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.SPACEYARD_API_KEY}`,
  },
});
console.log(await response.json());
```

Response (200 OK):

```json
{
  "limits": {
    "used": 0,
    "max": 5
  }
}
```

## CLI

### Install & auth

The `spaceyard` CLI wraps the full Spaceyard sandbox API in one static binary for macOS, Linux and Windows, with nothing else to install. Built for both interactive terminal workflows and AI coding agents (Claude Code, Codex, Cursor), every command supports `--json` and exits with predictable status codes.

macOS and Linux:

```bash
curl -fsSL https://spaceyard.dev/install.sh | sh
```

Windows:

```powershell
irm https://spaceyard.dev/install.ps1 | iex
```

The installer checks the binary's SHA-256 checksum, places it in `~/.spaceyard/bin`, and adds that folder to your PATH. Sign in with your [API key](https://console.spaceyard.dev/api-key) or export `SPACEYARD_API_KEY`:

```bash
spaceyard login          # prompts securely and verifies the key
spaceyard whoami         # confirm auth, active key source and account limits
spaceyard logout         # remove saved key from user config
```

| Environment / flag | Purpose |
| --- | --- |
| `SPACEYARD_API_KEY` / `--api-key` | API key used instead of the saved config file. |
| `SPACEYARD_SANDBOX` | Default sandbox UUID, so you can omit `<id>` on every command. |
| `SPACEYARD_API_URL` / `--api-url` | Override the API base URL (default `https://api.spaceyard.dev/v1`). |
| `--json` | Machine-readable JSON output on every command (errors included). |
| `-h`, `--help` | Usage and flags for any command or subcommand. |

Exit codes: `0` on success, `1` on API or runtime error, `2` on bad arguments, `124` when `exec` or `run` is still running after 60 seconds (otherwise `exec` and `run` exit with the remote command's own exit code).

### Sandboxes & run

Create persistent or ephemeral sandboxes, run one-shot commands in a disposable VM, fork an existing sandbox's disk and memory state, or manage lifecycles.

```bash
# One-shot: boot an ephemeral sandbox, run a command, destroy it automatically
spaceyard run uname -a
spaceyard run --os windows '$PSVersionTable.PSVersion'

# Persistent sandbox: waits until running and prints only the UUID on stdout
id=$(spaceyard create --name browser --location NL01 --env-file .env)

spaceyard list --status running
spaceyard get $id
spaceyard stop $id --wait
spaceyard start $id
spaceyard destroy $id
```

| Command (aliases) | Does |
| --- | --- |
| `create` (`new`) | Start a sandbox and wait until it runs; prints its UUID on stdout. Flags: `--image ID\|SLUG`, `--snapshot ID\|SLUG`, `--os linux\|windows`, `-l`/`--location CODE\|ID`, `--name`, `--idle MIN`, `--no-auto-stop`, `--destroy-after MIN`, `--ephemeral`, `-e`/`--env K=V` (repeatable), `--env-file FILE`, `--no-wait`, `--timeout SEC`. |
| `run` | Start an ephemeral sandbox, run `<command...>` (or `-` for stdin), print its output, destroy the sandbox, and exit with the command's exit code. Takes the same image/location/env flags as `create`, plus `--keep`. |
| `list` (`ls`, `ps`) | List your sandboxes. Filter with `--status running\|stopped\|creating\|failed`. |
| `get` (`info`, `show`) | Show full details of one sandbox: status, IP, size, pricing, lifecycle timers, env names and desktop login. |
| `start` (`resume`) | Start a stopped sandbox and wait until running (`--no-wait`, `--timeout SEC`). |
| `stop` (`pause`) | Stop a running sandbox while keeping its disk (`--wait`, `--timeout SEC`). Ephemeral sandboxes are destroyed on stop. |
| `destroy` (`rm`, `delete`) | Permanently destroy one or more sandboxes, disk and all: `spaceyard destroy <id>...`. |
| `fork` | Capture a snapshot from `<id>` and immediately boot a new clone sandbox from it. Supports `--name`, `--snapshot-name`, `--idle`, `--no-auto-stop`, `--ephemeral`, `--env`, `--env-file`, `--no-wait`, `--timeout`. |
| `images` | List available images, specs, regions, hourly pricing and account limits. Filter with `--os` and `-l`/`--location`. |

### Exec, files & logs

Run shell commands, copy files to and from Linux or Windows sandboxes, stream the live desktop, and tail sandbox activity logs.

```bash
# Run a command or pipe a script via stdin
spaceyard exec $id 'cd /srv && ls -la'
spaceyard exec $id - <<'EOF'
apt-get update && apt-get install -y jq
EOF

# Copy files in and out (works on Linux and Windows; use - for stdin/stdout)
spaceyard cp ./scraper.py $id:/tmp/scraper.py
spaceyard cp $id:/tmp/output.json ./output.json
spaceyard cp $id:/var/log/app.log -

# Live desktop and VNC / iframe streaming
spaceyard desktop $id                    # open console desktop in browser
spaceyard desktop $id --view-only        # open watch-only embed URL
spaceyard stream $id --ttl 3600 --json   # mint embed_url + one-time VNC WebSocket

# Inspect or tail logs live
spaceyard logs $id --type commands --limit 20
spaceyard logs $id --follow
```

| Command (aliases) | Does |
| --- | --- |
| `exec <id> <command...>` | Run a command (`/bin/sh -c` on Linux, PowerShell on Windows) or pass `-` to read a script from stdin. Exits with the command's exit code, or `124` after 60 s. |
| `cp` (`scp`, `copy`) | Copy a file to (`<local> <id>:<remote>`) or from (`<id>:<remote> <local>`) a running sandbox. Supports chunked binary files, Windows paths, `-` for stdin/stdout, and `:<remote>` when `SPACEYARD_SANDBOX` is set. |
| `stream <id>` | Call `POST /sandboxes/{id}/stream` and print `embed_url`, VNC WebSocket `url`, `password` and login credentials. Flags: `--view-only`, `--ttl SEC`, `--open`. |
| `desktop <id>` | Open the live desktop in your browser. Flags: `--embed` (use tokenized `/stream` URL), `--view-only`, `--ttl SEC`, `--print` (print URL without opening). |
| `logs <id>` | List sandbox events newest first. Flags: `--type all\|lifecycle\|commands\|computer\|screen`, `--limit N`, `--before ID`, `-f`/`--follow` (live tail; emits NDJSON with `--json`). |

### Computer use

Drive the sandbox's Linux or Windows desktop directly from the shell: take screenshots, inspect the accessibility tree, open apps or URLs, click, type, press keys and scroll. Every action command accepts `--screenshot FILE` to capture the updated screen in the same API request.

```bash
export SPACEYARD_SANDBOX=$id
spaceyard open https://example.com --wait 3 --screenshot after-open.jpg
spaceyard read-screen --max-nodes 100
spaceyard click 640 400 --screenshot clicked.jpg
spaceyard type "hello world"
spaceyard key ctrl+l enter
spaceyard scroll down --amount 5 --at 640,400
spaceyard focus Firefox
spaceyard screenshot -o screen.png
```

| Command | Does |
| --- | --- |
| `screenshot <id> [-o FILE]` | Save the screen as JPEG or PNG (`.png` selects PNG; `-o -` writes raw bytes to stdout). Flag: `--quality 10..100`. |
| `click <id> [X Y]` | Click at `X Y` or current cursor. Flags: `--button left\|middle\|right`, `--right`, `--double`, `--count 1..3`, `--screenshot FILE`. |
| `type <id> <text...>` | Type text on the keyboard (or `-` to read from stdin). Flag: `--screenshot FILE`. |
| `key <id> <keys...>` | Press one or more key combinations (`enter`, `ctrl+l`, `alt+f4`). Flags: `--repeat 1..50`, `--screenshot FILE`. |
| `scroll <id> [dir]` | Scroll `up`, `down`, `left` or `right`. Flags: `--amount 1..30`, `--at X,Y`, `--screenshot FILE`. |
| `move <id> X Y` | Move the mouse cursor to `X Y`. Flag: `--screenshot FILE`. |
| `drag <id> X1 Y1 X2 Y2` | Drag from `X1 Y1` to `X2 Y2`. Flag: `--screenshot FILE`. |
| `open <id> <target>` | Open a URL, file or app on the desktop. Flags: `--wait 0..30`, `--screenshot FILE`. |
| `windows <id>` | List open desktop windows with ids, titles and active state. |
| `focus <id> <window...>` | Bring a window to the front by id or title substring. Flag: `--screenshot FILE`. |
| `read-screen <id>` | Inspect the active window's accessibility tree (roles, labels, center coordinates). Flags: `--window`, `--max-nodes 20..1500`. |
| `wait <id> [SECONDS]` | Pause 0 to 30 seconds (default 1). Flag: `--screenshot FILE`. |
| `computer <id> <action>` | Call any computer use action directly (`size`, `cursor`, `mouse_down`, `mouse_up`, etc.) with `key=value` args or `--data JSON`. |

### Snapshots & warm pools

Capture a sandbox's disk and state into a reusable snapshot, replicate it to other regions, fork sandboxes in one step, or keep pre-warmed pools ready for instant sub-second handoff.

```bash
# Save a reusable snapshot from a configured sandbox (prints image id)
snap=$(spaceyard snapshots create $id --name python-chrome)

# Replicate it to another region and list snapshots
spaceyard snapshots deploy $snap --location NL01
spaceyard snapshots list

# Boot new sandboxes from the snapshot, or fork directly in one command
spaceyard create --snapshot $snap --name worker-1
clone=$(spaceyard fork $id --name branch-2)

# Keep 3 pre-warmed sandboxes ready on standby for your snapshot
spaceyard warm-pools set $snap 3
spaceyard warm-pools list
spaceyard warm-pools delete 7
```

| Command (aliases) | Does |
| --- | --- |
| `snapshots list` (`snap ls`) | List your custom snapshots with image id, slug, size, region, status and storage rate. Flags: `--official`, `--all`. |
| `snapshots create <id> --name NAME` | Capture a snapshot from a running or stopped sandbox and wait until `ready`; prints its image id (`--no-wait`, `--timeout SEC`). Aliases: `capture`, `save`. |
| `snapshots deploy <snap-id> --location CODE\|ID` | Replicate a ready snapshot to another region (`--no-wait`, `--timeout SEC`). Alias: `replicate`. |
| `snapshots delete <snap-id>...` | Delete one or more custom snapshot copies. Aliases: `rm`, `destroy`. |
| `warm-pools list` (`pools`) | List active warm pools, ready/warming counts, hourly cost and quota. |
| `warm-pools set <image-id> <size>` | Create or resize a warm pool for a custom snapshot (`0` drains it). Aliases: `upsert`, `scale`. |
| `warm-pools delete <pool-id>` | Drain a warm pool back to `0`. Aliases: `rm`, `drain`. |

### Scripting & agents

Every command is designed to compose cleanly in shell scripts, CI pipelines and AI agent tool loops:

- **Clean stdout**: `create`, `fork` and `snapshots create` write only the resulting id to stdout; progress notes go to stderr.
- **Structured JSON**: pass `--json` to any command to get raw JSON on stdout (and structured JSON errors on stderr) for `jq` or programmatic parsing.
- **Ambient sandbox**: `export SPACEYARD_SANDBOX=<uuid>` lets an agent drop the id from every subsequent command.
- **Automatic retries**: HTTP `429` (respecting `Retry-After`) and transient `503` responses right after boot are retried automatically.

```bash
# Run a local test script in a clean sandbox and pull back its artifact
id=$(spaceyard create --ephemeral --name ci-job)
trap 'spaceyard destroy "$id" >/dev/null 2>&1 || true' EXIT

spaceyard cp ./bench.py "$id:/tmp/bench.py"
spaceyard exec "$id" python3 /tmp/bench.py --out /tmp/report.json
spaceyard cp "$id:/tmp/report.json" ./report.json

# List running sandbox IPs with jq
spaceyard list --status running --json | jq -r '.data[] | "\(.uuid) \(.private_ip)"'
```
