Sandboxes ›
Exec command
POST
/v1/sandboxes/{id}/execRun a command and wait for it.
RequestTypeScript
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
- const result = await sandbox.exec(["npm", "test"]);
Answer200 OK · ExecResult
- {
- "exitCode": integer,
- "stdout": string,
- "stderr": string,
- "truncated": boolean,
- }
Command finished.
Path
idrequiredstring | e.g. "sbx_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
commandrequiredarray 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"] |
timeoutMsinteger | 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
200 Command finished. A non-zero exit code is still HTTP 200.
ExecResult4 fields
exitCodeinteger
stdoutstring
stderrstring
truncatedboolean
Errors and other answers
| 400 | invalid_request timeoutMs is above 90000. This call answers only when its command ends, and a proxy in front of the API stops waiting after 100 seconds, so a longer command is started with POST /v1/sandboxes/{id}/commands, which answers at once. Nothing was run. |
| 404 | Not found. |
| 409 | Sandbox is not running. |
| 503 | sandbox_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.