Overview

Build with Spaceyard

Give your agent a computer: start a Linux or Windows desktop in seconds, run commands on it and use it like a person.

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
https://api.spaceyard.dev/v1

Quickstart

  1. Create an account 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 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:
# 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"

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

Authentication

Every request carries your API key as a bearer token:

Header
Authorization: Bearer <your API key>

An account has one key. Making a new one on the 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.

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The image id field is required.",
    "details": {
      "image_id": [
        "The image id field is required."
      ]
    }
  }
}
StatusCodeMeans
401UNAUTHENTICATED, INVALID_TOKENNo key, or not a valid one.
403ACCOUNT_BANNEDThe account is suspended.
404NOT_FOUNDNo such sandbox on your account, or no such endpoint.
409CONFLICTThe sandbox is not running: start it first.
422VALIDATION_ERRORA parameter is missing or wrong; see details.
422UNPROCESSABLEValid, but refused: not enough credit, over your account's limits, or out of stock. The message says which.
429RATE_LIMITEDToo many requests; wait for Retry-After seconds.
503UNAVAILABLEThe sandbox did not answer, usually because it has only just started. Try again in a few seconds.
500INTERNAL_ERRORSomething 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:

RequestsPer minute
Computer use600
Run a command120
Create, start and stop30, and they count toward the 60 below too
Everything else60

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:

creatingBeing made. Ask again in a few seconds.
startingBooting after a start.
runningUp: commands and computer use work.
stopping, stoppedShut down. Its disk is kept, and start brings it back as it was.
deleting, deletedDestroyed, disk and all.
failedCould 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, 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 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
{
  "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 page.

Live desktop

To watch what an agent is doing, or to take over, open the sandbox in the console: 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 for a tokenized embed_url (ready for an <iframe>) and a one-time VNC WebSocket URL.