Skip to main content
A sandbox is an isolated instance launched from an Agent. This page covers its lifecycle. To run commands and move files, see Commands and files.

Launch a sandbox

Launch from an Agent, then wait until the sandbox is running. 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 running before 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 returns None.
Waiting ends in one of three ways:

Labels and lifetime

Add your own labels with metadata, and set how long the sandbox lives with timeout_seconds.
Metadata
  • Up to 32 keys. Keys match ^[A-Za-z0-9_.-]{1,63}$; values are at most 256 characters.
  • source and task_name are reserved.
  • Metadata is visible in the Console and in API responses. Do not put secrets in it.
Lifetime
  • timeout_seconds is 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_timeout works while the sandbox is running or paused. It pins the expiry the same way.
  • Launch does not return the expiry. Call refresh and read expires_at.
In tests, always set timeout_seconds. If your program exits before cleanup, the sandbox is still reclaimed when it expires.

List and filter sandboxes

  • By default the list excludes stopped and deleted sandboxes. Pass status to 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.
What a pause keeps 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 pausing or resuming. Poll with refresh, or with wait_until_running after 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_seconds keeps the run time that was left when you paused. Pass timeout_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: status is sent by the service, heartbeat marks keep-alive lines, and message is 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.