Create a reusable Vultr instance template that defines the compute plan, OS, SSH keys, startup script, VPC, and storage for cluster deployments.
An instance template is a reusable blueprint that defines the plan, OS, SSH keys, startup script, VPC, and storage configuration for instances. Templates ensure consistent deployments across a cluster and simplify scaling by eliminating the need to specify configuration details for each new instance.
This guide explains how to create an instance template using the Vultr API.
The following table describes the available fields for creating an instance template:
| Field | Type | Required | Description |
|---|---|---|---|
plan |
string | Yes | The compute plan identifier (e.g., vhp-4c-8gb-intel). |
label |
string | No | A descriptive label for the template. |
os_id |
integer | No | The operating system ID. |
iso_id |
string | No | The ISO image ID. |
snapshot_id |
string | No | The snapshot ID. |
marketplace_app_id |
integer | No | The Marketplace application ID. |
marketplace_image_id |
integer | No | The Marketplace image ID. |
script_id |
string | No | The startup script ID to execute on boot. |
ssh_key_ids |
array | No | Array of SSH key IDs to install on the instance. |
vpc_ids |
array | No | Array of VPC network IDs to attach to the instance. |
vfs_ids |
array | No | Array of Vultr File Storage (VFS) subscription IDs to attach. |
user_data |
string | No | Base64-encoded Cloud-Init user data to initialize and customize the instance at boot. |
plan field. All other fields are optional. To set an image source, choose only one of os_id, iso_id, snapshot_id, marketplace_app_id, or marketplace_image_id.
Send a POST request to the Create Instance Template endpoint to create a new template. Replace the placeholder values with your configuration.
$ curl "https://api.vultr.com/v2/instances/templates" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"plan": "PLAN",
"os_id": OS-ID,
"label": "TEMPLATE-LABEL",
"ssh_key_ids": [
"SSH-KEY-ID"
],
"vpc_ids": [
"VPC-ID"
]
}'
A successful request returns an HTTP 200 OK response with the template details. Note the template id for use when creating clusters or instances.