---
title: "Setup purchased virtual machine"
method: POST
path: "/api/vps/v1/virtual-machines/{virtualMachineId}/setup"
tags: ["VPS: Virtual machine"]
---

# Setup purchased virtual machine

`POST /api/vps/v1/virtual-machines/{virtualMachineId}/setup`

Setup newly purchased virtual machine with `initial` state.

Use this endpoint to configure and initialize purchased VPS instances.

## Path parameters

- `virtualMachineId` integer, required

## Request body

- VPSV1VirtualMachineSetupRequest
  - `template_id` integer, required — Template ID
  - `data_center_id` integer, required — Data center ID
  - `post_install_script_id` integer — Post-install script ID
  - `password` string, password — Password for the virtual machine. If not provided, random password will be generated. Password will not be shown in the response.
  - `hostname` string — Override default hostname of the virtual machine
  - `install_monarx` boolean — Install Monarx malware scanner (if supported)
  - `enable_backups` boolean — Enable weekly backup schedule
  - `ns1` string — Name server 1
  - `ns2` string — Name server 2
  - `public_key` object — Use SSH key
    - `name` string — Name of the SSH key
    - `key` string — Contents of the SSH key

## Response `200`

Success response

- VPSV1VirtualMachineVirtualMachineResource
  - `id` integer — Virtual machine ID
  - `firewall_group_id` integer, nullable — Active firewall ID, `null` if disabled
  - `subscription_id` string, nullable — Subscription ID
  - `data_center_id` integer, nullable — Data center ID
  - `plan` string, nullable — VPS plan name
  - `hostname` string
  - `state` 'running' | 'starting' | 'stopping' | 'stopped' | 'creating' | 'initial' | 'error' | 'suspending' | 'unsuspending' | 'suspended' | 'destroying' | 'destroyed' | 'recreating' | 'restoring' | 'recovery' | 'stopping_recovery'
  - `actions_lock` 'unlocked' | 'locked'
  - `cpus` integer — CPUs count assigned to virtual machine
  - `memory` integer — Memory available to virtual machine (in megabytes)
  - `disk` integer — Virtual machine disk size (in megabytes)
  - `bandwidth` integer — Monthly internet traffic available to virtual machine (in megabytes)
  - `ns1` string, nullable — Primary DNS resolver
  - `ns2` string, nullable — Secondary DNS resolver
  - `ipv4` VPSV1IPAddressIPAddressResource[] — Array of [`VPS.V1.IPAddress.IPAddressResource`](#model/vpsv1ipaddressipaddressresource)
    - `id` integer — IP address ID
    - `address` string — IP address: IPv4 or IPv6
    - `ptr` string, nullable — IP address PTR record
  - `ipv6` VPSV1IPAddressIPAddressResource[] — Array of [`VPS.V1.IPAddress.IPAddressResource`](#model/vpsv1ipaddressipaddressresource)
    - `id` integer — IP address ID
    - `address` string — IP address: IPv4 or IPv6
    - `ptr` string, nullable — IP address PTR record
  - `template` VPSV1TemplateTemplateResource
    - `id` integer — Template ID
    - `name` string — Template name
    - `description` string — Template description
    - `documentation` string, nullable — Link to official OS documentation
  - `created_at` string, date-time

## Other responses

- `401` — Unauthenticated response
- `422` — Validation error response
- `500` — Error response

---

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