curl --request POST \
--url https://api.cool.computer/api/computers/{id}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"execution_id": "<string>",
"command": "<string>",
"cwd": "<string>",
"uid": 1,
"gid": 1,
"shell": "<string>",
"env": {}
}
'import requests
url = "https://api.cool.computer/api/computers/{id}/exec"
payload = {
"execution_id": "<string>",
"command": "<string>",
"cwd": "<string>",
"uid": 1,
"gid": 1,
"shell": "<string>",
"env": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
execution_id: '<string>',
command: '<string>',
cwd: '<string>',
uid: 1,
gid: 1,
shell: '<string>',
env: {}
})
};
fetch('https://api.cool.computer/api/computers/{id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cool.computer/api/computers/{id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'execution_id' => '<string>',
'command' => '<string>',
'cwd' => '<string>',
'uid' => 1,
'gid' => 1,
'shell' => '<string>',
'env' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cool.computer/api/computers/{id}/exec"
payload := strings.NewReader("{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cool.computer/api/computers/{id}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/computers/{id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}"
response = http.request(request)
puts response.read_body{
"execution_id": "<string>",
"status": "succeeded",
"stdout": "<string>",
"stderr": "<string>",
"exit_code": 123,
"signal": "<string>",
"error": "<string>",
"dropped_bytes": 1,
"dropped_frames": 1
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}Run a command
Runs one command inside a computer and waits for its stdout, stderr, and exit status. On a published site with no VM yet, the first command gives it one, with the published files in /home/runtime/app, and waits until it is ready; the site keeps serving the published files. Only the computer’s own account does that: someone it is shared with gets 403 owner_required. A failure answers 502 linux_create_failed and leaves the site as it was.
curl --request POST \
--url https://api.cool.computer/api/computers/{id}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"execution_id": "<string>",
"command": "<string>",
"cwd": "<string>",
"uid": 1,
"gid": 1,
"shell": "<string>",
"env": {}
}
'import requests
url = "https://api.cool.computer/api/computers/{id}/exec"
payload = {
"execution_id": "<string>",
"command": "<string>",
"cwd": "<string>",
"uid": 1,
"gid": 1,
"shell": "<string>",
"env": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
execution_id: '<string>',
command: '<string>',
cwd: '<string>',
uid: 1,
gid: 1,
shell: '<string>',
env: {}
})
};
fetch('https://api.cool.computer/api/computers/{id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cool.computer/api/computers/{id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'execution_id' => '<string>',
'command' => '<string>',
'cwd' => '<string>',
'uid' => 1,
'gid' => 1,
'shell' => '<string>',
'env' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cool.computer/api/computers/{id}/exec"
payload := strings.NewReader("{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cool.computer/api/computers/{id}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/computers/{id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"execution_id\": \"<string>\",\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"uid\": 1,\n \"gid\": 1,\n \"shell\": \"<string>\",\n \"env\": {}\n}"
response = http.request(request)
puts response.read_body{
"execution_id": "<string>",
"status": "succeeded",
"stdout": "<string>",
"stderr": "<string>",
"exit_code": 123,
"signal": "<string>",
"error": "<string>",
"dropped_bytes": 1,
"dropped_frames": 1
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}{
"type": "<string>",
"title": "<string>",
"status": 499,
"code": "<string>",
"detail": "<string>",
"resolution": "<string>",
"context": {}
}Authorizations
A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.
Path Parameters
Stable public computer identifier.
1"cmp_123"
Body
Stable caller identity bound to the target computer and used to reconnect without relaunching the command.
^cmp_[0-9a-f]{24}\.exec\.[0-9a-f]{32}$1x >= 0x >= 0Show child attributes
Show child attributes
Response
Completed command output.
^cmp_[0-9a-f]{24}\.exec\.[0-9a-f]{32}$succeeded, failed, cancelled, owner_lost Retained stdout. Check dropped_bytes and dropped_frames before treating it as complete.
Retained stderr. Check dropped_bytes and dropped_frames before treating it as complete.
Explicit owner or launch failure when status is owner_lost or failed.
x >= 0x >= 0
