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.
1. Create an API token
Section titled “1. Create an API token”Open Settings → API tokens and fill in the Create token form:
| Field | What it does |
|---|---|
| Name | A label for the token, for example ci-bot or terraform. |
| Allowed IPs | One IP or CIDR per line (for example 203.0.113.5 or 198.51.100.0/24). Leave blank to allow any source. |
| Rate limit | Requests per minute. Leave blank (or 0) for no limit. |
| Expires | A date: the token stops working at the end of that day (server time). Leave blank for no expiry. |
| Access | Read and write, or Read only (only GET requests). |
| Areas | Limit the token to some parts of the API. Tick none for every area. |
| Connection scope | Comma-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:
| Area | Endpoints |
|---|---|
| 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.
2. Authenticate
Section titled “2. Authenticate”Send the token as a bearer header on every request:
curl -s https://panel.example.com/api/v1/hosts \ -H "Authorization: Bearer $NEXOVIRT_TOKEN"The token check answers with a short {"error": "..."} body:
| Status | Meaning |
|---|---|
401 | Missing, unknown or revoked token, or “This API token has expired.” (an expired token is not counted by the API jail). |
403 | The 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). |
429 | Rate 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}/approveandPOST /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.
3. Read the response envelope
Section titled “3. Read the response envelope”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.
4. Discover what you can create with
Section titled “4. Discover what you can create with”Before creating a guest, look up the identifiers the create call takes. None of these return secrets.
| Endpoint | Returns |
|---|---|
GET /hosts/{id}/plans | Active plans (cores, memory, disk, traffic, runtime). |
GET /hosts/{id}/os-templates | QEMU 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-templates | App templates with an approved version: base, minimums, price and input fields. Create with app_template + inputs on the create call. |
GET /hosts/{id}/ip-zones | IP zones, each with a ref like zone:2. |
GET /hosts/{id}/next-vmid | A free VMID for a new guest, from the VMID allocation (unique across all nodes by default). |
GET /hosts/{id}/storages, /networks, /nodes | Storage 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-groups | Node groups: id, name, description and members (host_id, node). Not paginated; read-only. |
GET /users/{id}/ssh-keys | A user’s SSH keys (name and fingerprint only). |
5. Create a guest in one call
Section titled “5. Create a guest in one call”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" }'typeisqemuorlxc. QEMU takesos_template(tpl:<id>); LXC takeslxc_template_idor anos_templatevolume id.plan_idsets cores, memory and disk from a plan. Without a plan, sendcores,memory_mbanddisk_gb(memoryanddiskare 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.vmidis optional (with a named node too): without it the panel takes one from the VMID allocation. Avmidyou send is refused with 409 when it is in use (in unique mode also on another node).- Give a
passwordor SSH keys (ssh_keys, plus the stored keys ofowner_id). ip_sourceisdhcp(default) orzone:<id>to assign the next free address from an IP zone. With a zone,ipv4_address/ipv6_addresspick 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) andextra_opts[]. Eachextra_optsentry is a comma list of the switches to turn on:backup,discard,iothread(the last two for VMs), for example"backup,discard". Leavebackupout to keep the disk out of backups. Withoutextra_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 anoptionsobject, for example"options": {"swap": 1024, "onboot": 1}. See the OpenAPI reference for the full list. Any invalid value refuses the whole request with422. group(withnode: "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.
6. Poll the job
Section titled “6. Poll the job”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.
Manage a guest after create
Section titled “Manage a guest after create”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).
| Endpoint | Does |
|---|---|
POST .../power, .../reinstall, .../password | Power actions, reinstall, password reset. |
POST .../resize | Any 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 .../ipconfig | Static or DHCP config of the primary NIC. Without bridge the guest keeps its bridge. |
POST .../ips | zone_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 .../options | Read 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-flags | Per-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}/iso | The VM’s CD/DVD: the inserted ISO and the node’s ISO images, insert (volid, boot_once), eject. |
GET .../migrate/options, POST .../migrate | Plan 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/restore | List backups, back up now, restore a backup over the guest. |
POST .../console | A one-time WebSocket session (ws_url, valid 60 seconds) for a terminal or VNC client. |
GET / PUT .../traffic, POST .../traffic/lift, POST .../traffic/extra | Monthly traffic usage and limit, set the server’s own limit, lift it for this month, add extra GB. |
GET / PUT .../notes | The 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/options | enabled, 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/options | The 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.
Hosts, agents and NAT on clusters
Section titled “Hosts, agents and NAT on clusters”GET /hosts/{id}returns the connection (name,hostname,port,user,active) and itsagents: one entry per node withnode,version,last_seen_atandstate(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) takenode(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 with422“Pick a node.”. POST .../nat/port-forwardsis refused with409when 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": trueto take the port over anyway; the answer then lists the reason inwarnings(empty otherwise).POST .../nat/applywith"allow_foreign": trueagrees 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.
Automatic placement
Section titled “Automatic placement”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"onPOST /hosts/{id}/guestspicks the best node on that host.POST /guests(no host in the path) picks across every host in the token’s scope;nodemust beautothere.GET /placement/suggest?type=qemu&memory_mb=2048&cores=2&disk_gb=20previews 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 a422; if no node of the group has room, a create answers409.
Weights are set under Settings → Placement.
Billing systems: customer login links
Section titled “Billing systems: customer login links”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.
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:
- Your system calls the endpoint from the server side with an admin API token and gets the
url. - Redirect the customer’s browser to that
urlwithin 60 seconds. The link works once. - 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 (andredirectis dropped). - 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.
| Status | Error |
|---|---|
403 | Login links require a Business license. / The token is limited to specific hosts. |
404 | User not found. |
409 | The customer portal is switched off. |
422 | redirect is not a portal path, or the account is not a customer. |
The request log
Section titled “The request log”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.