telnyx-edge CLI and with the API.
These examples require a Sandbox-enabled account and a
telnyx-edge release containing the sandbox-cpu commands.telnyx-edge-dev sandbox-cpu openapi, or send a request with telnyx-edge-dev sandbox-cpu api METHOD /v2/compute/sandbox/.... The CLI also has dedicated commands for every documented operation (the token mint is handled automatically), including batch, fork, snapshot, template, network, logs, metrics, events, and file management (ls, stat, mkdir, mv, rm). Check sandbox-cpu --help for the released commands and flags.
Lifecycle requests go to the control plane at api.telnyx.com with the API key. Execs and files go to the data plane in the sandbox’s region with a token. The CLI sends both and handles the token itself. See Architecture.
Prerequisites
- The
telnyx-edgeCLI. See Installation. - A Telnyx API key, stored for the CLI and in
TELNYX_API_KEYfor the API. See Create API Keys. curlandjqfor the API requests.
Workstation
1. Create a Sandbox
Create a sandbox from the official Python image, with a 30-minute lifetime. The CLI waits until the sandbox isrunning and prints its ID.
starting. Poll until it is running before proceeding.
API
2. Get a Token
With the API, request a token from the control plane, and keep it with the base URL of the data plane in the sandbox’s region. The CLI mints and caches the token itself, so it has no step here.API
3. Write a File
Write a script into the workspace disk.Workstation
4. Run It
Run the script as an exec. The CLI streams the script’s output and exits with its exit code. With the API, start the exec, then wait up to 10 seconds for it to finish.-, the CLI writes the file to stdout, and -q drops its summary line.
5. Serve a Port
Start an HTTP server on port 8000 as a second exec. It keeps running beside other execs. The CLI’sexec streams until its command ends, so the server is started in the background inside the sandbox and the exec returns at once.
Shell
6. Pause and Resume
Pause the sandbox. Its memory, processes, and files are saved, and it stops using CPU. The CLI waits until the sandbox ispaused.
resume waits until the sandbox runs again. With the API, connect resumes it and extends its lifetime, as an agent does at the start of each turn.
running again, the HTTP server is still serving. It resumed from where it paused, without a restart.
Shell
7. Terminate
Terminate the sandbox. The CLI asks for a confirmation, which--yes skips.
Next Steps
- Templates start a sandbox with its server already running.
- Fork copies a running sandbox into many.
- Network Limits restrict where a sandbox connects.
- Secrets give a sandbox credentials it never sees.