Launch a sandbox
Launch from an Agent, then wait until the sandbox isrunning. A new sandbox starts as pending.
- A sandbox launches in the Agent’s data center. Launch cannot move it to a different one.
- Wait for
runningbefore you run commands or transfer files. - The endpoint URL is empty until an endpoint is assigned. It can still be empty for a short time after the sandbox is
running. Python returnsNone.
Labels and lifetime
Add your own labels withmetadata, and set how long the sandbox lives with timeout_seconds.
- Up to 32 keys. Keys match
^[A-Za-z0-9_.-]{1,63}$; values are at most 256 characters. sourceandtask_nameare reserved.- Metadata is visible in the Console and in API responses. Do not put secrets in it.
timeout_secondsis the lifetime in seconds from now. The minimum is 60.- If you omit it, the sandbox uses the platform default lifetime of 24 hours, which renews automatically.
- A positive value pins the expiry, so it no longer renews automatically.
set_timeoutworks while the sandbox is running or paused. It pins the expiry the same way.- Launch does not return the expiry. Call
refreshand readexpires_at.
List and filter sandboxes
- By default the list excludes
stoppedanddeletedsandboxes. Passstatusto include them. - Metadata filters match exactly. Several keys must all match.
- To clean up a batch, filter by a label you set for that run, not by status. Deleting by status can remove other people’s sandboxes in your organization.
Pause and resume
Pause stops run time. Resume brings the sandbox back.
Resume is a cold start. Processes are not restored and the start command does not run again, so restart any services you need after resume.
Timing
- Pause and resume return as soon as the request is accepted. The status is usually
pausingorresuming. Poll withrefresh, or withwait_until_runningafter resume. - A paused sandbox is kept for up to 7 days. Resume it before
paused_expire_at, or it is deleted together with its disk. - Resume without
timeout_secondskeeps the run time that was left when you paused. Passtimeout_seconds(60 or more) to restart the lifetime from now and pin it.
Watch status events
Open an event stream to receive status changes as they happen, for example during a pause or resume.- Event names:
statusis sent by the service,heartbeatmarks keep-alive lines, andmessageis used for unnamed events. - In Go, the client request timeout does not apply to streams. Control the duration with the context and always close the stream.
Delete
- Deleting a sandbox is permanent.
- Deleting an Agent returns HTTP 409 while it still has sandboxes, and can keep returning 409 for a few seconds after the last one is deleted. Delete the sandboxes and snapshots first, then retry the Agent on 409.