Skip to main content
POST
Create CVM (two-phase on one path)

Body

application/json

Request for provisioning a DStack app with automatic resource matching.

Most fields are optional and will be automatically determined by the resource matching logic in preflight_dstack_app. Only compose_file and name are required.

compose_file
AppComposeV2 · object
required
name
string
required

CVM name (used as hostname): 5-63 chars, must start with letter, can contain letters/numbers/hyphens

compose_file_raw
string

A whole app-compose JSON file, sent instead of compose_file. Phala Cloud parses it with the same rules as compose_file and serializes it the same way, so the deployed bytes and compose hash match the structured form, not the sent bytes. Needs the compose_advanced feature flag.

instance_type
string | null
vcpu
integer | null
memory
integer | null
disk_size
integer | null
image
string | null
prefer_dev
boolean | null

For OS images before 0.6.0, True selects dev and False selects non-dev. Ignored for unified images (0.6.0 or later). When None, inferred from the image name or defaults to dev.

node
string | null

Physical node name

Minimum string length: 1
region
string | null
listed
boolean
default:false
kms_id
string | null
kms
enum<string> | null
default:phala
Available options:
phala,
ethereum,
base,
local,
legacy
kms_contract_id
string<hashid> | null

A hashed identifier that maps to an internal database ID

Pattern: ^kc_.+
Example:

"kc_0123abcd"

kms_contract
string | null
nonce
integer | null

Optional nonce for deterministic app_id generation. When provided, app_id must also be provided. System will verify: app_id == get_create_address(team_wallet, nonce)

app_id
string | null

Optional app_id for manual specification. Required when nonce is provided. Only works with PHALA KMS.

env_keys
string[]

Allowed encrypted environment variable names. When compose_file does not declare allowed_envs, or sends an empty list, these names populate compose_file.allowed_envs for the guest allowlist.

ports
CreateTimePortMappingEntry · object[] | null
encrypted_env
string | null
user_config
string | null
hugepages
boolean
default:false
pin_numa
boolean
default:false
gpus
GpuConfig · object | null
kms_urls
string[]
gateway_urls
string[]
skip_gateway
boolean | null

Deploy without dstack-gateway. Turns the gateway off in compose_file when it does not set gateway_enabled/tproxy_enabled; rejected when compose_file enables the gateway.

key_provider_mode
enum<string> | null

Key provider mode. 'local' enables the local key provider in compose_file (and turns off KMS and the gateway where compose_file does not set them); rejected when compose_file sets key_provider or local_key_provider_enabled the other way.

Available options:
kms,
local
init_scripts
enum<string>[]

Platform-owned init scripts to run on every boot, as slugs: docker_cleanup erases all local container-runtime stores (images, volumes, all containerd namespaces) and needs OS 0.6.x, ext4 storage and the docker-compose runner; env_merge merges encrypted env on boot, needs OS 0.6.0 or newer and the managed_env_create feature flag. Phala Cloud fixes the run order (docker_cleanup, then env_merge). The deprecated object form {"env_merge": bool} is still accepted. GET /cvms/{cvm_id}/init-scripts shows what an existing CVM runs.

Available options:
docker_cleanup,
env_merge
enabled_init_scripts_docker_cleanup
boolean
default:false
deprecated

Deprecated: send init_scripts: ["docker_cleanup"]. True adds docker_cleanup to init_scripts.

launch_token
string | null

Launch token (at least 32 bytes) the guest requires on every boot before key provisioning. Phala Cloud writes its hash into compose_file.requirements.launch_token_hash and stores the token on the app. For an existing app it must equal the app's token. Needs dstack OS 0.6.0 or newer. Phala Cloud and the node operator can read the token: it protects only against parties who know the public compose.

generate_launch_token
boolean
default:false

Gate the CVM with a launch token Phala Cloud generates for a new app, or with the app's existing token. A newly generated token is returned once, in the create (commit) response.

enabled_guest_agent_access
boolean | null

Restrict the guest agent (port 8090) to Phala Cloud by sending false. Omit it to leave the app unchanged; a new app starts unrestricted. Sending true never relaxes an existing restriction: it is rejected with ERR-03-030 when the app is already restricted, because relaxing requires Phala Cloud support.

ssh_key_ids
string[] | null

SSH key hashids to authorize on the new CVM. Must belong to a member of the workspace. Omit to authorize all of your own active keys.

annotations
Annotations · object

Opaque key/value metadata for host-side tooling, stored by the dstack VMM with the VM. Not passed to the guest, not measured, and not part of the compose hash: attestation does not cover it, so do not rely on it for security. A non-empty map requires the cvm_annotations feature flag (ERR-03-049) and a node running dstack VMM 0.6.1 or newer (ERR-03-050). Keys must not be empty. Phala Cloud keeps no copy as CVM state and never copies or restores it (a replica starts without it, a relocated CVM keeps what its VMM manifest carries); this create request is recorded in the audit log.

Response

Prepare returns provision data with a token; commit returns the created CVM

Response from DStack app preflight checks containing provisioning details.

compose_hash
string
required
compose_file
string
required

Exact final app-compose JSON bound to compose_hash

os_image_version
string
required
requires_gpu
boolean
required
app_id
string | null
app_env_encrypt_pubkey
string | null
teepod_version
string | null
kms_info
KMSInfo · object | null

KMS instance information.

fmspc
string | null
device_id
string | null
os_image_hash
string | null
instance_type
string | null
token
string | null

Commit token for POST /cvms. Present for same-path two-phase create.