Skip to main content
GET
/
sandboxes
/
{sandbox_id}
/
commands
/
{pid}
/
wait
Wait for Command
curl --request GET \
  --url https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/wait \
  --header 'X-API-Key: <api-key>'
{
  "stdout": "<string>",
  "stderr": "<string>",
  "exit_code": 123
}
Blocks until the background process identified by pid completes, then returns the full CommandResult. The process is removed from the tracked list after this call returns. If the PID is not found in the tracked process list, the endpoint returns a CommandResult with exit_code: 1 and a "process not found" message in stderr.

Path Parameters

sandbox_id
string
required
The sandbox identifier. Format: sbx-<8 chars>.
pid
integer
required
Process ID of the background command to wait for.Example: 42

Response

stdout
string
Full standard output produced by the command.
stderr
string
Full standard error output. Contains "process not found" if the PID is not tracked.
exit_code
integer
Exit code returned by the process. 0 indicates success. 1 when the process was not found.

Example

# Start a background command first
curl -X POST https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "cmd": "sleep 2 && echo done", "background": true }'

# Then wait for it
curl https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands/42/wait \
  -H "X-API-Key: YOUR_API_KEY"
Response
{
  "stdout": "done\n",
  "stderr": "",
  "exit_code": 0
}

Error Responses

StatusCause
400pid path parameter is not a valid integer
401Missing or invalid API key
503Sandbox has no VM
502envd daemon inside the VM is unreachable