Skip to content
Templates

Templates

The Templates API is used to create and manage sandbox templates. Template builds usually include creating a template build record, uploading build files, starting the build, and querying build status.

Create a Template

Description

Creates a new template and returns build task information that can be started later.

Request Path

http
POST /v3/templates

Compatible paths:

http
POST /v2/templates
POST /templates

Request Parameters

Parameters for POST /v3/templates:

ParameterTypeRequiredDescription
namestringNoTemplate name
cpuCountintegerNoDefault CPU core count for the template. Minimum: 1
memoryMBintegerNoDefault memory size for the template, in MiB. Minimum: 128

Parameters for the compatible POST /templates API:

ParameterTypeRequiredDescription
dockerfilestringYesDockerfile content used to build the template
aliasstringNoTemplate alias
startCmdstringNoStart command executed after the template starts
readyCmdstringNoReadiness check command executed after the template starts
cpuCountintegerNoDefault CPU core count for the template
memoryMBintegerNoDefault memory size for the template, in MiB

Response Fields

Returns 202 Accepted on success, indicating that the build task has been created.

Request Example

bash
curl -X POST "$SUFY_SANDBOX_API_URL/v3/templates" \
  -H "X-API-Key: $SUFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-template",
    "cpuCount": 2,
    "memoryMB": 1024
  }'

Get a Build File Upload URL

Description

Gets an upload URL for a template build file. hash is the content hash of the build layer file. If the server cache already has the file, present in the response is true.

Request Path

http
GET /templates/{templateID}/files/{hash}

Path Parameters

ParameterTypeRequiredDescription
templateIDstringYesTemplate ID
hashstringYesBuild file content hash

Response Fields

FieldTypeDescription
presentbooleanWhether the file already exists in the cache
urlstringFile upload URL. Use it when present is false

Start a Template Build

Description

Starts the build task for the specified template.

Request Path

http
POST /v2/templates/{templateID}/builds/{buildID}

Compatible path:

http
POST /templates/{templateID}/builds/{buildID}

Path Parameters

ParameterTypeRequiredDescription
templateIDstringYesTemplate ID
buildIDstringYesBuild ID

Request Parameters

ParameterTypeRequiredDescription
fromImagestringNoBase image to use
fromTemplatestringNoBase template to use
fromImageRegistryobjectNoPrivate image registry configuration
forcebooleanNoWhether to force rebuilding and skip cache. Defaults to false
stepsarrayNoBuild step list
startCmdstringNoStart command executed after the template starts
readyCmdstringNoReadiness check command executed after the template starts

Returns 202 Accepted on success.

List Default Templates

Request Path

http
GET /default-templates

Response Fields

Returns an array of template objects:

FieldTypeDescription
templateIDstringTemplate ID
buildIDstringMost recent successful build ID
cpuCountintegerCPU core count
memoryMBintegerMemory size in MiB
diskSizeMBintegerDisk size in MiB
publicbooleanWhether the template is public
aliasesstring[]Template aliases
createdAtstringTemplate creation time
updatedAtstringTemplate update time
lastSpawnedAtstringMost recent usage time
spawnCountintegerNumber of times the template has been used
buildCountintegerNumber of template builds
envdVersionstringenvd version
buildStatusstringMost recent build status

List Templates

Request Path

http
GET /templates

Response fields are the same as the default template list.

Get Template Details

Request Path

http
GET /templates/{templateID}

Request Parameters

ParameterTypeRequiredDescription
nextTokenstringNoPagination cursor for the build list
limitintegerNoNumber of builds per page. Range: 1 to 100. Defaults to 100

Response Fields

FieldTypeDescription
templateIDstringTemplate ID
publicbooleanWhether the template is public
aliasesstring[]Template aliases
createdAtstringTemplate creation time
updatedAtstringTemplate update time
lastSpawnedAtstringMost recent usage time
spawnCountintegerNumber of times the template has been used
buildsarrayBuild list

Update a Template

Request Path

http
PATCH /templates/{templateID}

Request Parameters

ParameterTypeRequiredDescription
publicbooleanNoWhether to make the template public

Returns the updated template information on success.

Rebuild a Template

Request Path

http
POST /templates/{templateID}

Request Parameters

The parameters are the same as the compatible POST /templates API. Returns 202 Accepted on success.

Delete a Template

Request Path

http
DELETE /templates/{templateID}

Returns 204 No Content on success.

Query Build Status

Request Path

http
GET /templates/{templateID}/builds/{buildID}/status

Request Parameters

ParameterTypeRequiredDescription
logsOffsetintegerNoBuild log start offset
limitintegerNoNumber of log entries to return
levelstringNoLog level filter

Response Fields

FieldTypeDescription
templateIDstringTemplate ID
buildIDstringBuild ID
statusstringBuild status
reasonstringBuild status reason
logsstring[]Build logs
logEntriesarrayStructured build logs

Query Build Logs

Request Path

http
GET /templates/{templateID}/builds/{buildID}/logs

Request Parameters

ParameterTypeRequiredDescription
cursorintegerNoLog cursor
limitintegerNoNumber of log entries to return
directionstringNoLog read direction
levelstringNoLog level filter
sourcestringNoLog source filter

Response Fields

FieldTypeDescription
logsarrayStructured build logs

Get a Template by Alias

Request Path

http
GET /templates/aliases/{alias}

Path Parameters

ParameterTypeRequiredDescription
aliasstringYesTemplate alias

Response Fields

FieldTypeDescription
templateIDstringTemplate ID
publicbooleanWhether the template is public

Request Example

bash
curl -X GET "$SUFY_SANDBOX_API_URL/templates/base" \
  -H "X-API-Key: $SUFY_API_KEY"