Docs
Commands and files ›

Start command

POST/v1/sandboxes/{id}/commands

Start a command without waiting.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
  4. const command = await sandbox.commands.start(["npm", "run", "build"]);
Answer201 Created · StartedCommand
  1. {
  2. "id": string,
  3. "pid": integer | null,
  4. "status": string,
  5. }

Detached command.

Path

idrequired
string
e.g. "sbx_0123456789abcdef"

Headers

Authorizationrequired
Bearer key
An API key that may make this call.

Body

commandrequired
array of string
Argv. The control plane does not invoke a shell. It runs as root, with the variables of the sandbox's template and its own in its environment, and AGENTAL_SANDBOX_ID, the sandbox's id, AGENTAL_API_URL, where this API answers, and AGENTAL_SANDBOX_TOKEN, the sandbox's own token for the run it is in, which reads and moves its stop and does nothing else. e.g. ["echo","hello"]
timeoutMs
integer
Defaults to 60000. On timeout the exit code is 124. Up to 600000 for /commands and /exec/stream, and up to 90000 for POST /v1/sandboxes/{id}/exec, which answers only when its command ends: a proxy in front of the API stops waiting after 100 seconds.

Returns

201 Detached command. pid is the process id when one is reported, otherwise null.

StartedCommand3 fields
id
string
pid
integernull
status
string

Errors and other answers

404 Not found.
409 Sandbox is not running.
503sandbox_moved the sandbox was moved to another server while this was being done, and it was cut off. Send it again.

Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.