Skip to main content
The cwsandbox command-line interface (CLI) manages existing CoreWeave sandboxes from your terminal. Use it to inspect sandboxes, run commands, retrieve logs, transfer files, manage file system snapshots, and clean up resources. Install the CLI as an optional extra of the Sandboxes Python client. Create sandboxes with the SDK before using the CLI. Follow the serverless quickstart or Use your own compute to create one.

Prerequisites

Before you begin, prepare the following:

Install and authenticate

Choose the credential you used to create your sandboxes. Run the commands from one tab in your active virtual environment, replacing the credential placeholder with your key or token:
Install the cli and wandb extras, then select the W&B authentication strategy for your Forge API key:
The help output lists the available commands. Keep the authentication variables set in the terminal where you run the remaining examples. CWSANDBOX_AUTH selects the credential strategy. The top-level --auth option overrides it for one invocation. For example, with Forge dependencies and credentials configured:
To see the options for any command or subcommand, use --help:

Find your sandboxes

List sandboxes visible to your credential:
Filter by status, or combine a status and a tag. Replace TAG with a tag attached to your sandboxes:
The default table shows sandbox IDs, statuses, runners, and start times. --output json returns structured output. Repeat --tag or --runner-id to supply multiple filter values.

Inspect a sandbox

Replace SANDBOX_ID_VALUE with an ID from cwsandbox ls, and set it in your terminal:
The following examples use this variable. The details include the sandbox status, runner information, start time, and return code when available.

Run commands

Execute a command in a running sandbox. The command must be available in the sandbox image:
To set the remote working directory, pass --cwd before the remote command. Replace REMOTE_DIRECTORY with an existing directory in the sandbox:
The CLI streams standard output and standard error to your local terminal. When the remote command completes normally, the CLI exits with its exit code.

Open an interactive shell

From a local terminal on macOS or Linux, open an interactive shell:
The default shell is /bin/bash. Use --cmd to choose a different shell or an interactive program installed in the sandbox:
The interactive shell requires a terminal for both standard input and standard output and isn’t supported on Windows. To leave a shell session, type exit or press Ctrl+D. Ctrl+C is forwarded to the remote process.

View logs

Retrieve logs from the sandbox’s main process:
Use --follow to stream new log output. Press Ctrl+C to stop following:
Use --since to filter logs by a timestamp. Replace 2026-09-10 09:00:00 with the start time you want. The CLI interprets a timestamp without a timezone as UTC:
Logs contain standard output and standard error from the main process, which is the command used to create the sandbox. They don’t include output from cwsandbox exec. Sandboxes created with the default keep-alive command produce no log output. Log retrieval requires a running sandbox. Retrieve logs before stopping the sandbox. For more information, see Sandbox logging.

Read and write files

File operations require a running sandbox. To print a remote file to standard output, replace REMOTE_PATH with its path inside the sandbox:
To download the file, add --output with a local destination. Replace LOCAL_PATH with the path where you want to save it:
To upload a file, supply the remote destination first and the existing local source file second:

Manage file system snapshots

Snapshot creation requires a running sandbox configured with a file system snapshot mount. Your organization must be enabled for file system snapshots. Create a snapshot:
The command waits for the snapshot to become ready and prints its ID. To return without waiting for readiness and print the ID as JSON, use:
List snapshots, or filter to ready snapshots created from a specific sandbox:
To inspect a snapshot, replace SNAPSHOT_ID_VALUE with its ID:
To delete a snapshot you no longer need, run:
For snapshot requirements, supported storage, and restoring a sandbox with the SDK, see File system snapshots.

Stop or delete a sandbox

Stop a sandbox when you finish using it:
To allow up to 30 seconds for graceful shutdown, use this alternative:
For a sandbox configured with a file system snapshot mount, capture a snapshot before stopping with this alternative:
To delete a sandbox, run:
For cleanup scripts, use --missing-ok so an already missing sandbox doesn’t cause an error:
Last modified on October 27, 2026