---
title: "create instance"
method: PUT
path: "/api/v0/asks/{id}/"
tags: ["Instances"]
---

# create instance

`PUT /api/v0/asks/{id}/`

Creates a new instance by accepting an "ask" contract from a provider.

- Use the search offers endpoint to discover available machines.
- If `template_id` is provided, those template defaults are either merged or overridden by parameters specified in the request body.

**Template Precedence Rules:**
- **Scalar fields** (image, disk, runtype, etc.): Request value overrides template value
- **`env`**: Merged by key. Request values win on key conflicts
- **`extra_filters`**: Merged by key. Request values win on key conflicts

For detailed template usage, see [Creating and Using Templates with API](/api-reference/creating-and-using-templates-with-api).

CLI Usage: `vastai create instance <offer_id> <image> [options]`

## Path parameters

- `id` integer, required

## Request body

- object
  - `image` string, required — Docker image to use for the instance.
  - `template_hash_id` string — Content-based hash ID of a template to use as base configuration. Template values are merged with or overridden by request parameters (see precedence rules in endpoint description). When using a template, the `image` field is optional as the template provides it. Example: `4e17788f74f075dd9aab7d0d4427968f`
  - `label` string — Custom name for the instance
  - `disk` number, float — Size of local disk partition (in GB)
  - `runtype` 'ssh' | 'jupyter' | 'args' | 'ssh_proxy' | 'ssh_direct' | 'jupyter_proxy' | 'jupyter_direct' — Launch mode for the instance. If omitted, defaults to 'ssh' unless `args/args_str` is provided.
  - `target_state` 'running' | 'stopped' — Desired initial state of the instance
  - `price` number — Bid price per machine (in $/hour). Only for interruptible instances
  - `env` string — Environment variables and port mappings in Docker flag format. When using a template, request `env` is merged with template `env` - existing keys are retained, new keys are appended, conflicting keys use the request value. Example: `"-e HF_TOKEN=hf_xxx123456789 -e MODEL_ID=TheBloke/Llama-2-7B-Chat-GPTQ -p 8000:8000"`
  - `cancel_unavail` boolean — Whether to cancel if instance cannot start immediately. Defaults to false for interruptibles. Defaults to true for on-demand with target_state='running'
  - `vm` boolean — Whether this is a VM instance
  - `onstart` string — Commands to run when instance starts Example : `env | grep _ >> /etc/environment; echo 'starting up'`
  - `args` string[] — Arguments array to passed to the image entrypoint Example : `["bash", "-c", "env | grep _ >> /etc/environment; echo 'starting up'"]`
  - `args_str` string — Arguments string to pass to the entrypoint (alternative to args) Example : `args_str: bash -c "env | grep _ >> /etc/environment; echo 'starting up'"`
  - `use_jupyter_lab` boolean — Launch instance with jupyter lab instead of notebook
  - `jupyter_dir` string — Directory to launch Jupyter from Example : `/home/notebooks`
  - `python_utf8` boolean — Set python's locale to C.UTF-8
  - `lang_utf8` boolean — Set locale to C.UTF-8
  - `force` boolean — Skip sanity checks when creating from an existing instance
  - `user` string — User to use with docker create (breaks some images, use with caution)
  - `image_login` string — Docker registry credentials if needed
  - `volume_info` object — Volume creation/linking information
    - `create_new` boolean — Set to `true` to create a new volume, `false` to link an existing volume
    - `volume_id` integer — If `create_new` is false: existing volume ID (from `show volumes`). If `create_new` is true: volume offer ID (from `search volumes`)
    - `size` integer — Size of the volume in GB. Only used when `create_new` is true
    - `mount_path` string — Mount path for the volume inside the container (e.g., `/workspace`)

## Response `200`

Instance created successfully

- object
  - `success` boolean — If the instance was created successfully
  - `new_contract` integer — ID of the newly created instance contract

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Offer not found or not available
- `410` — Offer no longer available (when cancel_unavail is true and instance cannot start)
- `429` — Too Many Requests

---

[API](https://skmtc.net/vast/apis/vast-ai-api.md) · [All operations](https://skmtc.net/vast/apis/vast-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/vast/vast-ai-api/revisions/4ed14f79f796/schema)
