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
| Name | In | Type | Required | Description | Constraints |
|---|---|---|---|---|---|
wait | query | boolean | No | Wait for VM to be provisioned | default=true |
X-API-Key | header | string | null | No | nullable |
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:
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
session_id | string | null | No | nullable | |
vm_lifetime_seconds | integer | string | null | No | VM lifetime in seconds, or "max" to use the caller plan cap. | nullable |
memory_mb | integer | null | No | nullable | |
vcpu_count | integer | null | No | nullable | |
metadata | object | null | No | nullable | |
env | object<string, string> | null | No | nullable | |
env.* | string | No | ||
egress_policy | object | null | No | nullable | |
snapshot_id | string | null | No | nullable | |
snapshot_on_terminate | boolean | null | No | nullable | |
snapshot_name | string | null | No | nullable | |
auto_suspend | boolean | null | No | nullable | |
auto_resume | boolean | null | No | nullable | |
share | object | null | No | nullable | |
share.port | integer | No | min=1, max=65535 | |
share.is_public | boolean | No | default=false | |
image_variant | string | null | No | nullable | |
volumes | array<object> | null | No | nullable | |
volumes[] | object | No | ||
volumes[].volume_id | string | No | ||
volumes[].mount_path | string | No | ||
volumes[].mode | string | No | default="rw" | |
volumes[].checkpoint_id | string | null | No | nullable | |
vault_ids | array<string> | null | No | nullable | |
vault_ids[] | string | No |
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:
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
vm_id | string | null | No | nullable | |
session_id | string | Yes | ||
status | string | Yes | ||
share | object | null | No | nullable | |
env_status | string | No | default="none" | |
env_error | string | null | No | nullable |
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:
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
detail | array<object> | No | ||
detail[] | object | No | ||
detail[].loc | array<string | integer> | No | ||
detail[].loc[] | string | integer | No | ||
detail[].msg | string | No | ||
detail[].type | string | No |
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.