Skip to main content
POST
/
preview
/
v2
/
images
Create image
curl --request POST \
  --url https://api.sfcompute.com/preview/v2/images \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "workspace": "<string>",
  "name": "my-resource-name"
}
'
import requests

url = "https://api.sfcompute.com/preview/v2/images"

payload = {
    "workspace": "<string>",
    "name": "my-resource-name"
}
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({workspace: '<string>', name: 'my-resource-name'})
};

fetch('https://api.sfcompute.com/preview/v2/images', 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/images",
  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([
    'workspace' => '<string>',
    'name' => 'my-resource-name'
  ]),
  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/images"

	payload := strings.NewReader("{\n  \"workspace\": \"<string>\",\n  \"name\": \"my-resource-name\"\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/images")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"workspace\": \"<string>\",\n  \"name\": \"my-resource-name\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.sfcompute.com/preview/v2/images")

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  \"workspace\": \"<string>\",\n  \"name\": \"my-resource-name\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
  "resource_path": "<string>",
  "owner": "<string>",
  "workspace": "<string>",
  "workspace_id": "<string>",
  "name": "<string>",
  "is_public": true,
  "object": "image",
  "created_at": 1738972800,
  "sha256": "<string>"
}
{
  "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": "conflict",
    "message": "<string>",
    "details": [
      {
        "code": "<string>",
        "message": "<string>",
        "field": "<string>"
      }
    ]
  }
}
{
  "error": {
    "type": "api_error",
    "message": "<string>"
  }
}

Authorizations

Authorization
string
header
required

Create an API token using sf tokens create or at https://sfcompute.com/account/api-keys.

Body

application/json

Start a multipart image upload. Max image size is 128 GiB.

workspace
string
required

Workspace to create this image in.

Pattern: (wksp_[0-9a-zA-Z_-]{1,21})|(sfc:workspace:[a-zA-Z0-9._-]+(:[a-zA-Z0-9._-]+){1,1})
Example:

"wksp_k3R-nX9vLm7Qp2Yw5Jd8F"

name
null | string
Required string length: 1 - 255
Pattern: [a-zA-Z0-9][a-zA-Z0-9._-]{0,254}
Example:

"my-resource-name"

Response

Image created

id
required

Accepts the canonical prefix below; additional legacy prefixes are aliased for read compatibility. Writes always emit the canonical form.

Pattern: image_[0-9a-zA-Z_-]{1,21}
Example:

"image_k3R-nX9vLm7Qp2Yw5Jd8F"

resource_path
string
required

A resource path for a image resource. Format: sfc:image:::.

Pattern: sfc:image:([a-zA-Z0-9._-]+:){2}[a-zA-Z0-9._-]+
Example:

"sfc:image:<account_id>:<workspace>:<name>"

owner
string
required
Required string length: 1 - 255
Pattern: [a-zA-Z0-9][a-zA-Z0-9._-]{0,254}
Example:

"my-resource-name"

workspace
string
required
Required string length: 1 - 255
Pattern: [a-zA-Z0-9][a-zA-Z0-9._-]{0,254}
Example:

"my-resource-name"

workspace_id
string
required

The workspace that owns this image.

Pattern: wksp_[0-9a-zA-Z_-]{1,21}
Example:

"wksp_k3R-nX9vLm7Qp2Yw5Jd8F"

name
string
required
Required string length: 1 - 255
Pattern: [a-zA-Z0-9][a-zA-Z0-9._-]{0,254}
Example:

"my-resource-name"

is_public
boolean
required

Whether this is an sfc-provided public image.

object
string
default:image
required
read-only
Allowed value: "image"
upload_status
enum<string>
required
Available options:
started,
uploading,
completed,
failed,
revoked
created_at
integer<int64>
required

Unix timestamp.

Example:

1738972800

sha256
string | null
Required string length: 64
Pattern: ^[a-f0-9]{64}$