curl --request POST \
--url https://api.cool.computer/api/computers/{id}/service/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "python3 -m http.server 3000",
"port": 3000
}
'import requests
url = "https://api.cool.computer/api/computers/{id}/service/run"
payload = {
"command": "python3 -m http.server 3000",
"port": 3000
}
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({command: 'python3 -m http.server 3000', port: 3000})
};
fetch('https://api.cool.computer/api/computers/{id}/service/run', 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}/service/run",
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([
'command' => 'python3 -m http.server 3000',
'port' => 3000
]),
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}/service/run"
payload := strings.NewReader("{\n \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\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}/service/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/computers/{id}/service/run")
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 \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\n}"
response = http.request(request)
puts response.read_body{
"configured": true,
"status": "<string>",
"public_url": "<string>",
"command": "<string>",
"cwd": "<string>",
"port": 32768,
"exec_id": "<string>",
"pid": 2,
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"signal": "<string>",
"restart_policy": "none",
"readiness": {
"type": "port_ready",
"ready": true,
"continuous": false
},
"logs": {
"retention": "disk_ring",
"bytes_written": 1,
"bytes_dropped": 1,
"dropped_frames": 1,
"next_id": 1
}
}{
"configured": true,
"status": "<string>",
"detail": "<string>",
"public_url": "<string>",
"command": "<string>",
"cwd": "<string>",
"port": 32768,
"exec_id": "<string>",
"pid": 2,
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"signal": "<string>",
"restart_policy": "none",
"readiness": {
"type": "port_ready",
"ready": true,
"continuous": false
},
"logs": {
"retention": "disk_ring",
"bytes_written": 1,
"bytes_dropped": 1,
"dropped_frames": 1,
"next_id": 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 published service
Saves and starts one managed service, then exposes its HTTP port after successful startup. On a published site with no VM yet it gives the computer one first, as exec does. On a computer whose URL serves published files, the files keep being served and the service answers what no file matches. The command must listen on the declared port; one still starting after 60 seconds is kept and answers 202. A later explicit exposure selection is independent of this process. Send an Idempotency-Key when a network failure might cause a retry.
curl --request POST \
--url https://api.cool.computer/api/computers/{id}/service/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "python3 -m http.server 3000",
"port": 3000
}
'import requests
url = "https://api.cool.computer/api/computers/{id}/service/run"
payload = {
"command": "python3 -m http.server 3000",
"port": 3000
}
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({command: 'python3 -m http.server 3000', port: 3000})
};
fetch('https://api.cool.computer/api/computers/{id}/service/run', 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}/service/run",
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([
'command' => 'python3 -m http.server 3000',
'port' => 3000
]),
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}/service/run"
payload := strings.NewReader("{\n \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\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}/service/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/computers/{id}/service/run")
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 \"command\": \"python3 -m http.server 3000\",\n \"port\": 3000\n}"
response = http.request(request)
puts response.read_body{
"configured": true,
"status": "<string>",
"public_url": "<string>",
"command": "<string>",
"cwd": "<string>",
"port": 32768,
"exec_id": "<string>",
"pid": 2,
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"signal": "<string>",
"restart_policy": "none",
"readiness": {
"type": "port_ready",
"ready": true,
"continuous": false
},
"logs": {
"retention": "disk_ring",
"bytes_written": 1,
"bytes_dropped": 1,
"dropped_frames": 1,
"next_id": 1
}
}{
"configured": true,
"status": "<string>",
"detail": "<string>",
"public_url": "<string>",
"command": "<string>",
"cwd": "<string>",
"port": 32768,
"exec_id": "<string>",
"pid": 2,
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"signal": "<string>",
"restart_policy": "none",
"readiness": {
"type": "port_ready",
"ready": true,
"continuous": false
},
"logs": {
"retention": "disk_ring",
"bytes_written": 1,
"bytes_dropped": 1,
"dropped_frames": 1,
"next_id": 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.
Headers
A caller-generated key for safely retrying this side effect. The server retains the key and response for 24 hours. Reusing it with the same request replays the original response; reusing it with different input returns 409.
1 - 128^[!-~]+$"req_01J6M6Y9TF9Q9QF6M1ZP8K4R2A"
Path Parameters
Stable public computer identifier.
1"cmp_123"
Body
1HTTP port to expose after the command starts. Platform ports 3129, 8080 and 18080 are reserved.
1 <= x <= 65535Existing absolute directory used to start the service. Omit it to use /home/runtime/app, created if missing. /, /home and /home/runtime hold credentials and are refused with 400.
Response
The configured service and current process state.
Current lifecycle or process status.
1 <= x <= 65535x >= 1"none"Show child attributes
Show child attributes
Show child attributes
Show child attributes

