curl --request PATCH \
--url https://api.sfcompute.com/preview/v2/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F"
}
]
}
'import requests
url = "https://api.sfcompute.com/preview/v2/instances"
payload = { "data": [{ "id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F" }] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: [{id: 'inst_k3R-nX9vLm7Qp2Yw5Jd8F'}]})
};
fetch('https://api.sfcompute.com/preview/v2/instances', 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.sfcompute.com/preview/v2/instances",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'id' => 'inst_k3R-nX9vLm7Qp2Yw5Jd8F'
]
]
]),
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.sfcompute.com/preview/v2/instances"
payload := strings.NewReader("{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.sfcompute.com/preview/v2/instances")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sfcompute.com/preview/v2/instances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F",
"resource_path": "<string>",
"owner": "<string>",
"workspace": "<string>",
"workspace_id": "<string>",
"name": "<string>",
"object": "instance",
"capacity": {
"id": "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "<string>"
},
"pool": {
"id": "<string>",
"name": "<string>"
},
"created_at": 1738972800,
"updated_at": 1738972800,
"image": {
"id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "<string>"
},
"cloud_init_user_data_used": true,
"instance_sku": {
"object": "instance_sku",
"id": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"alias": "<string>"
},
"managed_by": {
"id": "<string>",
"name": "<string>",
"object": "deployment"
},
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"enable_public_ipv4": true,
"public_ip": "<string>",
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
},
"expected_shutdown_at": 1738972800
}
]
}{
"error": {
"type": "authentication_error",
"message": "<string>"
}
}{
"error": {
"type": "forbidden",
"message": "<string>"
}
}{
"error": {
"type": "unprocessable_entity",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "api_error",
"message": "<string>"
}
}Update multiple instances
⚠️ This endpoint is in public preview.
Update one or more instances atomically. All listed instances must be in the same workspace; mixed-workspace batches are rejected with 422.
curl --request PATCH \
--url https://api.sfcompute.com/preview/v2/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F"
}
]
}
'import requests
url = "https://api.sfcompute.com/preview/v2/instances"
payload = { "data": [{ "id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F" }] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: [{id: 'inst_k3R-nX9vLm7Qp2Yw5Jd8F'}]})
};
fetch('https://api.sfcompute.com/preview/v2/instances', 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.sfcompute.com/preview/v2/instances",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'id' => 'inst_k3R-nX9vLm7Qp2Yw5Jd8F'
]
]
]),
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.sfcompute.com/preview/v2/instances"
payload := strings.NewReader("{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.sfcompute.com/preview/v2/instances")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sfcompute.com/preview/v2/instances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"id\": \"inst_k3R-nX9vLm7Qp2Yw5Jd8F\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F",
"resource_path": "<string>",
"owner": "<string>",
"workspace": "<string>",
"workspace_id": "<string>",
"name": "<string>",
"object": "instance",
"capacity": {
"id": "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "<string>"
},
"pool": {
"id": "<string>",
"name": "<string>"
},
"created_at": 1738972800,
"updated_at": 1738972800,
"image": {
"id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "<string>"
},
"cloud_init_user_data_used": true,
"instance_sku": {
"object": "instance_sku",
"id": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"alias": "<string>"
},
"managed_by": {
"id": "<string>",
"name": "<string>",
"object": "deployment"
},
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"enable_public_ipv4": true,
"public_ip": "<string>",
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
},
"expected_shutdown_at": 1738972800
}
]
}{
"error": {
"type": "authentication_error",
"message": "<string>"
}
}{
"error": {
"type": "forbidden",
"message": "<string>"
}
}{
"error": {
"type": "unprocessable_entity",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "api_error",
"message": "<string>"
}
}Authorizations
Create an API token using sf tokens create or at https://sfcompute.com/account/api-keys.
Body
Request body for PATCH /v2/instances (batch). Each entry in data applies a partial patch to one instance; instances not mentioned are untouched. All entries must succeed or none — a single failure rolls back every other entry's writes (422).
When the same id appears more than once in data, the last occurrence wins.
Show child attributes
Show child attributes
Response
Instances updated.
Response shape for PATCH /v2/instances (batch). Mirrors the input list — one InstanceResponse per unique id in the request body, reflecting the post-write state. Unlike the paginated list response, there's no cursor or has_more: the response is exactly the instances the caller mentioned, no pagination involved.