Skip to main content
POST
/
preview
/
v2
/
instance_templates
Create instance template
curl --request POST \
  --url https://api.sfcompute.com/preview/v2/instance_templates \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "workspace": "<string>",
  "image": "<string>",
  "name": "my-resource-name",
  "cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo="
}
'
{
  "id": "itmpl_k3R-nX9vLm7Qp2Yw5Jd8F",
  "resource_path": "<string>",
  "owner": "<string>",
  "workspace": "<string>",
  "workspace_id": "<string>",
  "name": "<string>",
  "object": "instance_template",
  "image": {
    "id": "image_k3R-nX9vLm7Qp2Yw5Jd8F",
    "name": "<string>"
  },
  "cloud_init_user_data_used": true,
  "created_at": 1738972800,
  "cloud_init_user_data": "IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo="
}

Authorizations

Authorization
string
header
required

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

Body

application/json
workspace
string
required

Workspace to create this template 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"

image
string
required

Machine image to use when starting instances with this template. Accepts name or ID.

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

"image_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"

cloud_init_user_data
string<byte>

Base64-encoded cloud-init user data. Maximum 64KB.

Example:

"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo="

Response

Instance template created.

id
required

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

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

"itmpl_k3R-nX9vLm7Qp2Yw5Jd8F"

resource_path
string
required

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

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

"sfc:instance_template:<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
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"

object
string
default:instance_template
required
read-only
Allowed value: "instance_template"
image
object
required

Machine image to use when starting instances with this template.

cloud_init_user_data_used
boolean
required

Whether cloud-init user data is configured for this template.

created_at
integer<int64>
required

Unix timestamp.

Example:

1738972800

cloud_init_user_data
string<byte>

Base64-encoded cloud-init user data.

Example:

"IyEvYmluL2Jhc2gKZWNobyBoZWxsbyB3b3JsZAo="