---
title: "Execute a command with a known ID, optimistically waiting for completion"
method: POST
path: "/v1/devboxes/{id}/execute"
tags: ["Devbox", "Devbox-ShellTools"]
---

# Execute a command with a known ID, optimistically waiting for completion

`POST /v1/devboxes/{id}/execute`

Execute a command with a known command ID on a devbox, optimistically waiting for it to complete within the specified timeout. If it completes in time, return the result. If not, return a status indicating the command is still running. Note: attach_stdin parameter is not supported; use execute_async for stdin support.

## Path parameters

- `id` string, required

## Query parameters

- `last_n` string

## Request body

- DevboxStartExecutionParameters
  - `command_id` string, required — The command ID in UUIDv7 string format for idempotency and tracking
  - `command` string, required — The command to execute via the Devbox shell. By default, commands are run from the user home directory unless shell_name is specified. If shell_name is specified the command is run from the directory based on the recent state of the persistent shell.
  - `shell_name` string, nullable — The name of the persistent shell to create or use if already created. When using a persistent shell, the command will run from the directory at the end of the previous command and environment variables will be preserved.
  - `optimistic_timeout` integer, nullable — Timeout in seconds to wait for command completion, up to 25 seconds. Defaults to 25 seconds. Operation is not killed.

## Response `200`

OK

- DevboxAsyncExecutionDetailView
  - `devbox_id` string, required — Devbox id where command was executed.
  - `execution_id` string, required — Ephemeral id of the execution in progress.
  - `status` 'queued' | 'running' | 'completed', required
  - `shell_name` string, nullable — Shell name.
  - `stdout` string, nullable — Standard out generated by command. This field will remain unset until the execution has completed.
  - `stderr` string, nullable — Standard error generated by command. This field will remain unset until the execution has completed.
  - `exit_status` integer, nullable — Exit code of command execution. This field will remain unset until the execution has completed.
  - `stdout_truncated` boolean, nullable — Indicates whether the stdout was truncated due to size limits.
  - `stderr_truncated` boolean, nullable — Indicates whether the stderr was truncated due to size limits.

## Other responses

- `404` — Devbox not found.
- `408` — Command timed out.

---

[API](https://skmtc.net/runloopai/apis/runloop-api.md) · [All operations](https://skmtc.net/runloopai/apis/runloop-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/runloopai/runloop-api/versions/ef553a04de89/schema)
