Skip to content

Automation (REST API)

Everything you script against NexoVirt goes through the REST API under /api/v1. It is smaller and friendlier than the raw Proxmox API: one token covers every connected host, and one call creates a complete guest. This page walks through the typical workflow; the interactive REST API reference lists every endpoint with a try-it panel.

Open Settings → API tokens and fill in the Create token form:

FieldWhat it does
NameA label for the token, for example ci-bot or terraform.
Allowed IPsOne IP or CIDR per line (for example 203.0.113.5 or 198.51.100.0/24). Leave blank to allow any source.
Rate limitRequests per minute. Leave blank (or 0) for no limit.
ExpiresA date: the token stops working at the end of that day (server time). Leave blank for no expiry.
AccessRead and write, or Read only (only GET requests).
AreasLimit the token to some parts of the API. Tick none for every area.
Connection scopeComma-separated connection ids (the API’s host ids, one node or one cluster each) the token may access. Leave blank for all nodes.

The areas are:

AreaEndpoints
Servers/guests, /placement, /apps, /app-templates, /ip-addresses, and on a host .../guests, .../apps, .../jobs, .../plans, .../os-templates, .../ct-templates, .../next-vmid, .../ip-zones, .../tasks
Infrastructure/hosts, a host and its other paths (nodes, storages, networks, NAT, HA, backup jobs, usage), /agents, /node-groups, /pbs, /alerts, /alert-rules
Users/users (not balance, orders and subscriptions), /customer-groups, /resellers, /reseller-plans
Billing/shop, /services, /payments, /module-servers, /games, /users/{id}/balance, /users/{id}/orders, /users/{id}/subscriptions

/api/health always works. A new endpoint outside these lists is refused for tokens limited to areas. Tokens created before expiry and areas existed keep full access.

The token is shown once, right after you create it: copy it then. Only a hash is stored. The Tokens table shows each token’s allowed IPs, scope, rate, access, expiry, last use and status; Revoke disables a token immediately.

Send the token as a bearer header on every request:

Terminal window
curl -s https://panel.example.com/api/v1/hosts \
-H "Authorization: Bearer $NEXOVIRT_TOKEN"

The token check answers with a short {"error": "..."} body:

StatusMeaning
401Missing, unknown or revoked token, or “This API token has expired.” (an expired token is not counted by the API jail).
403The source IP is not in Allowed IPs, the path names a host outside the token’s scope, “This API token is read-only.” or “This API token may not use this endpoint.” (outside its areas).
429Rate limit exceeded. The Retry-After header says how many seconds until the next minute window.

Host-less endpoints (GET /hosts, POST /guests, GET /placement/suggest) only ever see the hosts in the token’s scope.

A token limited to specific hosts cannot use endpoints that act across all hosts. They answer 403 with “This API token is limited to specific hosts and cannot use this endpoint.”:

  • resellers and reseller plans,
  • alerts and alert rules,
  • POST /hosts,
  • POST /users, DELETE /users/{id}, PUT /users/{id}/profile, POST /users/{id}/approve and POST /users/{id}/reject,
  • writing a user’s SSH keys,
  • GET /users/{id}/ips.

Use a token without a connection scope for these. DELETE /users/{id} and the SSH key writes only accept customer accounts, never admins or resellers.

Every endpoint answers with the same envelope:

{ "success": true, "data": { }, "error": null }

On failure success is false, data is null and error holds a readable message (404 not found, 409 conflict, 422 validation, 502 Proxmox failure). List endpoints accept ?page= and ?perPage= (default 50, at most 200) and add meta: { page, perPage, total }. A path under /api that does not exist answers 404 with the same envelope ("error": "Not found."), not an empty body.

Before creating a guest, look up the identifiers the create call takes. None of these return secrets.

EndpointReturns
GET /hosts/{id}/plansActive plans (cores, memory, disk, traffic, runtime).
GET /hosts/{id}/os-templatesQEMU OS templates, each with a ref like tpl:3.
GET /hosts/{id}/ct-templates?node=LXC templates: the managed library plus the node’s template files.
GET /app-templatesApp templates with an approved version: base, minimums, price and input fields. Create with app_template + inputs on the create call.
GET /hosts/{id}/ip-zonesIP zones, each with a ref like zone:2.
GET /hosts/{id}/next-vmidA free VMID for a new guest, from the VMID allocation (unique across all nodes by default).
GET /hosts/{id}/storages, /networks, /nodesStorage names, bridges and nodes. Each storage has class: the disk type set for it on that node (nvme, ssd, hdd, or null when not set).
GET /node-groupsNode groups: id, name, description and members (host_id, node). Not paginated; read-only.
GET /users/{id}/ssh-keysA user’s SSH keys (name and fingerprint only).
Terminal window
curl -s -X POST https://panel.example.com/api/v1/hosts/1/guests \
-H "Authorization: Bearer $NEXOVIRT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "qemu",
"node": "auto",
"name": "web-01",
"plan_id": 2,
"os_template": "tpl:3",
"ip_source": "zone:1",
"owner_id": 14,
"password": "change-me-please"
}'
  • type is qemu or lxc. QEMU takes os_template (tpl:<id>); LXC takes lxc_template_id or an os_template volume id.
  • plan_id sets cores, memory and disk from a plan. Without a plan, send cores, memory_mb and disk_gb (memory and disk are accepted as the same fields). Without them the guest gets 1 core, 512 MB and 8 GB.
  • node: "auto" lets placement pick the node and storage. vmid is optional (with a named node too): without it the panel takes one from the VMID allocation. A vmid you send is refused with 409 when it is in use (in unique mode also on another node).
  • Give a password or SSH keys (ssh_keys, plus the stored keys of owner_id).
  • ip_source is dhcp (default) or zone:<id> to assign the next free address from an IP zone. With a zone, ipv4_address / ipv6_address pick a specific address instead; it must be a free address of that zone, otherwise the create is refused. The error says which case it is: “The IP address … is not in the address range of the selected zone.” or ”… is already in use in the selected zone.” When the zone has a VLAN tag, the guest’s NIC gets that tag.
  • Additional disks are parallel arrays: extra_storage[], extra_size[] (GB), extra_mount[] (containers) and extra_opts[]. Each extra_opts entry is a comma list of the switches to turn on: backup, discard, iothread (the last two for VMs), for example "backup,discard". Leave backup out to keep the disk out of backups. Without extra_opts, a disk is backed up and has no other switch.
  • Optional advanced guest options (swap, CPU limit, disk cache, VLAN tag, startup order and so on, the same as the wizard’s Advanced section) go in as flat opt_* fields or an options object, for example "options": {"swap": 1024, "onboot": 1}. See the OpenAPI reference for the full list. Any invalid value refuses the whole request with 422.
  • group (with node: "auto") limits placement to a node group.

The request returns at once with a queued job:

{ "success": true, "data": { "queued": true, "job_id": 381, "vmid": 112,
"placement": { "host_id": 1, "node": "pve-2", "storage": "local-zfs", "explanation": "..." } }, "error": null }

A 409 means the host or the chosen node is in maintenance, the VMID is taken, the IP zone is full or no node has room.

Terminal window
curl -s https://panel.example.com/api/v1/hosts/1/jobs/381 \
-H "Authorization: Bearer $NEXOVIRT_TOKEN"

status moves from queued to running to done (or failed, with the reason in error). Poll every few seconds until it is done or failed. The same job id is shown in the panel, where the guest’s live provisioning page tracks it step by step.

Everything on a guest’s page in the panel has an endpoint under /hosts/{id}/guests/{type}/{vmid}. Writes are audited like the panel action. node (the node the guest is on) is optional on every one of these endpoints, reads and writes alike: without it the panel uses the guest’s node from its inventory, or the connection’s only node. Only when neither is known (a cluster guest the inventory has not seen yet) the answer is 422 “Pick a node.”. A node you send always wins and must be a valid node name. This covers power, reinstall, password, ipconfig, delete, snapshots, firewall, IPs, IP filter, isolation, options, ISO, backups, console, HA and replication (before, HA reads and power, isolation and snapshot calls needed node on a cluster while HA writes did not).

EndpointDoes
POST .../power, .../reinstall, .../passwordPower actions, reinstall, password reset.
POST .../resizeAny of cores, memory_mb, disk_gb (the new total size of the root disk, a whole number of GB) or disk + size (a slot such as scsi1 and a Proxmox size such as +10G). Disks only grow. disk_gb cannot be combined with disk/size. Any other field is refused with 422 “Unknown field(s): …”.
POST .../ipconfigStatic or DHCP config of the primary NIC. Without bridge the guest keeps its bridge.
POST .../ipszone_id adds an address from an IP zone as a new NIC (like Add IP, applies after a reboot). ip_id binds a customer pool IP in IPAM and the IP filter only (applied: false, configure it inside the guest). DELETE .../ips?ip_id= removes it again.
GET / POST .../optionsRead or change the advanced options (opt_* fields or an options object, same as create). pending: true means a reboot applies part of it.
GET / POST .../bind-mounts, DELETE .../bind-mounts/{slot}LXC bind mounts (node folder into the container).
POST .../disk-flagsPer-disk switches of one disk: node, slot (for example scsi1 or mp0) and any of backup, discard, iothread, ssd as true/false. See Per-disk switches.
GET / POST / DELETE .../guests/qemu/{vmid}/isoThe VM’s CD/DVD: the inserted ISO and the node’s ISO images, insert (volid, boot_once), eject.
GET .../migrate/options, POST .../migratePlan and queue a migration to another host, or to another node of the same cluster (target_host = the guest’s own host, target_node = another node; such a target is listed as "name": "Same cluster" with same_cluster: true, and the plan has same_cluster: true). Moving to the node the guest is on is a 422. A host-limited token only sees and uses hosts in its scope.
GET / POST .../backups, POST .../backups/restoreList backups, back up now, restore a backup over the guest.
POST .../consoleA one-time WebSocket session (ws_url, valid 60 seconds) for a terminal or VNC client.
GET / PUT .../traffic, POST .../traffic/lift, POST .../traffic/extraMonthly traffic usage and limit, set the server’s own limit, lift it for this month, add extra GB.
GET / PUT .../notesThe customer’s and the provider note; PUT sets the provider note (operator_note). See Server notes.
GET .../guests/lxc/{vmid}/app, POST .../guests/lxc/{vmid}/app/actions/{key}The container’s one-click app and its actions (reset password, change domain, update).
POST .../balance-optout{"optout": true} keeps the guest out of automatic balancing.
POST .../firewall/optionsenabled, policy_in, policy_out. A field you leave out keeps its current value. The answer is what Proxmox has after the change.
GET .../firewall/rules, GET .../firewall/optionsThe guest firewall as it is on Proxmox, also for guests made by hand. Each rule has pos (its place on Proxmox), managed (true = set by NexoVirt), isolation (true = a network isolation rule) and id (the panel rule id for DELETE .../firewall/rules/{id}, null for rules not stored in the panel). meta.source is proxmox; when Proxmox cannot be read it is panel, the panel’s stored settings come back and meta.warning says so.

POST /hosts/{id}/nodes/{node}/iso-download (storage, url, optional checksum and algorithm) downloads an ISO image to a node.

GET /hosts/{id}/backup-jobs lists each job in the same shape the create and update body takes: selection is all, pool or vmid, with the pool and the VMIDs in their own fields.

PUT (or POST) /hosts/{id}/storages/class sets the disk type of one storage on one node: {"node": "pve-1", "storage": "local-zfs", "class": "nvme"}. class is nvme, ssd or hdd; null or "" clears it. A storage the node’s inventory does not know is a 422.

GET /hosts/{id}/nodes/{node}/disks returns the node’s disks as last read (collected_at, agent, disks with path, by_id, model, serial, size, type, health, state, usage, offerable, reason) and the mounts a Directory storage may use. 404 until the first read.

POST /hosts/{id}/storages creates a storage on one node, either on a mounted file system ({"storage": "usb", "node": "pve-1", "from_mount": {"path": "/mnt/usb1tb"}, "content": "backup,iso"}, the path must be one of the node’s mounts) or on an unused disk, which ERASES it ({"storage": "tank2", "node": "pve-1", "from_disk": {"device": "/dev/sdb", "type": "zfs", "confirm": "sdb"}}, type lvmthin or zfs, confirm = the device name). Erasing a used disk (Erase and use) is only possible in the panel with step-up: "erase": true is a 422. The disk is checked again live before it is erased; a disk in use is a 422 with the reason. Each disk in GET .../disks has erasable, erase_reason and destroy (what an erase would remove).

POST /users/{id}/guests (assign a guest to a customer) answers 404 “Guest not found on this host.” when the host’s inventory has no guest of that type and VMID.

Jobs (create, reinstall, delete, migrate, restore) return a job_id. When a job fails because a Proxmox task failed, error contains Proxmox’s own reason, for example Creating the guest did not finish successfully on the node. Proxmox: directory '/srv/data' does not exist.

  • GET /hosts/{id} returns the connection (name, hostname, port, user, active) and its agents: one entry per node with node, version, last_seen_at and state (ok, or why the agent is missing, not responding or outdated). Use it to check that every node of a cluster has an agent.
  • The NAT endpoints (/hosts/{id}/nat, .../nat/port-forwards, .../nat/apply) take node (query or body), because NAT is per node. On a single-node connection it is optional; on a cluster a call without it is refused with 422 “Pick a node.”.
  • POST .../nat/port-forwards is refused with 409 when a hand-made DNAT rule on the node already forwards that public port (NexoVirt’s chain runs first and would take its traffic). Send "override": true to take the port over anyway; the answer then lists the reason in warnings (empty otherwise).
  • POST .../nat/apply with "allow_foreign": true agrees to add NexoVirt NAT next to the node’s own NAT rules, the same as the checkbox on the NAT page. The consent is stored for the rules as they are now and has to be given again once they change.

Placement scores every eligible node on free RAM, CPU load and free storage and skips nodes that are offline, in maintenance, without a healthy agent or without room.

  • node: "auto" on POST /hosts/{id}/guests picks the best node on that host.
  • POST /guests (no host in the path) picks across every host in the token’s scope; node must be auto there.
  • GET /placement/suggest?type=qemu&memory_mb=2048&cores=2&disk_gb=20 previews the ranking without creating anything: the best target, every ranked node with a score and explanation, and every dropped node with the reason.
  • Add group=<id or name> (comma-separated for several; the node must be in all of them) to any of these to pick only from a node group. An unknown group is a 422; if no node of the group has room, a create answers 409.

Weights are set under Settings → Placement.

A billing or hosting system can sign a customer straight into the customer portal without handing over their password. It asks the panel for a one-time link and redirects the customer’s browser to it. This needs the Business license (the sso entitlement); without it the call answers 403.

Terminal window
curl -s -X POST https://panel.example.com/api/v1/users/14/login-link \
-H "Authorization: Bearer $NEXOVIRT_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "redirect": "/portal/servers" }'
{ "success": true, "data": { "url": "https://panel.example.com/login/link/Zk3...", "expires_at": "2026-10-17T12:00:60+00:00" }, "error": null }

redirect is optional and must be a portal path (starting with /portal). The flow:

  1. Your system calls the endpoint from the server side with an admin API token and gets the url.
  2. Redirect the customer’s browser to that url within 60 seconds. The link works once.
  3. The panel signs the customer in and sends them to redirect (or /portal). Customers with two-factor authentication or a passkey still go through that check first (and redirect is dropped).
  4. If the link is expired, already used or unknown, the customer lands on the login page with a message asking them to sign in again from your billing system.

If a different user is already signed in in that browser, the customer sees a confirmation page (“You are signed in as … Continue as …?”) and nothing changes until they confirm. Login links are only for active customer accounts (not admins or resellers), and only while the customer portal is switched on. An API token limited to specific hosts cannot create login links (or reset passwords): use an unrestricted token. The panel logs each link as user.login_link in the audit log, without the token.

StatusError
403Login links require a Business license. / The token is limited to specific hosts.
404User not found.
409The customer portal is switched off.
422redirect is not a portal path, or the account is not a customer.

The Request log on Settings → API tokens records every API request, including refused ones: time, token, source IP, method, path, status and duration. Entries are kept for 30 days.

NexoVirt is developed and designed by Nucez Software, your partner for custom software and web design.