curl --request PUT \
--url https://console.vast.ai/api/v1/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": 123456,
"hash_id": "5915f1dc1ce881defb572015eb9d8178",
"name": "Example Template",
"desc": "Updated description",
"image": "vastai/base-image",
"tag": "latest",
"env": "-e MY_VAR=value -p 8000:8000",
"runtype": "ssh",
"ssh_direct": true,
"use_ssh": true,
"docker_login_repo": "",
"docker_login_user": "",
"docker_login_pass": "",
"recommended_disk_space": 16,
"private": true
}
'import requests
url = "https://console.vast.ai/api/v1/template"
payload = {
"id": 123456,
"hash_id": "5915f1dc1ce881defb572015eb9d8178",
"name": "Example Template",
"desc": "Updated description",
"image": "vastai/base-image",
"tag": "latest",
"env": "-e MY_VAR=value -p 8000:8000",
"runtype": "ssh",
"ssh_direct": True,
"use_ssh": True,
"docker_login_repo": "",
"docker_login_user": "",
"docker_login_pass": "",
"recommended_disk_space": 16,
"private": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 123456,
hash_id: '5915f1dc1ce881defb572015eb9d8178',
name: 'Example Template',
desc: 'Updated description',
image: 'vastai/base-image',
tag: 'latest',
env: '-e MY_VAR=value -p 8000:8000',
runtype: 'ssh',
ssh_direct: true,
use_ssh: true,
docker_login_repo: '',
docker_login_user: '',
docker_login_pass: '',
recommended_disk_space: 16,
private: true
})
};
fetch('https://console.vast.ai/api/v1/template', 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://console.vast.ai/api/v1/template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'id' => 123456,
'hash_id' => '5915f1dc1ce881defb572015eb9d8178',
'name' => 'Example Template',
'desc' => 'Updated description',
'image' => 'vastai/base-image',
'tag' => 'latest',
'env' => '-e MY_VAR=value -p 8000:8000',
'runtype' => 'ssh',
'ssh_direct' => true,
'use_ssh' => true,
'docker_login_repo' => '',
'docker_login_user' => '',
'docker_login_pass' => '',
'recommended_disk_space' => 16,
'private' => true
]),
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://console.vast.ai/api/v1/template"
payload := strings.NewReader("{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}")
req, _ := http.NewRequest("PUT", 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.put("https://console.vast.ai/api/v1/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v1/template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"msg": "Created an Edited Copy of Template 123456. New Template ID: 123457",
"template": {
"id": 123,
"hash_id": "<string>"
}
}{
"success": false,
"error": "invalid_args",
"msg": "Template ID is required for update"
}{
"success": false,
"error": "invalid_template",
"msg": "error 404: Template not found"
}edit template
Edits an existing template by creating a new version of it.
Template versions are immutable. Send the template’s numeric id and its current hash_id together with the full set of fields the new version should have; fields you leave out are not carried over from the previous version. The response contains the new version with a new numeric id and a new content-based hash_id. The previous version keeps its id and hash_id, so running instances and shared links that reference it stay valid.
If the template was created by someone else, the new version is created as your own copy. If the body hashes to the same hash_id as the current version, nothing is created and the response reports that no edits were made.
If a read returned ******** for docker_login_user or docker_login_pass, sending that placeholder back keeps the stored credential. Only the template’s creator can do this.
PUT /api/v0/template/ is deprecated and returns 410 Gone. Use this endpoint instead.
For detailed usage, see Creating and Using Templates with API.
CLI Usage: vastai update template <hash_id> [options]
curl --request PUT \
--url https://console.vast.ai/api/v1/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": 123456,
"hash_id": "5915f1dc1ce881defb572015eb9d8178",
"name": "Example Template",
"desc": "Updated description",
"image": "vastai/base-image",
"tag": "latest",
"env": "-e MY_VAR=value -p 8000:8000",
"runtype": "ssh",
"ssh_direct": true,
"use_ssh": true,
"docker_login_repo": "",
"docker_login_user": "",
"docker_login_pass": "",
"recommended_disk_space": 16,
"private": true
}
'import requests
url = "https://console.vast.ai/api/v1/template"
payload = {
"id": 123456,
"hash_id": "5915f1dc1ce881defb572015eb9d8178",
"name": "Example Template",
"desc": "Updated description",
"image": "vastai/base-image",
"tag": "latest",
"env": "-e MY_VAR=value -p 8000:8000",
"runtype": "ssh",
"ssh_direct": True,
"use_ssh": True,
"docker_login_repo": "",
"docker_login_user": "",
"docker_login_pass": "",
"recommended_disk_space": 16,
"private": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 123456,
hash_id: '5915f1dc1ce881defb572015eb9d8178',
name: 'Example Template',
desc: 'Updated description',
image: 'vastai/base-image',
tag: 'latest',
env: '-e MY_VAR=value -p 8000:8000',
runtype: 'ssh',
ssh_direct: true,
use_ssh: true,
docker_login_repo: '',
docker_login_user: '',
docker_login_pass: '',
recommended_disk_space: 16,
private: true
})
};
fetch('https://console.vast.ai/api/v1/template', 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://console.vast.ai/api/v1/template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'id' => 123456,
'hash_id' => '5915f1dc1ce881defb572015eb9d8178',
'name' => 'Example Template',
'desc' => 'Updated description',
'image' => 'vastai/base-image',
'tag' => 'latest',
'env' => '-e MY_VAR=value -p 8000:8000',
'runtype' => 'ssh',
'ssh_direct' => true,
'use_ssh' => true,
'docker_login_repo' => '',
'docker_login_user' => '',
'docker_login_pass' => '',
'recommended_disk_space' => 16,
'private' => true
]),
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://console.vast.ai/api/v1/template"
payload := strings.NewReader("{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}")
req, _ := http.NewRequest("PUT", 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.put("https://console.vast.ai/api/v1/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v1/template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 123456,\n \"hash_id\": \"5915f1dc1ce881defb572015eb9d8178\",\n \"name\": \"Example Template\",\n \"desc\": \"Updated description\",\n \"image\": \"vastai/base-image\",\n \"tag\": \"latest\",\n \"env\": \"-e MY_VAR=value -p 8000:8000\",\n \"runtype\": \"ssh\",\n \"ssh_direct\": true,\n \"use_ssh\": true,\n \"docker_login_repo\": \"\",\n \"docker_login_user\": \"\",\n \"docker_login_pass\": \"\",\n \"recommended_disk_space\": 16,\n \"private\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"msg": "Created an Edited Copy of Template 123456. New Template ID: 123457",
"template": {
"id": 123,
"hash_id": "<string>"
}
}{
"success": false,
"error": "invalid_args",
"msg": "Template ID is required for update"
}{
"success": false,
"error": "invalid_template",
"msg": "error 404: Template not found"
}Authorizations
API key must be provided in the Authorization header
Body
Numeric ID of the template version to edit. Must be the version identified by hash_id.
Current hash ID of the template version to edit.
Name of the template
Docker image path
Docker image tag. Can also be included in the image field instead.
Environment variables and port mappings in Docker flag format.
Example: "-e HF_TOKEN=hf_xxx123456789 -p 8000:8000"
Commands to run when the instance starts
Launch mode for instances created from this template
ssh, jupyter, args Enable direct SSH connection
Enable SSH access to instances created from this template
Enable direct Jupyter connection
Directory to launch Jupyter from
Use JupyterLab instead of Jupyter Notebook
Name of the private Docker repo (i.e docker.io)
Username for private Docker repo
Access token or password for private Docker repo
Additional machine search filters. Example: {"cuda_max_good": {"gte": 12.6}}
Recommended disk space in GB
Short description of the template
Longer documentation/readme content for the template
Arguments string passed to the container entrypoint when runtype is args
Link to Docker Hub or image documentation
Repository identifier (e.g., library/ubuntu)
Whether the template is private (not publicly searchable)
UI hint for volume configuration