Run a command
Runs a command inside the guest and waits for it, up to timeout_s.
On the hosted API a foreground request is cut off at the edge after about 120 seconds, whatever timeout_s says (a 524). The command keeps running, and until timeout_s runs out — or the command ends, if that is sooner — it holds the computer’s guest agent, so another exec, a clipboard, window or file call on that computer can answer 409 in that time, and so can input that goes through the guest agent: a paste, or a type whose text is not plain ASCII. Screenshots, pointer and key input, and a type of plain ASCII text do not wait on it. Use background: true for anything that may take more than about 100 seconds.
Pass background: true for a command that outlives the request: the response is a handle carrying the guest pid, and you read its output with GET /computers/{id}/exec/{pid} and stop it with the DELETE. timeout_s means nothing alongside it, because not waiting is the whole request. One computer may hold at most 16 background commands. A seventeenth answers 409 without a reason: the existing commands may be long-lived servers, so retrying does not necessarily help; stop one of the handles you already hold first.
A stopped computer answers 409 with reason: "unavailable", a foreground command or a background one: start it first. Waiting does not clear it. A computer that stops while its command is starting or running answers the same, and that command may have run in part, so decide for yourself whether to send it again. A computer being moved to another host answers 409 with reason: "contention" instead, and the same request works once the move finishes. A command the move itself cuts off answers 409 unavailable, as any other stop does: it may have run in part, so it is not one to send again without deciding to.
A suspended computer is resumed to run the command — after session, env and cwd have been checked, so a request refused for one of them, or for asking a Windows guest for a desktop or background command, never resumes or bills the computer.
Explicit retain_output:true or a finite options object captures only the already-returned completed synchronous response. Missing/false performs no retained storage work. The option is public/internal only; it does not open session exec. Effective background:true with retention, duplicate canonical options, or trailing non-whitespace after an enabled first object is invalid_retain_output 400 before dispatch. Original request bytes are forwarded unchanged. Optional admission adds at most 1000 milliseconds and publication at most 5000 milliseconds; inspection is bounded at 50331648 response bytes. Only successful immutable publication adds result_id. Every optional failure preserves the original command status/body with X-GC-Retained-Output: unavailable. Missing/false adds no header. Original credential loss takes precedence over private delivery; a refused or lost response does not prove the command did not run. Never replay exec to repair retention.
Requires the member role or higher.
Request
- Base URL: https://app.mandala.computer/api/v1
- URL: https://app.mandala.computer/api/v1/computers/{id}/exec
- Auth: HTTP bearer
Path parameters
The computer id.
Request body
Response
The command finished inside timeout_s. This is its result.
Changes
No recorded changes to this operation across all 1 revision of this API.