Sign in

Sandbox API

Every sandbox route: create, list, pause, resume, fork, delete, and SSH access on the control plane; run commands, read a background command's output as it grows, and move files on the edge; with the fields, states, and error codes.

On this page22

What a sandbox is, and how its lifecycle works, is on Sandboxes. The routes for boxes and the workspace are on API reference.

Two hosts, one key

WhatControl planeEdge
Base URLhttps://api.prized.dev/api/v1The sandbox's toolboxBase
Routes/sandboxes, /sandbox-templates/process/execute, /process/start, /process, /process/{processId}, /process/{processId}/logs, /process/{processId}/kill, /files/upload, /files/download
Errors{"error": "code"}, sometimes with reason, field, or message{"error": "code"}, sometimes with detail or message

Read toolboxBase from the sandbox object rather than building it; it is the same for the sandbox's whole life.

export PRIZED_API_KEY=dcp_…
API=https://api.prized.dev/api/v1
AUTH="Authorization: Bearer $PRIZED_API_KEY"

Each call below passes the header as -H @<(echo "$AUTH"), through a pipe, so the key stays off curl's command line (API reference).

Authentication

Send Authorization: Bearer dcp_… on every request, with an API key from https://prized.dev/dashboard/workspace/api-keys (API keys), or the one an agent gets at agent sign-in. Expiry, revocation, and rotation work as on the rest of the API (Authentication).

KeyReaches
Full accessEvery route below
Read only, or Custom with Sandboxes: ReadGET routes: templates, the list, one sandbox
Custom, Sandboxes: Write, or an agent sign-in keyEvery route below, the edge included
Limited to some boxesNone: 403 key_access_denied

A key acts as the member who made it: an owner's or member's key sees every sandbox in the workspace, and a contractor's gets 404 not_found on every sandbox route. On the free credit alone, a workspace works within the free tier's limits.

Conventions

TopicRule
JSONSend Content-Type: application/json on the control plane. A field the route does not know is 422 unknown_field with field, never ignored.
IdsSandboxes are sbx_…, forks frk_…. An unknown, malformed, deleted, or foreign id is 404 not_found.
202 means in progressPause, resume, fork, and delete answer 202 with the sandbox as written; its state then moves on its own. Poll GET /sandboxes/{id}, or have the API wait for you (Waiting).
IdempotencyPOST /sandboxes and POST /sandboxes/{id}/fork take an Idempotency-Key header (1 to 128 printable characters): a retry with the same key and body answers 200 with the first result, and makes nothing. It does so even where a new create or fork would now be refused (creating or forking paused, a quota, the balance, a hold, no capacity), so a create whose answer was lost can still be found and deleted. The same key with another body is 409 idempotency_conflict.
UnitsmemoryMb is MiB, diskGb is GiB, timers are whole minutes, timestamps are RFC 3339 UTC.
StabilityFields are added without notice; ignore the ones you do not know.

Templates

RouteAnswer
GET /api/v1/sandbox-templates200 {templates: [...]}, each {id, build, resources: {defaults, min, max}, durability, defaultMaxRuntimeMin}
{
  "templates": [
    {
      "id": "prized-base-v1",
      "build": "prized-base-v1-r2",
      "resources": {
        "defaults": {"vcpu": 4, "memoryMb": 8192, "diskGb": 10},
        "min": {"vcpu": 1, "memoryMb": 1024, "diskGb": 10},
        "max": {"vcpu": 32, "memoryMb": 131072, "diskGb": 128}
      },
      "durability": "ephemeral",
      "defaultMaxRuntimeMin": 1440
    }
  ]
}

id is the name a create passes, and defaultMaxRuntimeMin the run time a create in your workspace gets when it names none. build is the image a new sandbox of that name starts from today; it changes when the name is republished with a fix (Sandboxes: Templates), and resources are that build's. What each template holds is on the same page.

Create

POST /api/v1/sandboxes answers 201 {sandbox} with state: "starting", or already running; read it until running. With ?wait=running the answer comes once it is running instead (Waiting). A running sandbox takes commands at once. A create that waits for room may stay starting longer than the hold: its held create answers 201 still starting, and you read it until running.

curl -s -X POST "$API/sandboxes?wait=running" -H @<(echo "$AUTH") -H "Content-Type: application/json" -H "Idempotency-Key: pr-1874-1" -d @<(jq -n '{template: "prized-agent-v1", resources: {vcpu: 2, memoryMb: 4096}, envVars: {ANTHROPIC_API_KEY: env.ANTHROPIC_API_KEY}, labels: {run: "pr-1874"}, autoPauseMin: 10, autoDeleteMin: 60, maxRuntimeMin: 60}')

jq reads ANTHROPIC_API_KEY from your environment (export it first; unset, it is null and the create answers 400), so that key stays off the command line too. The Idempotency-Key is yours to choose, one per sandbox: resend the create with the same key and body, and you get the first sandbox back instead of a second (Conventions).

FieldDefaultRule
templateRequiredA template id from GET /sandbox-templates
resourcesThe template's defaults (capped at 2 vCPU and 4 GB on the free tier){vcpu, memoryMb, diskGb}, any of them, each within the template's min and max (and the free tier's caps); never more than 32 vCPU, 131,072 MiB, and 128 GiB
envVarsNoneUp to 32 names (shell identifiers of up to 64 characters), each value up to 16 KiB; set for every command, stored encrypted, never returned (Environment variables)
labelsNoneUp to 32 string pairs (keys up to 64 characters, values up to 256), yours to filter on
autoPauseMinOffPause after this many idle minutes; 0 is off, up to 40,320
autoDeleteMinOffDelete after this many minutes paused; 0 is off, up to 40,320
maxRuntimeMin1,440 (24 hours); 60 on the free tierIts run time: delete it after this many minutes of running, with the clock restarting on every resume; up to 10,080 (7 days), no maximum on a custom plan. On the free tier, at most 60 minutes of running in all (Run time)

The sandbox object

{
  "sandbox": {
    "id": "sbx_3f9c0a1b2d4e5f60",
    "state": "running",
    "template": "prized-agent-v1",
    "templateBuild": "prized-agent-v1-r2",
    "resources": {"vcpu": 2, "memoryMb": 4096, "diskGb": 10},
    "durability": "ephemeral",
    "labels": {"run": "pr-1874"},
    "autoPauseMin": 10,
    "autoDeleteMin": 60,
    "expiresAt": "2026-10-14T19:02:11Z",
    "maxRuntimeMin": 1440,
    "errorReason": null,
    "toolboxBase": "https://…/v1/sandbox/sbx_3f9c0a1b2d4e5f60",
    "previewUrlTemplate": "https://{port}-sbx-3f9c0a1b2d4e5f60.p.prized.dev/",
    "createdAt": "2026-10-14T17:02:11Z",
    "lastActiveAt": "2026-10-14T17:05:40Z"
  }
}
FieldMeaning
statestarting, running, pausing, paused, resizing, deleting, deleted, or error (States)
templateThe template name it was created from
templateBuildThe build of that template it runs, which it keeps for life: a later republish of the name changes new sandboxes only
durabilityAlways ephemeral
expiresAtWhen its run time ends and it is deleted; null while the clock is stopped, from a few seconds after it reaches paused until it resumes
maxRuntimeMinThe run time it was created with: on a paid plan each resume restarts the clock with it, up to the workspace's maximum then; on the free tier a resume carries on the time left instead. null on a sandbox created before 2026-10-23 until its next resume
errorReasonA short failure explanation, with recovery guidance when known; otherwise null. It remains while a failed sandbox or fork copy is being deleted.
autoPauseMin, autoDeleteMinnull when off
toolboxBaseThe edge address for this sandbox's commands and files
previewUrlTemplateThe URL a port of the sandbox answers at, with {port} for the port (Ports at a URL)
lastActiveAtThe last activity autoPauseMin counts from
memoryDiscardedAtPresent only on a sandbox moved to a new machine without its paused memory: when that happened. Its files were kept and its processes were not, so the next resume starts it fresh, as a create does, and until that resume a fork answers 409 parent_not_forkable

Read

RouteAnswer
GET /api/v1/sandboxes200 {sandboxes: [...]}: every sandbox not deleted, newest first. ?label=key=value lists only those carrying that label (Labels). ?ended=1 adds ended while the workspace is on the free tier: up to 10 sandboxes it deleted at its 60-minute run limit in the last 7 days, newest first, each {id, endedAt, reason: "free_tier_run_limit", limitMin, message}, where message says what lifts the limit and links Billing, and endedTotal, how many there were in all; both keys are left out when there are none
GET /api/v1/sandboxes/{id}200 {sandbox}, or 404 not_found once it is deleted

Lifecycle

RouteBodyAnswer
POST /api/v1/sandboxes/{id}/pause202 {sandbox}, state: "pausing"; with ?wait=paused, 200 once it is paused. A deleting sandbox answers 410 sandbox_deleted
POST /api/v1/sandboxes/{id}/resume202 {sandbox}, state: "starting"; with ?wait=running, 200 once it is running. Checks the balance and the quota like a create. A deleting sandbox answers 410 sandbox_deleted
POST /api/v1/sandboxes/{id}/refresh204: counts as activity for autoPauseMin
POST /api/v1/sandboxes/{id}/fork{count, labels?, maxRuntimeMin?}202 {fork, sandboxes, warning?}, below
POST /api/v1/sandboxes/{id}/resize{resources}409 resize_rejected: resizing is not available yet (Sandboxes: Resize)
POST /api/v1/sandboxes/{id}/extend{byMin}200 {sandbox, capped}, below
POST /api/v1/sandboxes/{id}/timeout{inMin} or {expiresAt}200 {sandbox, capped}, below
DELETE /api/v1/sandboxes/{id}202 {sandbox}, state: "deleting"; again on a deleting sandbox is a no-op. A command still running on it answers 410 sandbox_deleted (The edge)
DELETE /api/v1/sandboxes?label=key=value202 {count, ids, more}: deletes the sandboxes carrying the label (Labels)

Labels

Label sandboxes at create (or fork) and you can list and delete them together: label=key=value selects the sandboxes carrying that label, and repeating it selects those carrying all of them. The key ends at the first =, so a value may hold more, and a key that holds one cannot be selected. Let curl encode the selector, as a raw +, &, or # in a URL changes it:

curl -s -G "$API/sandboxes" --data-urlencode "label=run=pr-1874" -H @<(echo "$AUTH")
curl -s -G -X DELETE "$API/sandboxes" --data-urlencode "label=run=pr-1874" -H @<(echo "$AUTH")
  • A delete by label needs at least one label (400 label_required otherwise) and takes no other parameter (400 bad_request naming it), so it never deletes more than you asked for.
  • Each sandbox is deleted as DELETE /sandboxes/{id} deletes it, and still counts toward your quota until it is gone: list with the same label until the answer is empty.
  • Up to 250 a request. ids lists the sandboxes it left deleting, ones that already were included, and count how many; more: true means matches are left, so send it again. Nothing matching answers {count: 0, ids: [], more: false}.
  • Each request selects the current matches. After a lost answer or a 500, some sandboxes may already be deleting. List the matches before deleting again: another delete can include sandboxes created since the first request.

Waiting

Create, resume and fork take ?wait=running, and pause ?wait=paused: the API holds the answer until the sandbox gets there (for a fork, every child), so there is nothing to poll.

curl -s -X POST "$API/sandboxes/sbx_3f9c0a1b2d4e5f60/resume?wait=running" -H @<(echo "$AUTH")
QueryRule
waitrunning on create, resume and fork, paused on pause; anything else is 400 bad_request with field: "wait"
waitTimeoutMsHow long to hold, a whole number of milliseconds from 0 to 8000; default 8000. The answer can come up to half a second after it, while the API takes its last look at the sandbox. Anything else, or waitTimeoutMs without wait, is 400 bad_request with field: "waitTimeoutMs"
  • It got there. Resume and pause answer 200, create 201, with the sandbox in its new state. A fork answers as it does without wait, with every child running.
  • It did not get there in time. The answer is the one without wait (202, or 201 for a create), with the sandbox as it is by then, still starting or pausing: read it until it settles, as without wait. A create that boots from scratch can outlast the hold.
  • It failed. The hold ends at once, with the sandbox in error or on its way there; the status is the one without wait.
  • It went another way. The hold also ends at once when the sandbox stops heading for that state: deleted (deleting, or gone, which answers as the request was accepted), or asked the other way by a later pause or resume (pausing or starting, or still running or paused if it had not moved yet). The status is the one without wait.
  • A pause sent while the sandbox is still starting, even the moment its create or fork answers, lets the boot finish and then pauses it: it shows pausing from the moment it is sent, and answers 200 once it is paused (or as without wait at the bound).
  • A change that reverses one in flight waits for the box, not the request: resume a sandbox that is still pausing and it shows starting until the pause has landed and it runs again; pause one still resuming and it shows pausing until it is paused. 200 comes only once it is really there.

Fork

count is 1 to 256; labels replaces the parent's on every child; maxRuntimeMin sets each child's lifetime in minutes (on a paid workspace, default the parent's, up to your workspace's maximum; on the free tier it can only shorten the parent's deletion time). The answer lists the children, each starting with its own expiresAt; poll each until running, or send the fork with ?wait=running to have the answer come once they run (Waiting). A fork is all or nothing: if a child cannot start, Prized deletes every child, running ones too. Each shows deleting, with an errorReason saying why, until it is gone (404).

{
  "fork": {
    "id": "frk_9a1c44e0b7d2f318",
    "parentId": "sbx_3f9c0a1b2d4e5f60",
    "count": 2,
    "status": "active",
    "sandboxIds": ["sbx_51d0c2aa9e8b7f64", "sbx_c8e4f1b20a3d9e75"],
    "createdAt": "2026-10-14T17:06:02Z"
  },
  "sandboxes": [{"id": "sbx_51d0c2aa9e8b7f64", "state": "starting", "…": "…"}]
}

On the free tier, children keep the parent's deletion time. When that is under 10 minutes away, the answer adds a warning:

{
  "warning": {
    "code": "short_lifetime",
    "expiresAt": "2026-10-14T17:13:00Z",
    "minutesLeft": 6,
    "message": "These copies are deleted in 6 minutes: on the free tier a fork keeps its parent's expiry. Top up to give each fork its own lifetime."
  }
}

What a child inherits, its lifetime, and the limits are on Sandboxes: Fork.

Resize

Resizing a sandbox is not available yet: the route answers 409 resize_rejected and changes nothing (Sandboxes: Resize).

Run time

A running sandbox's expiresAt can move at any time; a resume restarts the clock on its own (Sandboxes: Run time).

curl -s -X POST "$API/sandboxes/sbx_3f9c0a1b2d4e5f60/extend" -H @<(echo "$AUTH") -H "Content-Type: application/json" -H "Idempotency-Key: extend-pr-1874-1" -d '{"byMin":120}' | jq '{expiresAt: .sandbox.expiresAt, capped}'
RouteRule
extendbyMin, a whole number of minutes, is added to expiresAt (or to now, if that has just passed). It never shortens; past 7 days from now it stops there and answers "capped": true. Send an Idempotency-Key and a retry adds the time once
timeoutExactly one of inMin (minutes from now) or expiresAt (an ISO 8601 time in the future) sets expiresAt, earlier or later. Past 7 days from now it answers 429 sandbox_quota_exceeded, reason max_runtime, with limit in minutes and maxExpiresAt, the latest it allows
  • Running or starting sandboxes. A paused one answers 409 sandbox_not_running: its clock is stopped, and a resume gives it a fresh run time.
  • The free tier never moves the end later: an extend answers "capped": true unchanged, and a timeout may only bring it earlier ("tier": "free" on a refusal). A custom plan has no maximum.

SSH access

A password for any SSH client to one sandbox: shells and commands as prized, and local forwards (ssh -L) to the sandbox's own ports (Sandboxes: SSH access). A key needs Full access or Sandboxes: Write.

curl -s -X POST "$API/sandboxes/sbx_3f9c0a1b2d4e5f60/ssh-access" -H @<(echo "$AUTH") -H "Content-Type: application/json" -d '{"expiresInMinutes":30}'
# {"sandboxId":"sbx_3f9c0a1b2d4e5f60","host":"ssh.prized.dev","port":22,"user":"sbx_3f9c0a1b2d4e5f60","password":"…","expiresAt":"2026-11-02T22:30:00.000Z","command":"ssh sbx_3f9c0a1b2d4e5f60@ssh.prized.dev"}
RouteBodyAnswer
POST /api/v1/sandboxes/{id}/ssh-access{expiresInMinutes?}, or no body201 {sandboxId, host, port, user, password, expiresAt, command}. expiresInMinutes is 1 to 1,440, 60 if left out; the password is shown once, and works for any number of connections until expiresAt, when they end too. A paused sandbox gets one as well, but is not resumed by a connection: resume it first
DELETE /api/v1/sandboxes/{id}/ssh-access200 {revoked}: how many passwords of this sandbox stopped working; connections made with them close shortly after

Connect with user and password at host and port, from OpenSSH (ssh -p PORT USER@HOST, typing the password, or giving it through SSH_ASKPASS) or a library such as ssh2 or Paramiko. Forward to localhost, 127.0.0.1 or ::1; any other destination, a remote forward, and agent or X11 forwarding are refused.

The edge

Routes below are relative to the sandbox's toolboxBase, with the same bearer. They run on a running sandbox, and wake one that is not:

  • Paused or pausing: the request resumes it, as POST /resume would, then waits for running and runs. The resume is billed and counted as activity like any other, and a refused one answers with the resume's own error (409 insufficient_balance, 409 paid_balance_required, 402 template_needs_payment, 429 sandbox_quota_exceeded, …), with nothing run.
  • Starting or resuming: the request waits for running, then runs.
  • The wait is up to 10 seconds, counted from when the edge, having checked the key and looked the sandbox up, finds it not running. Requests with the same key that arrive during a wait share it, deadline included, so a later one waits only what is left of it. Past the deadline the answer is 503 sandbox_not_ready with Retry-After: 1; nothing ran, so retry.
  • A waiting request counts toward the sandbox's edge limits as a running one does: past 8 at once, up to 16 more wait their turn and the rest answer 429 rate_limited.
  • Resizing: a request answers 409 sandbox_not_running at once and wakes nothing. Read the sandbox until it leaves resizing, then retry.
  • Prized-Auto-Resume: false on a request turns waking off for it: a sandbox that is not running answers 409 sandbox_not_running, and nothing wakes. On a running sandbox the header changes nothing: the request runs and counts as activity, so it still holds off automatic pause. To watch a sandbox without keeping it up, read GET /api/v1/sandboxes/{id}, which is not activity.

Once it runs:

  • It takes commands at once. When a create or resume answers running, or a read shows it, send the real command; no warm-up command is needed.
  • Deleting ends what runs. A request still in flight when its sandbox is deleted (by DELETE, its run time, or automatic delete) ends within about 2 seconds: one waiting for its answer, such as a running command, answers 410 sandbox_deleted, and a download already under way stops short. A command that was running is stopped with the sandbox. A request sent to a sandbox that is deleting answers 410 sandbox_deleted at once, and nothing runs.
  • Pausing does not. A command running when its sandbox pauses is paused with it, and its answer comes once the sandbox resumes. Delete the sandbox instead to end it.

Run a command

RouteBodyAnswer
POST /process/execute{command, cwd?, env?, timeout?}200 {stdout, stderr, exitCode, durationMs, timedOut?}
curl -s -X POST "$TOOLBOX/process/execute" -H @<(echo "$AUTH") -H "Content-Type: application/json" -d '{"command":"npm test","cwd":"/home/prized/work/app","env":{"CI":"1"},"timeout":600}'
# {"stdout":"…","stderr":"","exitCode":0,"durationMs":8124}
  • How it runs. bash -c as the user prized, in cwd (absolute; /home/prized/work by default), with the create's envVars and then this request's env on top.
  • The answer is the verdict. A command that fails still answers 200; read exitCode.
  • timeout is in seconds, 300 by default and 3,600 at most. At the limit the command and everything it started in its process group are killed: exitCode: -1, timedOut: true. A process that left the group (setsid) runs on until it exits or the sandbox is deleted.
  • From Node, keep it under 300. Node's fetch stops waiting for an answer after 300 seconds, the default timeout itself, so a command that runs to the default limit fails just as its answer comes. Pass a timeout well under that, such as 240, or start a longer job as a background process and read its output as it runs.
  • Output. Each stream keeps its first 4 MiB; the rest is dropped. For more, write to a file and download it.
  • One run per request. An exec whose answer was lost is never retried for you, since it may already have run; retry it yourself only if the command is safe to run twice.
  • To stop a command, use a background process. Closing an exec's connection (an abort, or a client timeout) does not always stop the command; it can run on until its timeout. Start a command you may need to stop as a background process and kill it, and keep timeout short on an exec.
  • Keep /home/prized/work. If a command removes it, every exec that names no cwd answers 400 spawn_failed. Recreate it by running mkdir -p /home/prized/work with cwd set to /home/prized.

Background processes

Start a command that outlives the request, then read its output as it grows. An exec holds the request until the command ends (3,600 seconds and 4 MiB of each stream at most); a start answers at once, the process runs until it exits or its timeout (up to 7 days) or the sandbox ends, and its whole output stays readable. A read answers with what has been printed so far and does not wait for more, so you poll it from the offsets each answer returns.

RouteBody or queryAnswer
POST /process/start{command, cwd?, env?, timeout?}201 {process}
GET /process/{processId}/logsstdoutOffset?, stderrOffset?, limit?, encoding?200 the output from those offsets, and the offsets to read from next
GET /process/{processId}tail?200 {process}, with the end of each log
GET /process200 {processes}, newest first
POST /process/{processId}/kill200 {processId, wasRunning, signal}

Start it. The answer is 201 at once with the process id; the exit code comes later.

curl -s -X POST "$TOOLBOX/process/start" -H @<(echo "$AUTH") -H "Content-Type: application/json" -d '{"command":"for i in 1 2 3 4 5; do echo tick $i; sleep 1; done","timeout":600}'
# {"process":{"processId":"p_f4d800ca16e6","pid":840,"running":true,"lost":false,"exitCode":null,"timedOut":false,"timeout":600,"startedAt":"2026-10-30T21:42:34Z","cwd":"/home/prized/work"}}

Follow it. Read from offset 0, then from the nextStdoutOffset and nextStderrOffset of each answer, until done is true. The loop stops on any answer that is not a read, and waits a second only when a read came back empty.

P=p_f4d800ca16e6 SO=0 SE=0
while true; do
  R=$(curl -s "$TOOLBOX/process/$P/logs?stdoutOffset=$SO&stderrOffset=$SE" -H @<(echo "$AUTH"))
  jq -e 'has("done")' >/dev/null <<<"$R" || { echo "$R" >&2; break; }
  jq -j .stdout <<<"$R"
  jq -j .stderr <<<"$R" >&2
  SO=$(jq .nextStdoutOffset <<<"$R") SE=$(jq .nextStderrOffset <<<"$R")
  [ "$(jq .done <<<"$R")" = true ] && break
  [ "$(jq '(.stdout + .stderr) | length' <<<"$R")" = 0 ] && sleep 1
done
jq '{exitCode, signal, timedOut}' <<<"$R"

Stop it early. The answer comes once the process has ended.

curl -s -X POST "$TOOLBOX/process/p_f4d800ca16e6/kill" -H @<(echo "$AUTH")
# {"processId":"p_f4d800ca16e6","signal":"TERM","wasRunning":true}

A read 1.5 seconds after that start, while the command is still running:

{
  "processId": "p_f4d800ca16e6",
  "running": true,
  "lost": false,
  "exitCode": null,
  "timedOut": false,
  "encoding": "utf-8",
  "stdout": "tick 1\ntick 2\n",
  "stderr": "",
  "stdoutOffset": 0,
  "stderrOffset": 0,
  "nextStdoutOffset": 14,
  "nextStderrOffset": 0,
  "stdoutSize": 14,
  "stderrSize": 0,
  "done": false
}
ParameterOnRule
command, cwd, envstartAs an exec: bash -c as the user prized, in cwd (absolute; /home/prized/work by default), with the create's envVars and then env on top. A field the route does not know is 400 bad_json, with the field in message
timeoutstartSeconds, 1 to 604,800 (7 days); none by default. At the limit the process group gets TERM, and KILL 5 seconds later if it is still there: timedOut: true, and exitCode 143 (137 after KILL)
stdoutOffset, stderrOffsetlogsByte offsets into each stream, from 0 (the default). A read past the end answers 200 with empty output
limitlogsMost bytes returned per stream per read: 262,144 by default, 1 to 1,048,576 (at least 4 with utf-8). Larger output takes several reads
encodinglogsutf-8 (the default) or base64. utf-8 does not end a chunk inside a character while more may follow, so a chunk can be a little short, or empty mid-character, and the next offset is that character's first byte; bytes that are not valid UTF-8 come back as U+FFFD. Use base64 for exact bytes; offsets count bytes either way
tailstatusBytes of each log to return as text: 16,384 by default, up to 1,048,576
  • done is true once the process has ended and both next offsets are at the end of their logs. If the process has ended and done is false, there is more to read: read again at once. stdoutSize and stderrSize are how much each log holds so far.
  • Re-attach. The whole log stays on the sandbox's disk until the sandbox is deleted, so a chatty process counts against diskGb. After a dropped connection, or from another machine, read again from the last offsets you handled: no gap, no repeat.
  • A lost start answer. Every answer to a start that got as far as the sandbox, a 502 or 504 included, carries a Prized-Process-Id header; an answer without it means nothing ran. Read that id with GET /process/{processId} before you start again: 404 process_not_found means it never started, anything else means do not start a second copy.
  • The process (GET /process/{processId}) has processId (p_ and 12 hex characters), pid (its process group), running, exitCode (null while it runs), signal (named from a 128+n exit code, TERM for 143), timedOut, lost, timeout, startedAt, finishedAt, cwd, stdout and stderr (the tails), and stdoutTruncated and stderrTruncated saying a log is longer than its tail. lost is true when it is not running and left no exit code, as after a resize.
  • The list holds every process started in this sandbox, ended ones included, each with processId, pid, running, lost, exitCode, signal, startedAt, and command (its first 200 bytes).
  • Kill sends TERM to the process group, waits up to 5 seconds, then sends KILL; signal is the last one sent, and exitCode is 143 or 137 unless the command handled it. On a process that has ended it answers 200 with wasRunning: false and an empty signal. A child that started its own session (setsid), or is still running after the command exits, is neither tracked by done nor stopped by a kill.
  • Pause. A running process does not keep the sandbox from automatic pause: with autoPauseMin set, the sandbox pauses after that many idle minutes, the process is frozen with it, and it carries on at the next resume. Requests here count as activity, so a client that keeps reading keeps the sandbox up; for a job nobody is watching, create the sandbox with autoPauseMin off.
  • Same edge rules. A well-formed request here wakes a paused sandbox, counts as activity and toward the edge limits, and ends with 410 sandbox_deleted if the sandbox is deleted meanwhile, as an exec does. An id that is not a process of this sandbox is 404 process_not_found.

Files

RouteBody or queryAnswer
POST /files/uploadquery path; the raw file as the body200 {path, size}
GET /files/downloadquery pathThe file as application/octet-stream with Content-Length
curl -s -X POST "$TOOLBOX/files/upload?path=/home/prized/work/app.py" -H @<(echo "$AUTH") --data-binary @app.py
curl -s "$TOOLBOX/files/download?path=/home/prized/work/out.json" -H @<(echo "$AUTH") -o out.json

Paths are absolute and inside /home/prized; symlinks are followed only while they stay inside that directory. An upload creates missing directories and replaces the file whole, never half-written. Downloads are regular files only; list or archive a directory with a command (tar czf /home/prized/out.tgz work) and download that. Each transfer is up to 100 MiB and 10 minutes.

Edge limits

48 concurrent requests and 60 a second (bursts of 120) per key, and 8 concurrent and 20 a second (bursts of 40) per sandbox; a request waiting for its sandbox to wake is one of them. Past 8 at once at a sandbox, up to 16 more requests wait their turn, for 10 seconds at most; past that, or any other limit, the answer is 429 rate_limited with Retry-After. An address that keeps sending keys that do not work (unknown, revoked or expired) gets the same answer until its Retry-After; requests with a working key never count toward that. The request document of an exec or a process start is at most 1 MiB.

Send an exec or process-start document within 60 seconds. An upload that stops sending data for 60 seconds ends with 408 request_timeout; a response closes if the client stops reading it for 60 seconds. These limits apply while sending the request or receiving its answer; a command can still run for its requested timeout.

Ports at a URL

Every port of a sandbox but 22 and 81 answers at https://<port>-<sandbox id>.p.prized.dev/, the sandbox's previewUrlTemplate with {port} filled in, and at the same host under prized.link (browserUrl), the address to open in a browser (Preview a port). Nothing needs creating first. A request gets in with one of three:

  • The API key, with Sandboxes: Write, in Prized-Key (or as Authorization: Bearer). A request to a paused sandbox resumes it and waits up to 10 seconds, as on the edge; Prized-Auto-Resume: false turns that off.
  • A token in the URL's prized_token query parameter, from POST …/ports/{port}/token.
  • Nothing, on a port made public with PUT …/ports/{port}.

The key and the token never reach your app. A redirect your app sends to another host comes back as Prized-Location, not Location, so no client follows it with the key. A token or a public port never wakes a paused sandbox. On p.prized.dev they answer programs, fetch and WebSockets but no page in a browser tab; on prized.link they open in a browser too, the token moving from the URL into a cookie for that host, and a tab's first visit shows a notice that the page is hosted by a Prized user.

RouteBodyAnswer
GET /sandboxes/{id}/ports/{port}200 {preview: {sandboxId, port, url, browserUrl, public, publicExpiresAt}}. url is for programs with the key, browserUrl for a browser
POST /sandboxes/{id}/ports/{port}/token{expiresIn?}: seconds, 60 to 86,400, 3,600 by default; or no body201 {sandboxId, port, url, browserUrl, token, expiresAt}. url and browserUrl carry the token; open browserUrl in a browser. Made with an API key only, and never outlives it
PUT /sandboxes/{id}/ports/{port}{public: true, expiresIn?}: seconds, 300 to 2,592,000, 7 days by default; or {public: false}200 {preview}. A port already public keeps its expiry: make it private, then public again, to change it
TOKEN_URL=$(curl -s -X POST "$API/sandboxes/$ID/ports/3000/token" -H @<(echo "$AUTH") -H 'Content-Type: application/json' -d '{"expiresIn": 600}' | jq -r .url)
curl -s "$TOKEN_URL"

A token ends at its expiresAt, when the key that made it is revoked or expires, when the port is made public or private again, or when the sandbox is deleted. A token, and making a port public, need a workspace that has paid in; a token needs an owner's or member's key, and public the owner's (Preview a port). Refusals of those two routes:

HTTPerrorMeaning
400bad_request, port_reservedA port that is not 1 to 65,535, port 22 or 81, or an expiresIn out of range
422unknown_fieldA field the route does not take, as on every route
402share_links_need_paymentThe workspace has only free credit
403api_key_requiredA token asked for with a dashboard session instead of an API key
403not_allowedMaking a port public with a key or session that is not the owner's
403policy_deniedA token under the anyoneLinksOwnerOnly policy, asked for by a member
403share_links_blocked, workspace_heldPorts that open without the key are turned off for this workspace, or it is on hold; message says why
409share_link_limitThe workspace already has 10 public ports
429rate_limitedToo many tokens, or public changes, in a minute; retry after Retry-After
503preview_unavailablePort URLs are not available right now

Answers the URL itself writes:

HTTPerrorMeaning
401unauthorized, token_expiredNo key or token, or one that is not accepted (expired, revoked, or another port's)
403key_access_deniedThe key lacks Sandboxes: Write, or is limited to some boxes
403workspace_heldThe workspace is on hold; message says why
403ingress_browser_pageA page opened in a browser tab, a frame or an embed on p.prized.dev without the API key; browserUrl is the prized.link URL to open instead
404not_foundNo such sandbox for this key
404ingress_port_reservedPort 22 or 81
409, 429The resume's codes (insufficient_balance, sandbox_quota_exceeded, …)A request with the key needed to resume the sandbox, and the resume was refused
429rate_limitedPast the limits; retry after Retry-After
429ingress_tunnel_limitThe workspace already has 24 ports with a request in flight; retry after Retry-After
502ingress_nothing_listeningNothing in the sandbox listens on that port
503sandbox_not_readyThe sandbox did not reach running within 10 seconds of a request with the key; retry after Retry-After
503sandbox_not_runningThe sandbox is paused or starting, and the request came with a token, on a public port, or with Prized-Auto-Resume: false; with state and Retry-After
502, 503sandbox_unreachable, control_plane_unavailable, edge_busyNothing reached the sandbox this time; retry

Errors

The control plane:

HTTPerrorMeaning
400bad_requestThe body is not a JSON object, or a field has the wrong type or is out of range; for envVars, with field and a message stating the rules; for a wait or waitTimeoutMs the route cannot take, with field naming it (Waiting); for a label that is not key=value within the label limits, with field: "label" (Labels)
400invalid_idempotency_keyNot 1 to 128 printable characters
400label_requiredA delete by label with no label (Labels)
401unauthorizedNo key, or a revoked one; also carries signUp, how a coding agent can sign its person up (Agent sign-in)
401token_expiredThe key has expired, with expiresAt
402template_needs_paymentThe template runs on paid workspaces only, and this workspace has only free credit, on a create or fork, or a resume of one made while it paid: add a plan or a top-up; message, billing and billingUrl link the Billing page
403key_access_deniedThe key lacks Sandboxes: Read or Write, or is limited to some boxes; message names what it needs
403workspace_heldThe key's workspace is on hold (Not allowed), on every route; message says why. The key works again once the hold is lifted
404not_foundNo such sandbox in this workspace, a contractor's key, or a create, fork, or resize while sandboxes are switched off for this workspace (email )
404template_not_foundtemplate is missing or names no template
409paid_balance_requiredFree-tier access is switched off for your workspace, and it has only free credit, on a create, resume, or fork: add a plan or a top-up; message and billing link the Billing page
409insufficient_balanceThe balance is empty; message and billing say a top-up or a plan adds credit, and link the Billing page
409workspace_heldThe workspace is on hold (Not allowed), on a create, resume, fork, or a run-time increase; message says why. The hold paused its running sandboxes; pausing and deleting still work from the dashboard. Email for a review
409workspace_closingThe workspace is being closed, on a create, resume, fork, or a run-time increase; the owner can reopen it (Close or erase the workspace)
409template_inactiveThe template is retired; pick another
409idempotency_conflictThe key was used for another request
409durability_incompatibledurability: "persistent"; every sandbox is ephemeral
409parent_not_runningFork of a sandbox that is neither running nor paused (for example starting or pausing), with its state
409parent_not_forkableThis sandbox cannot be forked. With reason resized_while_paused, it was resized while paused and has no memory to copy: resume it, then fork it. With reason memory_discarded, it moved to a new machine without its paused memory (see memoryDiscardedAt): resume it, then fork it. With reason parent_too_big, its machine cannot hold even one copy beside it: field names what does not fit (vcpu, memoryMb, or diskGb) and message says so; fork a smaller sandbox
409fork_capacityThe parent's machine has room for only fits more copies, with a message saying what to do: fork that many or fewer (when fits is above 0), try again later, or start a new sandbox and fork that, keeping the parent until it runs. The new sandbox and each copy count toward your quota: at the limit, delete sandboxes you no longer need and wait until each answers 404 (a deleting sandbox still counts), or top up on the free tier; never delete a parent while a copy forked from it is still starting
409fork_unsupported_hostThis sandbox's machine cannot fork; create a fresh sandbox and fork that. With reason host_retiring, the machine is being replaced and starts no new sandboxes, and message says so: a smaller count does not help, but a paused sandbox is usually moved to a current machine on its own and forks again from there, so retry later (pause it first if it runs)
409sandbox_not_runningAn extend or timeout on a paused sandbox; resume it first
409sandbox_ssh_unavailableSSH access for a sandbox created before shells became available, or whose template has no user to log in as; create a new sandbox
409resize_rejectedWith reason resize_unavailable and a message: resizing a sandbox is not available yet; create a new sandbox with the shape you need (Sandboxes: Resize)
410sandbox_deletedA pause or resume of a sandbox that is deleting, or in error after losing the machine it ran on: a delete cannot be undone, so create a new sandbox. Once it is gone, it is 404
422unknown_fieldA field the route does not take, named in field, with the route's fields in accepted, the one it most likely meant in hint when there is one (on a create, timeout is maxRuntimeMin and memoryMB is resources.memoryMb), and a message saying both
422invalid_resourcesA key resources does not take (it takes vcpu, memoryMb and diskGb), with hint, accepted and message as for unknown_field; a shape outside the template's bounds, or over the free tier's 2 vCPU and 4 GB (then with "tier": "free", limit in vCPU or MB, a message naming what lifts it, and billing), named in field; field host_capacity means that shape cannot run right now
422invalid_max_runtimemaxRuntimeMin (on a create or fork) is not a positive whole number
422invalid_timeoutAn extend's byMin, or a timeout's inMin or expiresAt, is not a positive whole number or a future time, named in field; a timeout with neither or both of them names fields: ["expiresAt", "inMin"]
422invalid_countA fork count outside 1 to max (256)
422invalid_labelsFork labels that are not up to 32 string pairs
429sandbox_quota_exceededA quota, or a free-tier limit (then with "tier": "free", limit in the reason's unit, a message naming what lifts it with the Billing link, and billing: Billing hints), would be passed, named in reason: sandbox_limit, paused_limit, running_vcpu, running_memory, retained_disk, or max_runtime (a timeout's adds maxExpiresAt); on a resume, extend, or later timeout, customer_disabled means sandboxes are switched off for this workspace (email ). A fork adds admitted, how many children would have fit
429too_many_ssh_accessThe sandbox already has 100 unexpired SSH access passwords; revoke them or wait for some to expire
503sandbox_capacityNo sandbox capacity is free right now. Nothing was created or billed; retry after Retry-After (also retryAfterSec in the body)
503sandboxes_disabled, sandbox_create_disabled, sandbox_fork_disabledSandboxes, or creating or forking them, are paused for maintenance; retry later

The edge:

HTTPerrorMeaning
400bad_json, missing_command, cwd_not_absolute, bad_timeout, bad_envThe exec or process-start document is not the documented shape (a start's bad_timeout states its 1 to 604,800 second range); detail or message says more where it can
400bad_cwd, bad_command, bad_offset, bad_limit, bad_encoding, bad_tailA process cwd or command the sandbox cannot carry (a newline or NUL byte in cwd; a command over 256 KiB or with a NUL byte), or an offset, limit, encoding, or tail outside its range; message states the range (Background processes)
400spawn_failedThe command could not start (a cwd that does not exist); detail has the system's words
400missing_path, path_not_absolute, symlink_not_allowed, not_regular_fileThe path is missing, relative, through a symlink that leaves /home/prized or loops, or not a regular file
401unauthorized, token_expiredAs on the control plane
403key_access_deniedThe key lacks Sandboxes: Write
403workspace_heldAs on the control plane
403path_outside_root, permission_deniedThe path is outside /home/prized, or prized cannot touch it
404not_foundNo such sandbox for this key, or no such file
404process_not_foundNo process with that id in this sandbox (Background processes)
408request_timeoutThe request document did not arrive within 60 seconds, or an upload stopped sending data for 60 seconds. Send a complete request on a new connection
409sandbox_not_runningThe sandbox is not running and the request cannot wake it: it is resizing (retry once it leaves resizing) or failed, or the request sent Prized-Auto-Resume: false
410sandbox_deletedThe sandbox is deleted or being deleted, before or while the request ran (The edge); a command that was running is stopped with it. Do not retry: create a new sandbox
402, 409, 429The resume's codes (insufficient_balance, paid_balance_required, template_needs_payment, sandbox_quota_exceeded, …)The request needed to resume a paused sandbox, and the resume was refused; nothing ran
413body_too_large, file_too_largeOver 1 MiB for an exec or process-start document, or 100 MiB for a file. The same request fails again, so split or shrink it rather than retry; the edge's body_too_large says the limit in message. A request whose Content-Length is over the limit is refused before the key is checked: it wakes no paused sandbox and is not activity
429rate_limitedOver the edge limits; Retry-After says when
502sandbox_unreachableThe sandbox did not answer. An exec or a process start may or may not have run
502process_start_failed, process_unreadableA start or a process read did not complete: a start may or may not have run (its processId and Prized-Process-Id name it; read it before starting again); a read can be sent again, and so can a kill (it answers wasRunning: false if the first one landed)
502resolve_failed, sandbox_credentials_unavailableThe edge could not look the sandbox up; retry
503sandbox_not_readyThe sandbox did not reach running within the edge's 10-second wait (The edge); nothing ran. Retry after Retry-After
504process_op_timed_outA process request did not finish in time; read the process before you retry a start
500control_plane_unavailableThe edge could not reach the control plane to check the key

Not yet

Not yetInstead
Output pushed to you (SSE, WebSocket), or a terminalThe SDKs stream a command's output; without one, start a background process and read its output by offset. For a terminal, prized sandbox ssh or SSH access
Listing, moving, or deleting files through the edgels, mv, and rm through exec
WebhooksPoll GET /api/v1/sandboxes/{id}
An OpenAPI documentThe routes above with curl or any HTTP client, or the Python and TypeScript SDKs