Skip to main content

Create Vm

POST /v1/vms

Start a VM, or restore one from a ready snapshot (snapshot_id: yours or a public one). The VM is billed for its vCPUs and memory until it is deleted or its vm_lifetime_seconds runs out; it is then killed, after a snapshot if snapshot_on_terminate is set, or suspended instead if auto_suspend is set. With wait=false you get status: pending and a session_id at once; otherwise the call returns when the VM is running. Send an Idempotency-Key header so a retry returns the first result instead of starting a second VM; a session_id whose session already has a VM updates that VM instead of creating one.

Authentication​

Requires authentication via: OAuth2PasswordBearer.

Parameters​

NameInTypeRequiredDescriptionConstraints
waitquerybooleanNoWait for VM to be provisioneddefault=true
X-API-Keyheaderstring | nullNonullable

Request Body​

Required: Yes

application/json​

Resolved schema:

{
"properties": {
"session_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Session Id"
},
"vm_lifetime_seconds": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"const": "max"
},
{
"type": "null"
}
],
"title": "Vm Lifetime Seconds",
"description": "VM lifetime in seconds, or \"max\" to use the caller plan cap."
},
"memory_mb": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Memory Mb"
},
"vcpu_count": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Vcpu Count"
},
"metadata": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"title": "Metadata"
},
"env": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"title": "Env"
},
"egress_policy": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"title": "Egress Policy"
},
"snapshot_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Snapshot Id"
},
"snapshot_on_terminate": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Snapshot On Terminate"
},
"snapshot_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Snapshot Name"
},
"auto_suspend": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Auto Suspend"
},
"auto_resume": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"title": "Auto Resume"
},
"share": {
"anyOf": [
{
"properties": {
"port": {
"type": "integer",
"maximum": 65535,
"minimum": 1,
"title": "Port"
},
"is_public": {
"type": "boolean",
"title": "Is Public",
"default": false
}
},
"type": "object",
"required": [
"port"
],
"title": "ShareRequest"
},
{
"type": "null"
}
]
},
"image_variant": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Image Variant"
},
"volumes": {
"anyOf": [
{
"items": {
"properties": {
"volume_id": {
"type": "string",
"title": "Volume Id"
},
"mount_path": {
"type": "string",
"title": "Mount Path"
},
"mode": {
"type": "string",
"title": "Mode",
"default": "rw"
},
"checkpoint_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Checkpoint Id"
}
},
"type": "object",
"required": [
"volume_id",
"mount_path"
],
"title": "VMVolumeMountRequest"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Volumes"
},
"vault_ids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Vault Ids"
}
},
"type": "object",
"title": "VMCreateRequest"
}

Field details:

FieldTypeRequiredDescriptionConstraints
session_idstring | nullNonullable
vm_lifetime_secondsinteger | string | nullNoVM lifetime in seconds, or "max" to use the caller plan cap.nullable
memory_mbinteger | nullNonullable
vcpu_countinteger | nullNonullable
metadataobject | nullNonullable
envobject<string, string> | nullNonullable
env.*stringNo
egress_policyobject | nullNonullable
snapshot_idstring | nullNonullable
snapshot_on_terminateboolean | nullNonullable
snapshot_namestring | nullNonullable
auto_suspendboolean | nullNonullable
auto_resumeboolean | nullNonullable
shareobject | nullNonullable
share.portintegerNomin=1, max=65535
share.is_publicbooleanNodefault=false
image_variantstring | nullNonullable
volumesarray<object> | nullNonullable
volumes[]objectNo
volumes[].volume_idstringNo
volumes[].mount_pathstringNo
volumes[].modestringNodefault="rw"
volumes[].checkpoint_idstring | nullNonullable
vault_idsarray<string> | nullNonullable
vault_ids[]stringNo

Responses​

200​

Successful Response

application/json​

Resolved schema:

{
"properties": {
"vm_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Vm Id"
},
"session_id": {
"type": "string",
"title": "Session Id"
},
"status": {
"type": "string",
"title": "Status"
},
"share": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"title": "Share"
},
"env_status": {
"type": "string",
"title": "Env Status",
"default": "none"
},
"env_error": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Env Error"
}
},
"type": "object",
"required": [
"session_id",
"status"
],
"title": "VMCreateResponse"
}

Field details:

FieldTypeRequiredDescriptionConstraints
vm_idstring | nullNonullable
session_idstringYes
statusstringYes
shareobject | nullNonullable
env_statusstringNodefault="none"
env_errorstring | nullNonullable

400​

Invalid request: env, memory, vCPU count, lifetime, egress policy, volume mounts, Idempotency-Key, a snapshot that is not ready, or wait=false combined with share or volumes.

No response body.

401​

No credentials, or the Bearer token / X-API-Key is invalid.

No response body.

403​

The account is disabled, or a guest token was used; or your account cannot start VMs yet (the body's code says why), your plan does not allow the requested lifetime or vCPU count, or the snapshot, session, volume or vault is not yours.

No response body.

404​

Snapshot, session or volume not found.

No response body.

409​

The Idempotency-Key was used for a different request, a creation with it is still in progress, the startup needs reconciliation (check GET /v1/vms/creation-status/{session_id} before creating another VM), or a volume already has a writer.

No response body.

422​

Validation Error

application/json​

Resolved schema:

{
"properties": {
"detail": {
"items": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
}

Field details:

FieldTypeRequiredDescriptionConstraints
detailarray<object>No
detail[]objectNo
detail[].locarray<string | integer>No
detail[].loc[]string | integerNo
detail[].msgstringNo
detail[].typestringNo

429​

Too many requests, or your VM, Devbox or concurrent-startup limit is reached. Nothing was queued.

No response body.

503​

No capacity is free right now, volumes are disabled, or VM placement is temporarily unavailable. Retry after Retry-After when present.

No response body.

504​

The VM, its environment or its egress policy was not ready in time. Check GET /v1/vms before creating another VM.

No response body.