Skip to Content
Homemade
Dashboard

Sandboxes

Throwaway VMs for agents and scripts. Create one, run commands, delete it.

A sandbox is a VM with no project around it. Your agent or script creates one, runs code in it, reads the results and throws it away. Sandboxes never sleep. Each one is deleted when its time runs out, or sooner when you delete it.

Use them for code an agent wrote, a test you want to run somewhere clean, or anything you don't want on your own machine.

Quickstart with curl

You need an API key. Create one under Account → API keys, or run homemade api-key create --name sandboxes.

export HOMEMADE_API_KEY=hmk_...
API=https://api.homemade.dev/api

# Create a sandbox that lives 15 minutes
ID=$(curl -s -X POST $API/sandboxes \
  -H "Authorization: Bearer $HOMEMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ttlMinutes": 15}' | jq -r .sandbox.id)

# Run a command (it waits for the sandbox to finish starting)
curl -s -X POST $API/sandboxes/$ID/exec \
  -H "Authorization: Bearer $HOMEMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "echo hi && uname -a"}'

# Delete it when you are done
curl -s -X DELETE $API/sandboxes/$ID -H "Authorization: Bearer $HOMEMADE_API_KEY"

The exec answer has the exit code, stdout and stderr. exitCode is null when the command timed out:

{ "exitCode": 0, "stdout": "hi\nLinux ...\n", "stderr": "", "durationMs": 41, "timedOut": false, "stdoutTruncated": false, "stderrTruncated": false }

Quickstart with MCP

Connect your agent to the remote MCP server, then ask it to use a sandbox. It gets these tools:

ToolWhat it does
sandbox_createCreates a sandbox. Optional size, ttlMinutes, env, projectId, region and orgId.
sandbox_execRuns one command and answers its exit code and output. Optional cwd, env and timeoutMs.
sandbox_write_fileWrites a file, as text or base64.
sandbox_read_fileReads a file back.
sandbox_extendSets how long it lives from now, up to 24 hours.
sandbox_deleteDeletes it.
sandbox_list, sandbox_getShows your sandboxes, or one of them.

A prompt like "Make a sandbox, clone my repo into it and run the tests" is enough.

Quickstart with the CLI

homemade sandbox create --ttl-minutes 15
homemade sandbox exec <id> --command "python3 -c 'print(6*7)'"
homemade sandbox write-file <id> --path /tmp/main.py --content 'print(42)'
homemade sandbox read-file <id> --path /tmp/main.py
homemade sandbox extend <id> --ttl-minutes 60
homemade sandbox list
homemade sandbox delete <id> --yes

Add --json to any of them to get the API's answer unchanged. create also takes --size, --env, --project-id, --region and --org-id. exec takes --cwd, --env, --timeout-ms and --stream.

Options

FieldDefaultNotes
ttlMinutes60How long it lives. At most 1440 (24 hours). Change it later with PATCH /api/sandboxes/{id}.
sizeYour plan's default size: small on Pro, tiny on HobbyAny size your plan allows. See Projects and VMs.
envnoneEnv vars every command run through the API gets. Stored encrypted. A command's own env wins over them.
projectIdnoneStart from one of your projects' images instead of the plain base image.
regionYour default regioneu or us. A region that is not open yet is refused.
orgIdYour first teamThe team the sandbox belongs to. An API key always uses its own team.

Files

Write a file anywhere the sandbox user can write. Folders are made for you.

curl -s -X PUT $API/sandboxes/$ID/files \
  -H "Authorization: Bearer $HOMEMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path": "/tmp/main.py", "content": "print(42)"}'

curl -s "$API/sandboxes/$ID/files?path=/tmp/main.py" -H "Authorization: Bearer $HOMEMADE_API_KEY"

Send "encoding": "base64" for binary files, and add &encoding=base64 to read one back. A file can be up to 10 MB.

Lifetime

  • A sandbox never goes to sleep. When its time runs out it is deleted, with everything in it.
  • Deleting one is final. Nothing is kept to recover.
  • If a sandbox would otherwise be put to sleep, for example because your plan's hours ran out, it is deleted instead.
  • Your team's Sandboxes page in the dashboard lists the live ones with their time left and cost, and the ones that ended in the last 24 hours. Each sandbox has a page with a terminal, its files and a log of the commands run through the API. From code, list them with GET /api/sandboxes, homemade sandbox list or the sandbox_list tool.

Billing and limits

A sandbox is billed like any VM: per second of running time at its size's rate, on the pricing page. There is no storage charge after it is deleted. Sandboxes count toward your plan's VM limits, both how many can run at once and how many you can start per minute, hour and day.

Commands that run long

Exec answers when the command ends, so for anything over about 90 seconds add ?stream=1 to get output as it happens, one JSON line per chunk. Set timeoutMs for the command's own limit: 60 seconds by default, up to 600000 (10 minutes). Output over about 500 KB keeps only its last part, and the answer says so with stdoutTruncated or stderrTruncated.

When a request is refused

Creating a sandbox answers 402 when your plan does not allow the size or the verification it needs, and 429 when you reached a plan limit or the rate limit. See Authentication and errors. A command sent to a sandbox that is not running answers 409, and a sandbox that is deleted or not yours answers 404.

On this page