Create one or more instances
curl --request POST \
--url https://api.sfcompute.com/preview/v2/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"pool": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"image": "<string>",
"instance_sku": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"infiniband_partition": "<string>",
"enable_public_ipv4": true,
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
}
}
]
}
'import requests
url = "https://api.sfcompute.com/preview/v2/instances"
payload = { "data": [
{
"pool": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"image": "<string>",
"instance_sku": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"infiniband_partition": "<string>",
"enable_public_ipv4": True,
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
}
}
] }
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({
data: [
{
pool: 'pool_k3R-nX9vLm7Qp2Yw5Jd8F',
image: '<string>',
instance_sku: 'isku_k3R-nX9vLm7Qp2Yw5Jd8F',
name: 'my-resource-name',
cloud_init_user_data: 'IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=',
infiniband_partition: '<string>',
enable_public_ipv4: true,
firewall: 'frwl_k3R-nX9vLm7Qp2Yw5Jd8F',
tags: {env: 'prod', team: 'infra'}
}
]
})
};
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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'pool' => 'pool_k3R-nX9vLm7Qp2Yw5Jd8F',
'image' => '<string>',
'instance_sku' => 'isku_k3R-nX9vLm7Qp2Yw5Jd8F',
'name' => 'my-resource-name',
'cloud_init_user_data' => 'IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=',
'infiniband_partition' => '<string>',
'enable_public_ipv4' => true,
'firewall' => 'frwl_k3R-nX9vLm7Qp2Yw5Jd8F',
'tags' => [
'env' => 'prod',
'team' => 'infra'
]
]
]
]),
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 \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\n }\n ]\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.sfcompute.com/preview/v2/instances")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\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::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"instances": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F",
"resource_path": "sfc:instance:<account_id>:<workspace>:<name>",
"owner": "my-resource-name",
"workspace": "my-resource-name",
"workspace_id": "wksp_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"object": "instance",
"status": "awaiting_allocation",
"instance_sku": {
"object": "instance_sku",
"id": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"alias": "my-resource-name"
},
"capacity": {
"id": "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"pool": {
"id": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"created_at": 1738972800,
"updated_at": 1738972800,
"image": {
"id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"cloud_init_user_data_used": true,
"managed_by": {
"id": "depl_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"object": "deployment"
},
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"subnet": "snet_k3R-nX9vLm7Qp2Yw5Jd8F",
"private_ip": "<string>",
"enable_public_ipv4": true,
"public_ip": "<string>",
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"infiniband_partition": "ibpart_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
},
"expected_shutdown_at": 1738972800,
"priority_level": "yield"
}
]
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"message": "<string>"
}
}{
"error": {
"type": "forbidden",
"message": "<string>"
}
}{
"error": {
"type": "not_found",
"message": "<string>"
}
}{
"error": {
"type": "conflict",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "unprocessable_entity",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "api_error",
"message": "<string>"
}
}Instances
Create one or more instances
⚠️ This endpoint is in public preview.
Create one instance, or atomically create a batch of instances under one workspace. Batch create is available only under the preview API prefix.
POST
/
preview
/
v2
/
instances
Create one or more instances
curl --request POST \
--url https://api.sfcompute.com/preview/v2/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"pool": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"image": "<string>",
"instance_sku": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"infiniband_partition": "<string>",
"enable_public_ipv4": true,
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
}
}
]
}
'import requests
url = "https://api.sfcompute.com/preview/v2/instances"
payload = { "data": [
{
"pool": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"image": "<string>",
"instance_sku": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"infiniband_partition": "<string>",
"enable_public_ipv4": True,
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
}
}
] }
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({
data: [
{
pool: 'pool_k3R-nX9vLm7Qp2Yw5Jd8F',
image: '<string>',
instance_sku: 'isku_k3R-nX9vLm7Qp2Yw5Jd8F',
name: 'my-resource-name',
cloud_init_user_data: 'IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=',
infiniband_partition: '<string>',
enable_public_ipv4: true,
firewall: 'frwl_k3R-nX9vLm7Qp2Yw5Jd8F',
tags: {env: 'prod', team: 'infra'}
}
]
})
};
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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'pool' => 'pool_k3R-nX9vLm7Qp2Yw5Jd8F',
'image' => '<string>',
'instance_sku' => 'isku_k3R-nX9vLm7Qp2Yw5Jd8F',
'name' => 'my-resource-name',
'cloud_init_user_data' => 'IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=',
'infiniband_partition' => '<string>',
'enable_public_ipv4' => true,
'firewall' => 'frwl_k3R-nX9vLm7Qp2Yw5Jd8F',
'tags' => [
'env' => 'prod',
'team' => 'infra'
]
]
]
]),
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 \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\n }\n ]\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.sfcompute.com/preview/v2/instances")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\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::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"pool\": \"pool_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"image\": \"<string>\",\n \"instance_sku\": \"isku_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"name\": \"my-resource-name\",\n \"cloud_init_user_data\": \"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=\",\n \"infiniband_partition\": \"<string>\",\n \"enable_public_ipv4\": true,\n \"firewall\": \"frwl_k3R-nX9vLm7Qp2Yw5Jd8F\",\n \"tags\": {\n \"env\": \"prod\",\n \"team\": \"infra\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"instances": [
{
"id": "inst_k3R-nX9vLm7Qp2Yw5Jd8F",
"resource_path": "sfc:instance:<account_id>:<workspace>:<name>",
"owner": "my-resource-name",
"workspace": "my-resource-name",
"workspace_id": "wksp_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"object": "instance",
"status": "awaiting_allocation",
"instance_sku": {
"object": "instance_sku",
"id": "isku_k3R-nX9vLm7Qp2Yw5Jd8F",
"alias": "my-resource-name"
},
"capacity": {
"id": "cap_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"pool": {
"id": "pool_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"created_at": 1738972800,
"updated_at": 1738972800,
"image": {
"id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name"
},
"cloud_init_user_data_used": true,
"managed_by": {
"id": "depl_k3R-nX9vLm7Qp2Yw5Jd8F",
"name": "my-resource-name",
"object": "deployment"
},
"cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo=",
"subnet": "snet_k3R-nX9vLm7Qp2Yw5Jd8F",
"private_ip": "<string>",
"enable_public_ipv4": true,
"public_ip": "<string>",
"firewall": "frwl_k3R-nX9vLm7Qp2Yw5Jd8F",
"infiniband_partition": "ibpart_k3R-nX9vLm7Qp2Yw5Jd8F",
"tags": {
"env": "prod",
"team": "infra"
},
"expected_shutdown_at": 1738972800,
"priority_level": "yield"
}
]
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<string>"
}
]
}
}{
"error": {
"type": "authentication_error",
"message": "<string>"
}
}{
"error": {
"type": "forbidden",
"message": "<string>"
}
}{
"error": {
"type": "not_found",
"message": "<string>"
}
}{
"error": {
"type": "conflict",
"message": "<string>",
"details": [
{
"code": "<string>",
"message": "<string>",
"field": "<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/dashboard/tokens.
Headers
Optional key that makes a batch request idempotent. Retries with the same key return the original instances.
Body
application/json
- Option 1
- Option 2
Required array length:
1 - 100 elementsShow child attributes
Show child attributes
Response
Instance or batch created.
- Option 1
- Option 2
Show child attributes
Show child attributes