Plan a workspace switch
curl --request POST \
--url https://api.cool.computer/api/workspaces/switch/plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repo": "<string>",
"branch": "<string>",
"create": true,
"from": "<string>"
}
'import requests
url = "https://api.cool.computer/api/workspaces/switch/plan"
payload = {
"repo": "<string>",
"branch": "<string>",
"create": True,
"from": "<string>"
}
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({repo: '<string>', branch: '<string>', create: true, from: '<string>'})
};
fetch('https://api.cool.computer/api/workspaces/switch/plan', 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/workspaces/switch/plan",
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([
'repo' => '<string>',
'branch' => '<string>',
'create' => true,
'from' => '<string>'
]),
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/workspaces/switch/plan"
payload := strings.NewReader("{\n \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\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/workspaces/switch/plan")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/workspaces/switch/plan")
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 \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"read_only": true,
"ready": true,
"repo": "<string>",
"branch": "<string>",
"create": true,
"workspace_identity": "<string>",
"predicted_slug": "<string>",
"action": "<string>",
"reason": "<string>",
"target_branch": {
"name": "<string>",
"exists": true,
"source": "<string>"
},
"permission_preflight": {
"provider": "<string>",
"repository": "<string>",
"status": "<string>",
"token_scope": "<string>",
"permissions": [
"<string>"
]
},
"pull_requests": {
"status": "<string>",
"matches": [
{
"number": 123,
"url": "<string>",
"state": "<string>",
"draft": true,
"merged": true,
"head_ref": "<string>",
"head_repo": "<string>",
"base_ref": "<string>"
}
],
"ambiguous": true,
"error": "<string>"
},
"actions": [
{
"type": "<string>",
"target": "<string>",
"mutation": true
}
],
"existing_computer": {
"id": "<string>",
"hostname": "<string>",
"slug": "<string>",
"ip": "<string>",
"status": "<string>",
"visibility": "private",
"access": "owner",
"site": true,
"network_policy": {
"mode": "open",
"allowed_hosts": [
"api.example.com"
]
},
"created_at": "2023-11-07T05:31:56Z",
"public_url": "<string>",
"email_address": "jsmith@example.com",
"auto_delete_at": "2023-11-07T05:31:56Z",
"creation_mode": "<string>"
},
"base_branch": {
"name": "<string>",
"exists": true,
"source": "<string>"
}
}{
"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": {}
}GitHub
Plan a workspace switch
Reports, without changing anything, what switching to a GitHub repository branch would do: reuse or create the computer for that workspace, and whether the branch exists. Callers: an account bearer (API key or access token).
POST
/
api
/
workspaces
/
switch
/
plan
Plan a workspace switch
curl --request POST \
--url https://api.cool.computer/api/workspaces/switch/plan \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repo": "<string>",
"branch": "<string>",
"create": true,
"from": "<string>"
}
'import requests
url = "https://api.cool.computer/api/workspaces/switch/plan"
payload = {
"repo": "<string>",
"branch": "<string>",
"create": True,
"from": "<string>"
}
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({repo: '<string>', branch: '<string>', create: true, from: '<string>'})
};
fetch('https://api.cool.computer/api/workspaces/switch/plan', 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/workspaces/switch/plan",
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([
'repo' => '<string>',
'branch' => '<string>',
'create' => true,
'from' => '<string>'
]),
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/workspaces/switch/plan"
payload := strings.NewReader("{\n \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\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/workspaces/switch/plan")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cool.computer/api/workspaces/switch/plan")
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 \"repo\": \"<string>\",\n \"branch\": \"<string>\",\n \"create\": true,\n \"from\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"read_only": true,
"ready": true,
"repo": "<string>",
"branch": "<string>",
"create": true,
"workspace_identity": "<string>",
"predicted_slug": "<string>",
"action": "<string>",
"reason": "<string>",
"target_branch": {
"name": "<string>",
"exists": true,
"source": "<string>"
},
"permission_preflight": {
"provider": "<string>",
"repository": "<string>",
"status": "<string>",
"token_scope": "<string>",
"permissions": [
"<string>"
]
},
"pull_requests": {
"status": "<string>",
"matches": [
{
"number": 123,
"url": "<string>",
"state": "<string>",
"draft": true,
"merged": true,
"head_ref": "<string>",
"head_repo": "<string>",
"base_ref": "<string>"
}
],
"ambiguous": true,
"error": "<string>"
},
"actions": [
{
"type": "<string>",
"target": "<string>",
"mutation": true
}
],
"existing_computer": {
"id": "<string>",
"hostname": "<string>",
"slug": "<string>",
"ip": "<string>",
"status": "<string>",
"visibility": "private",
"access": "owner",
"site": true,
"network_policy": {
"mode": "open",
"allowed_hosts": [
"api.example.com"
]
},
"created_at": "2023-11-07T05:31:56Z",
"public_url": "<string>",
"email_address": "jsmith@example.com",
"auto_delete_at": "2023-11-07T05:31:56Z",
"creation_mode": "<string>"
},
"base_branch": {
"name": "<string>",
"exists": true,
"source": "<string>"
}
}{
"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.
Body
application/json
Response
The plan.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes

