/v1/vms/{uid}/execRuns one non-interactive command on a running VM over SSH and waits for it to finish. The
command runs as bash -lc '<command>'.
- Command execution through the API is off by default. A workspace owner or admin must
turn it on in workspace settings, otherwise this returns
403. - Requires the
runtime connectpermission (owner, admin or developer role). - The command times out after 30 seconds by default, or
timeout_seconds(max 60). stdoutandstderrare each capped at 64 KiB. Truncation is flagged in the response.- Each user can have at most 4 console sessions and commands open at once.
- The first command on an older VM may return
409while command access is set up. Retry after about 30 seconds.
A non-zero exit_code is still a 200 response. When the command times out, timed_out
is true and exit_code is usually 124, or -1 if the VM never returned one.
Authentication
Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.
Path parameters
uidstringRequiredThe VM's uid.
Headers
X-Workspace-SlugstringRequiredSlug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.
Request body
commandstringRequiredShell command to run. Leading and trailing whitespace is trimmed. At most 8192 bytes.
max length 8192
timeout_secondsintegerSeconds to let the command run. Values above 60 are capped at 60. 0 or omitted means 30.
Default 30min 1 · max 60
Response
The command ran. Check exit_code to see whether it succeeded.
successbooleanRequiredtrue when the request succeeded.
messagestringRequiredHuman-readable status message.
dataobjectShow attributesHide attributes
exit_codeintegerRequiredExit status of the command. 124 usually means it hit the timeout. -1 means no exit status was returned.
stdoutstringRequiredStandard output, up to 64 KiB. Invalid UTF-8 is replaced.
stderrstringRequiredStandard error, up to 64 KiB. Invalid UTF-8 is replaced.
stdout_truncatedbooleanPresent and true when stdout was cut at 64 KiB.
stderr_truncatedbooleanPresent and true when stderr was cut at 64 KiB.
timed_outbooleanPresent and true when the command was stopped by the timeout.
duration_msintegerRequiredHow long the command ran, in milliseconds.
Errors
| Status | Meaning |
|---|---|
400 | command is missing or empty (command is required), or longer than 8192 bytes (command is too long). |
401 | The API key is missing, invalid, expired or revoked. |
403 | Your role cannot connect to VMs, or command execution is turned off for this workspace. |
404 | The resource does not exist or you cannot access it. |
409 | The command could not be run right now: vm is not running, vm network route is not ready, too many open console sessions or commands; try again shortly, enabling command access on this VM; retry in about 30 seconds, this VM can't accept commands yet; connect with SSH instead, or unable to reach the VM over SSH. |
Errors use the standard error format.