# Create your first sandbox

Create a sandbox, run a command and clean up, from the rzv CLI, the API or the portal.

## With the rzv CLI

- rzv sandboxes create --name \<name\> \[--size 2vcpu-8gb|4vcpu-16gb|8vcpu-32gb|16vcpu-64gb\] \[--disk-gib 20\] creates and starts a sandbox. rzv sandboxes list shows which sizes can start now.
- rzv sandboxes list shows each sandbox's status, time left and credits used, the sizes on offer and the running limit. rzv sandboxes get \<sandbox-id\> shows one.
- rzv sandboxes exec \<sandbox-id\> \[--cwd \<dir\>\] \[--timeout \<seconds\>\] \[--env A=1,B=2\] -- \<command\> runs a command and exits with its status. One argument after -- runs as a shell script; two or more run as that exact argument list, so put pipes or && in a single quoted argument.
- rzv sandboxes ssh \<sandbox-id\> opens an interactive terminal. Every key, Ctrl-C included, goes to the sandbox, so leave with the shell's exit. ssh does not run on Windows; use exec there and in scripts.
- rzv sandboxes terminal-ticket \<sandbox-id\> \[--workspace \<id\>\] \[--json\] prints a single-use terminal ticket, for a browser or your own WebSocket client. With --json it returns url, ticket, expires_at, connect_url, sandbox_id and workspace_id.
- rzv sandboxes stop|start|delete \<sandbox-id\> stops, starts or deletes a sandbox. Every command except ssh accepts --json.

[Install the rzv CLI](https://runzivo.dev/docs/cli/)

## With the API

Send a person's access token, or a workspace API key with the sandboxes:write permission, as a bearer token. Repeating client_operation_id returns the sandbox the first request created.

Create a sandbox, then run a command once it is running

```
curl -X POST https://api.runzivo.dev/v1/customer/tenants/<tenant-id>/sandboxes \
  -H "Authorization: Bearer $RZV_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"agent-1","size":"2vcpu-8gb","client_operation_id":"agent-1-create"}'

curl -X POST https://api.runzivo.dev/v1/customer/tenants/<tenant-id>/sandboxes/<sandbox-id>/exec \
  -H "Authorization: Bearer $RZV_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"uname -a"}'
```

[See API key permissions for sandboxes](https://runzivo.dev/docs/sandboxes-api/#authentication)

## In the portal

- Open Build & Deploy, then Sandboxes, and select New Sandbox.
- Enter a name, choose a size, and select Create sandbox.
- The sandbox page shows its status, time left and credits used. Use Start, Stop and Delete there. While it runs, the page has a terminal.
- If the page says Sandboxes are not available yet, they are not turned on for your environment.

[Open the customer portal](https://app.runzivo.dev/)

On this page and page tools
