Reference
API reference
Every upstream API call, with its request and response fields. The reference is generated from the platform's API contract, so it always matches what the service accepts.
Basics#
The API speaks ConnectRPC over HTTPS with JSON bodies. Every call is a POST to https://api.upstream.build/upstream.platform.v1.Platform/<Method>, authenticated with your API key as a bearer token.
bash copy
$ curl https://api.upstream.build/upstream.platform.v1.Platform/CreateSandbox \
-H "Authorization: Bearer $UPSTREAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"template": "python"}'
Field names are lowerCamelCase in JSON: sandbox_id is sent as sandboxId.
Bytes fields, such as file contents and command output, are base64-encoded.
64-bit integers are encoded as strings.
Sandbox tokens. CreateSandbox, ForkSandbox and the other calls that create a sandbox return an authToken scoped to it. The SDK sends it with every call on that sandbox in the X-Sandbox-Token header.
Errors#
Errors follow the Connect protocol: a non-200 status with a JSON body carrying a code and a human-readable message.
json copy
{ "code" : "not_found" , "message" : "sandbox sb_7f3a2c not found" }
A missing or invalid key returns 401 or 403, and exceeding a rate limit or quota returns 429.
Sandboxes#
CreateSandbox#
Create a sandbox from a template. Returns its ID and the token for requests to it.
POST /upstream.platform.v1.Platform/CreateSandbox
Request Field Type Description
templatestring Template name.
envmap<string, string> Environment variables.
cwdstring Working directory inside the sandbox
metadatamap<string, string> Your own key-value labels.
volumeMountsVolumeMountSpec []Optional persistent volume mounts
onTimeoutstring "destroy" (default) or "pause".
Response Field Type Description
sandboxIdstring Sandbox ID.
statusstring Current status.
authTokenstring Token for requests to this sandbox. The SDK sends it for you.
example request copy
{
"template" : "python" ,
"env" : {
"DEBUG" : "1"
},
"cwd" : "/workspace" ,
"metadata" : {
"team" : "evals"
},
"volumeMounts" : [
{
"volumeId" : "vol_3c1d8e" ,
"mountPath" : "/data" ,
"readOnly" : false
}
],
"onTimeout" : "pause"
}
GetSandbox#
Get a sandbox's status, template and resources, and its parent if it is a fork.
POST /upstream.platform.v1.Platform/GetSandbox
Request Field Type Description
sandboxIdstring Sandbox ID.
Response Field Type Description
sandboxIdstring Sandbox ID.
statusstring Current status.
templatestring Template name.
vcpuinteger Virtual CPUs.
memoryMibinteger Memory in MiB.
createdAtstring RFC 3339 timestamp.
parentSandboxIdstring Parent sandbox, if this sandbox is a fork. Empty otherwise.
forkLatencyMsinteger How long the fork took, in milliseconds. Zero for sandboxes that are not forks.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
ListSandboxes#
List your sandboxes.
POST /upstream.platform.v1.Platform/ListSandboxes
DeleteSandbox#
Destroy a sandbox and discard its private state.
POST /upstream.platform.v1.Platform/DeleteSandbox
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
RunSandbox#
Create a sandbox and run commands in it, in one round trip.
POST /upstream.platform.v1.Platform/RunSandbox
Request Field Type Description
templatestring Template name.
envmap<string, string> Environment variables.
cwdstring
commandsBatchExecCommand []Commands to execute immediately after creation.
Response Field Type Description
sandboxIdstring Sandbox ID.
statusstring Current status.
authTokenstring Token for requests to this sandbox. The SDK sends it for you.
execResultsExecResponse []Results from the immediate commands.
example request copy
{
"template" : "python" ,
"env" : {
"DEBUG" : "1"
},
"cwd" : "/workspace" ,
"commands" : [
{
"command" : [
"python3" ,
"-c" ,
"print('hello')"
],
"workingDir" : "/workspace" ,
"env" : {
"DEBUG" : "1"
}
}
]
}
KeepAlive#
Extend a sandbox's lifetime.
POST /upstream.platform.v1.Platform/KeepAlive
Request Field Type Description
sandboxIdstring Sandbox ID.
timeoutSecondsinteger (string)
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"timeoutSeconds" : 1800
}
SetTimeout#
Set how long a sandbox may live before its timeout action runs.
POST /upstream.platform.v1.Platform/SetTimeout
Request Field Type Description
sandboxIdstring Sandbox ID.
timeoutSecondsinteger (string)
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"timeoutSeconds" : 1800
}
PauseSandbox#
Suspend a sandbox's VM in place.
POST /upstream.platform.v1.Platform/PauseSandbox
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
ResumeSandbox#
Resume a paused sandbox.
POST /upstream.platform.v1.Platform/ResumeSandbox
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
Forks, clones and snapshots#
ForkSandbox#
Fork a running sandbox. The child resumes with the parent's memory, files and processes, and shares the parent's pages until it writes. The parent's template must be forkable.
POST /upstream.platform.v1.Platform/ForkSandbox
Request Field Type Description
parentSandboxIdstring The sandbox to fork.
workloadIdstring Optional label for the fork.
Response Field Type Description
sandboxIdstring The new fork's ID.
sourceSandboxIdstring The parent sandbox.
statusstring Current status.
authTokenstring Token for requests to this sandbox. The SDK sends it for you.
forkLatencyMsinteger How long the fork took, in milliseconds. Zero for sandboxes that are not forks.
example request copy
{
"parentSandboxId" : "sb_7f3a2c" ,
"workloadId" : "…"
}
CloneSandbox#
Copy a sandbox's state into a new, independent sandbox.
POST /upstream.platform.v1.Platform/CloneSandbox
Request Field Type Description
sandboxIdstring Sandbox ID.
labelstring Human-readable label.
Response Field Type Description
sandboxIdstring Sandbox ID.
sourceSandboxIdstring
statusstring Current status.
authTokenstring Token for requests to this sandbox. The SDK sends it for you.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"label" : "after-install"
}
CreateSnapshot#
Save a sandbox's full state under a label.
POST /upstream.platform.v1.Platform/CreateSnapshot
Request Field Type Description
sandboxIdstring Sandbox ID.
labelstring Human-readable label.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"label" : "after-install"
}
ListSnapshots#
List snapshots, optionally for one sandbox.
POST /upstream.platform.v1.Platform/ListSnapshots
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
RestoreSnapshot#
Start a new sandbox from a snapshot.
POST /upstream.platform.v1.Platform/RestoreSnapshot
Request Field Type Description
snapshotIdstring Snapshot ID.
Response Field Type Description
sandboxIdstring Sandbox ID.
statusstring Current status.
authTokenstring Token for requests to this sandbox. The SDK sends it for you.
example request copy
{
"snapshotId" : "snap_91be04"
}
DeleteSnapshot#
Delete a snapshot.
POST /upstream.platform.v1.Platform/DeleteSnapshot
Request Field Type Description
snapshotIdstring Snapshot ID.
example request copy
{
"snapshotId" : "snap_91be04"
}
Execution#
Exec#
Run a command and wait for it to finish.
POST /upstream.platform.v1.Platform/Exec
Request Field Type Description
sandboxIdstring Sandbox ID.
commandstring[] Program and arguments.
workingDirstring Directory to run in. Defaults to the sandbox's working directory.
envmap<string, string> Environment variables.
Response Field Type Description
exitCodeinteger Exit status of the command.
stdoutbytes (base64) Standard output.
stderrbytes (base64) Standard error.
durationMsinteger (string) Run time in milliseconds.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"command" : [
"python3" ,
"-c" ,
"print('hello')"
],
"workingDir" : "/workspace" ,
"env" : {
"DEBUG" : "1"
}
}
ExecStream#
Run a command and stream its output as it is produced.
POST /upstream.platform.v1.Platform/ExecStream
Server-streaming: the response is a stream of ExecEvent messages.
Request Field Type Description
sandboxIdstring Sandbox ID.
commandstring[] Program and arguments.
workingDirstring Directory to run in. Defaults to the sandbox's working directory.
envmap<string, string> Environment variables.
Response Field Type Description
stdout one of event bytes (base64) Standard output.
stderr one of event bytes (base64) Standard error.
exitCode one of event integer Exit status of the command.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"command" : [
"python3" ,
"-c" ,
"print('hello')"
],
"workingDir" : "/workspace" ,
"env" : {
"DEBUG" : "1"
}
}
BatchExec#
Run several commands in one request.
POST /upstream.platform.v1.Platform/BatchExec
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"commands" : [
{
"command" : [
"python3" ,
"-c" ,
"print('hello')"
],
"workingDir" : "/workspace" ,
"env" : {
"DEBUG" : "1"
}
}
]
}
ListProcesses#
List processes running in the background.
POST /upstream.platform.v1.Platform/ListProcesses
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
Signal#
Send a signal to a process in the sandbox.
POST /upstream.platform.v1.Platform/Signal
Request Field Type Description
sandboxIdstring Sandbox ID.
pidinteger Process ID inside the sandbox.
signalinteger
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"pid" : 4242 ,
"signal" : 15
}
Files#
ReadFile#
Read a file.
POST /upstream.platform.v1.Platform/ReadFile
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
Response Field Type Description
contentbytes (base64) File contents.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
WriteFile#
Write a file, creating it if needed.
POST /upstream.platform.v1.Platform/WriteFile
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
contentbytes (base64) File contents.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py" ,
"content" : "cHJpbnQoJ2hlbGxvJyk="
}
ListFiles#
List a directory.
POST /upstream.platform.v1.Platform/ListFiles
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
StatFile#
Get a file's size, type and timestamps.
POST /upstream.platform.v1.Platform/StatFile
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
Response Field Type Description
namestring
sizeinteger (string)
modeinteger
isDirboolean
modifiedMsinteger (string)
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
MakeDir#
Create a directory.
POST /upstream.platform.v1.Platform/MakeDir
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
recursiveboolean Apply to directory contents too.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py" ,
"recursive" : false
}
Remove#
Remove a file or directory.
POST /upstream.platform.v1.Platform/Remove
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
recursiveboolean Apply to directory contents too.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py" ,
"recursive" : false
}
Rename#
Rename or move a file or directory.
POST /upstream.platform.v1.Platform/Rename
Request Field Type Description
sandboxIdstring Sandbox ID.
oldPathstring
newPathstring
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"oldPath" : "/workspace/draft.py" ,
"newPath" : "/workspace/main.py"
}
BatchWriteFiles#
Write several files in one request.
POST /upstream.platform.v1.Platform/BatchWriteFiles
Request Field Type Description
sandboxIdstring Sandbox ID.
filesBatchFile []
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"files" : [
{
"path" : "/workspace/main.py" ,
"data" : "…"
}
]
}
BatchFileOps#
Apply a mix of file operations in one request.
POST /upstream.platform.v1.Platform/BatchFileOps
Request Field Type Description
sandboxIdstring Sandbox ID.
opsFileOp []
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"ops" : [
{
"read" : {
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
}
]
}
WatchFiles#
Stream filesystem changes under a path.
POST /upstream.platform.v1.Platform/WatchFiles
Server-streaming: the response is a stream of FileWatchEvent messages.
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
recursiveboolean Apply to directory contents too.
Response Field Type Description
eventTypestring "created", "modified", "deleted", "renamed"
pathstring Absolute path inside the sandbox.
isDirboolean
timestampMsinteger (string)
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py" ,
"recursive" : false
}
GetDownloadUrl#
Get a pre-signed URL for downloading a file.
POST /upstream.platform.v1.Platform/GetDownloadUrl
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
Response Field Type Description
urlstring URL.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
GetUploadUrl#
Get a pre-signed URL for uploading a file.
POST /upstream.platform.v1.Platform/GetUploadUrl
Request Field Type Description
sandboxIdstring Sandbox ID.
pathstring Absolute path inside the sandbox.
Response Field Type Description
urlstring URL.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"path" : "/workspace/main.py"
}
Ports and MCP#
ExposePort#
Expose a port from inside the sandbox through the gateway. Returns its URL.
POST /upstream.platform.v1.Platform/ExposePort
Request Field Type Description
sandboxIdstring Sandbox ID.
portinteger Port inside the sandbox.
Response Field Type Description
urlstring URL.
portinteger Port inside the sandbox.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"port" : 8000
}
UnexposePort#
Stop exposing a port.
POST /upstream.platform.v1.Platform/UnexposePort
Request Field Type Description
sandboxIdstring Sandbox ID.
portinteger Port inside the sandbox.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"port" : 8000
}
ListPorts#
List a sandbox's exposed ports.
POST /upstream.platform.v1.Platform/ListPorts
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
GetMcpInfo#
Get connection details for the sandbox's MCP proxy.
POST /upstream.platform.v1.Platform/GetMcpInfo
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
Templates#
ListTemplates#
List built-in and custom templates.
POST /upstream.platform.v1.Platform/ListTemplates
GetTemplate#
Get a custom template.
POST /upstream.platform.v1.Platform/GetTemplate
Request Field Type Description
namestring
Response Field Type Description
idstring
namestring
statusstring Current status.
specJsonstring Template spec as JSON, e.g. {"dockerfile": "FROM …"}.
createdAtstring RFC 3339 timestamp.
example request copy
{
"name" : "my-env"
}
CreateTemplate#
Create a custom template from a Dockerfile.
POST /upstream.platform.v1.Platform/CreateTemplate
Request Field Type Description
namestring
specJsonstring Template spec as JSON, e.g. {"dockerfile": "FROM …"}.
Response Field Type Description
idstring
namestring
statusstring Current status.
specJsonstring Template spec as JSON, e.g. {"dockerfile": "FROM …"}.
createdAtstring RFC 3339 timestamp.
example request copy
{
"name" : "my-env" ,
"specJson" : "{\"dockerfile\":\"FROM python:3.12-slim\\nRUN pip install pandas\"}"
}
DeleteTemplate#
Delete a custom template.
POST /upstream.platform.v1.Platform/DeleteTemplate
Request Field Type Description
namestring
example request copy
{
"name" : "my-env"
}
Volumes#
CreateVolume#
Create a persistent volume that sandboxes can mount.
POST /upstream.platform.v1.Platform/CreateVolume
Request Field Type Description
namestring
sizeGibinteger (string)
example request copy
{
"name" : "my-env" ,
"sizeGib" : 1
}
ListVolumes#
List your volumes.
POST /upstream.platform.v1.Platform/ListVolumes
GetVolume#
Get a volume.
POST /upstream.platform.v1.Platform/GetVolume
Request Field Type Description
idstring
example request copy
{
"id" : "…"
}
DeleteVolume#
Delete a volume.
POST /upstream.platform.v1.Platform/DeleteVolume
Request Field Type Description
idstring
example request copy
{
"id" : "…"
}
Observability#
GetMetrics#
Get a sandbox's CPU, memory and disk usage.
POST /upstream.platform.v1.Platform/GetMetrics
Request Field Type Description
sandboxIdstring Sandbox ID.
example request copy
{
"sandboxId" : "sb_7f3a2c"
}
GetLogs#
Get a sandbox's logs.
POST /upstream.platform.v1.Platform/GetLogs
Request Field Type Description
sandboxIdstring Sandbox ID.
sinceinteger (string) Start of the range, RFC 3339.
example request copy
{
"sandboxId" : "sb_7f3a2c" ,
"since" : "2026-10-01T00:00:00Z"
}
ListEvents#
List lifecycle events such as sandbox.created and sandbox.forked.
POST /upstream.platform.v1.Platform/ListEvents
Request Field Type Description
offsetinteger (string)
limitinteger (string)
typestring filter by event type
sandboxIdstring Sandbox ID.
example request copy
{
"offset" : 0 ,
"limit" : 50 ,
"type" : "…" ,
"sandboxId" : "sb_7f3a2c"
}
GetUsage#
Get compute used over a time range.
POST /upstream.platform.v1.Platform/GetUsage
Request Field Type Description
sincestring Start of the range, RFC 3339.
untilstring End of the range, RFC 3339.
Response Field Type Description
totalSessionsinteger (string)
totalVcpuSecondsnumber
totalGibSecondsnumber
totalDurationSecondsnumber
example request copy
{
"since" : "2026-10-01T00:00:00Z" ,
"until" : "2026-10-31T00:00:00Z"
}
Webhooks#
CreateWebhook#
Receive lifecycle events at your own URL.
POST /upstream.platform.v1.Platform/CreateWebhook
Request Field Type Description
namestring
urlstring URL.
secretstring Shared secret used to sign deliveries.
eventTypesstring[] Event types to deliver, e.g. sandbox.forked. Empty means all.
example request copy
{
"name" : "my-env" ,
"url" : "https://example.com/hooks/upstream" ,
"secret" : "whsec_…" ,
"eventTypes" : [
"sandbox.forked"
]
}
ListWebhooks#
List your webhooks.
POST /upstream.platform.v1.Platform/ListWebhooks
DeleteWebhook#
Delete a webhook.
POST /upstream.platform.v1.Platform/DeleteWebhook
Request Field Type Description
idstring
example request copy
{
"id" : "…"
}
Types#
Message types that appear inside requests and responses.
BatchExecCommand#
Field Type Description
commandstring[] Program and arguments.
workingDirstring Directory to run in. Defaults to the sandbox's working directory.
envmap<string, string> Environment variables.
BatchFile#
Field Type Description
pathstring Absolute path inside the sandbox.
databytes (base64)
BatchWriteResult#
Field Type Description
pathstring Absolute path inside the sandbox.
okboolean
errorstring
FileEntry#
Field Type Description
namestring
isDirboolean
sizeinteger (string)
LogEntry#
Field Type Description
timestampinteger (string) unix millis
streamstring "stdout" or "stderr"
messagestring
McpServerInfo#
Field Type Description
namestring
commandstring Program and arguments.
argsstring[]
MetricEntry#
Field Type Description
namestring
valuenumber
timestampinteger (string) unix millis
PortInfo#
Field Type Description
portinteger Port inside the sandbox.
urlstring URL.
ProcessInfo#
Field Type Description
pidinteger Process ID inside the sandbox.
commandstring Program and arguments.
cwdstring
SandboxEvent#
Field Type Description
eventIdstring
typestring
sandboxIdstring Sandbox ID.
timestampstring RFC3339
payloadstring JSON
SnapshotInfo#
Field Type Description
idstring
sandboxIdstring Sandbox ID.
labelstring Human-readable label.
templatestring Template name.
createdAtstring RFC 3339 timestamp.
TemplateInfo#
Field Type Description
namestring
defaultVcpuinteger
defaultMemoryMibinteger
VolumeInfo#
Field Type Description
idstring
namestring
sizeGibinteger (string)
statusstring Current status.
attachedSandboxstring
createdAtstring RFC 3339 timestamp.
VolumeMountSpec#
Field Type Description
volumeIdstring Volume ID.
mountPathstring Where to mount the volume inside the sandbox.
readOnlyboolean Mount read-only.
WebhookInfo#
Field Type Description
idstring
namestring
urlstring URL.
eventTypesstring[] Event types to deliver, e.g. sandbox.forked. Empty means all.
createdAtstring RFC 3339 timestamp.