---
title: "Create a new instance under an existing app"
method: POST
path: "/api/v1/apps/{app_id}/instances"
tags: ["Apps"]
---

# Create a new instance under an existing app

`POST /api/v1/apps/{app_id}/instances`

Deploy a new CVM instance under an existing app, optionally with a new Docker Compose file. For on-chain KMS apps, this uses a two-phase flow: the first request returns HTTP 465 with a commit token; after registering the compose hash on-chain, the second request commits with the token and transaction hash.

## Path parameters

- `app_id` string, required — Hex app identifier

## Request body

- CreateAppInstanceRequest — Request model for creating a new instance under an existing app. Inherits node_id, encrypted_env, compose_hash and their validators from ReplicateRequest.
  - `teepod_id` integer, nullable — Target node ID (deprecated, use node_id)
  - `node_id` integer, nullable — Target node ID for the replica
  - `encrypted_env` string, nullable — New encrypted env blob (hex)
  - `compose_hash` string, nullable — Explicit compose hash to replicate. Required when the source app has multiple live instances.
  - `docker_compose_file` string, nullable — New Docker Compose YAML content
  - `pre_launch_script` string, nullable — New pre-launch script content
  - `token` string, nullable — Commit token returned by a prior prepare-only request. When set, this request commits the previously-prepared instance instead of preparing a new one.
  - `transaction_hash` string, nullable — On-chain transaction hash proving compose-hash registration. Use 'already-registered' (or omit) when the hash was registered earlier.

## Response `200`

Instance created

- VM
  - `id` integer, required
  - `name` string, required
  - `status` string, required
  - `teepod_id` integer, required
  - `teepod` TeepodMeta
    - `id` integer, required
    - `name` string, required
  - `user_id` integer, nullable
  - `app_id` string, required
  - `vm_uuid` string, nullable
  - `instance_id` string, nullable
  - `app_url` string, nullable
  - `base_image` string, nullable
  - `vcpu` integer, required
  - `memory` integer, required
  - `disk_size` integer, required
  - `manifest_version` integer, nullable
  - `version` string, nullable
  - `runner` string, nullable
  - `docker_compose_file` string, nullable
  - `features` string[], nullable
  - `created_at` string, date-time, required
  - `encrypted_env_pubkey` string, nullable

## Other responses

- `400` — Invalid compose, no template instance, or app mismatch
- `401` — Not authenticated
- `403` — No workspace access
- `404` — App or target node not found
- `422` — Validation Error
- `465` — On-chain compose hash registration required (two-phase flow)
- `500` — Instance creation failed

---

[API](https://skmtc.net/phala/apis/phala-cloud-api.md) · [All operations](https://skmtc.net/phala/apis/phala-cloud-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/phala/phala-cloud-api/versions/83c6ae62e860/schema)
