---
title: "Purchase new virtual machine"
method: POST
path: "/api/vps/v1/virtual-machines"
tags: ["VPS: Virtual machine"]
---

# Purchase new virtual machine

`POST /api/vps/v1/virtual-machines`

Purchase and setup a new virtual machine.

If virtual machine setup fails for any reason, login to
[hPanel](https://hpanel.hostinger.com/) and complete the setup manually.

If no payment method is provided, your default payment method will be used automatically.

Use this endpoint to create new VPS instances.

## Request body

- VPSV1VirtualMachinePurchaseRequest
  - `item_id` string, required — Catalog price item ID
  - `payment_method_id` integer — Payment method ID, default will be used if not provided
  - `setup` VPSV1VirtualMachineSetupRequest, required
    - `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
  - `coupons` unknown[] — Discount coupon codes
    - unknown

## Response `200`

Success response

- BillingV1OrderVirtualMachineOrderResource
  - `order` BillingV1OrderOrderResource
    - `id` integer — Order ID
    - `subscription_id` string — Subscription ID
    - `status` 'completed' | 'pending' | 'processing' | 'failed' | 'refunded' | 'cancelled' | 'awaiting_payment' | 'payment_initiated' | 'fraud_refund'
    - `currency` string — Currency code
    - `subtotal` integer — Subtotal price (exc. VAT) in cents
    - `total` integer — Total price (inc. VAT) in cents
    - `billing_address` BillingV1OrderOrderBillingAddressResource
      - `first_name` string
      - `last_name` string
      - `company` string, nullable
      - `address_1` string, nullable
      - `address_2` string, nullable
      - `city` string, nullable
      - `state` string, nullable
      - `zip` string, nullable
      - `country` string, nullable
      - `phone` string, nullable
      - `email` string
    - `created_at` string, date-time
    - `updated_at` string, date-time
  - `virtual_machine` 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/revisions/74abfea76e36/schema)
