SSH
Connect to a box with:SSH keys
Instead of the password, you can log in with an SSH key. A key you add works for all boxes in your account or team.-
Create a key pair, if you don’t have one:
-
In the Upstash Console, go to Box → Settings → SSH Keys, click New SSH Key, and paste the contents of
~/.ssh/upstash_box.pub. -
Connect with the private key:
~/.ssh/id_ed25519, you can leave out -i.
You can also click Generate Key to have Upstash create the key pair. The private key is shown only once and isn’t stored, so save it right away.
sk-) variants, and RSA keys of at least 2048 bits. An account can have up to 20 keys.
API
Run a shell command
A shell command resolves when the command finishes and gives you back the result and status. The SDK waits up to 10 minutes for the result by default (settimeout in the box config to change it). If the request gives up, the command keeps running in the box, so wrap commands that must stop in timeout, for example timeout 60 npm test.
Run a code snippet
You can execute code inside of a box:Check exit status
If the command fails, the run status will be"failed" and its result contains the stderr output.
Chain commands
Pass a full shell expression. Pipes, redirects, and chained commands all work as expected.Hold a command open
exec.command runs a command to completion. When you need to write to stdin, drive an interactive program through a terminal, or signal a process while it runs, start a live session instead.
Stop a long-running command
exec.command only returns once the command exits, so it cannot be stopped midway. To stop a command while it runs, start it as a live session and terminate it.
Retrieve logs
After a command finishes, calllogs() to get the full timestamped output for debugging or auditing.
Examples
Install dependencies before a run
Set up the environment withbox.exec.command(), then hand off to the agent.
Run a build and extract artifacts
Upload the project files, run the build, then download the output. Upload each file individually, sincefiles.upload does not take directories.