REST API & CLI Tools
Master the VergeOS REST API, yb-api helper script, and vrg CLI for programmatic infrastructure management and automation.
Every operation you perform in the VergeOS UI maps directly to a REST API call. This API-first design means anything you can click in the dashboard — creating VMs, configuring networks, managing tenants — can be automated through HTTP endpoints. This section covers the three primary interfaces for programmatic access: the REST API itself, the yb-api helper script for on-box automation, and the vrg CLI for remote management.
REST API Overview
The VergeOS API follows standard REST conventions with JSON payloads, supporting the full lifecycle of every resource in the platform.
HTTP Methods
GET
Retrieve resources
GET /api/v4/vms?fields=most
POST
Create resources or trigger actions
POST /api/v4/vms
PUT
Update existing resources
PUT /api/v4/vms/36
DELETE
Remove resources
DELETE /api/v4/vms/36
Query Parameters
Every GET request supports OData-style filtering and field selection:
fields— Specify which fields to return (e.g.,fields=name,$key,ramorfields=mostfor all common fields)filter— OData-style filter expressions (e.g.,filter=is_snapshot eq false)sort— Sort results by field (e.g.,sort=name)limit/offset— Pagination controls for large result sets
Data Formats
All API responses are returned in JSON format. Request bodies for POST and PUT operations must also be JSON with the Content-Type: application/json header.
Rate Limits
The API supports a maximum of 1,000 requests per hour per API key. For high-volume automation, batch operations where possible and implement retry logic with exponential backoff.
Authentication
VergeOS supports two authentication methods — Basic HTTP authentication and token-based authentication — each suited to different use cases. Long-lived API keys are a variant of the token method, presented as a Bearer token instead of a session token:
1. Basic HTTP Authentication
The simplest method — pass credentials directly with each request. All API traffic requires HTTPS.
2. Token-Based Authentication (Session Tokens)
Request a session token by POSTing credentials to /sys/tokens. Use the returned token in subsequent requests via the x-yottabyte-token header:
Bearer-Token Variant: Long-Lived API Keys
For production automation, create persistent API keys through System → Users → [User] → API Keys. These keys are a Bearer-token variant of token authentication — they function as Bearer tokens and remain valid until expiration or deletion:
API keys support IP allow/deny lists for security and configurable expiration dates. Store them in environment variables rather than hardcoding:
API keys are shown only once at creation time. If lost, you must delete the key and create a new one.
API Explorer (Swagger)
VergeOS includes a built-in Swagger documentation page that is dynamically generated from the running system, showing every available table and operation.
To access it:
Log in to the VergeOS UI
Navigate to System → API Documentation
Browse available endpoints, view schemas, and test API calls directly
The Swagger interface lets you execute API calls in-browser and see the resulting curl command, response body, and headers — making it an excellent tool for prototyping automation scripts.
Key API Endpoints
The API organizes resources into tables. Here are the most commonly used endpoints:
/api/v4/vms
Virtual machine CRUD operations
/api/v4/vm_actions
VM power operations, clone, snapshot
/api/v4/machine_drives
Attach/manage VM storage drives
/api/v4/machine_nics
Configure VM network interfaces
/api/v4/machine_devices
GPU/PCI device passthrough
/api/v4/machine_status/{id}
Runtime power state and status
/api/v4/vnets
Virtual network management
/api/v4/vnet_rules
Firewall and NAT rules
/api/v4/tenants
Tenant (VDC) management
/api/v4/nodes
Physical node information
/api/v4/clusters
Cluster configuration
/api/sys/tokens
Session token management
Schema Introspection
Append /$table to any endpoint to retrieve its full database schema, including all available fields and types:
VM Lifecycle API Walkthrough
The most common automation workflow is provisioning a complete VM through the API. This four-step process mirrors what the UI does behind the scenes:
Step 1: Create the VM
Step 2: Add a Storage Drive
Step 3: Add a Network Interface
Step 4: Power On
Additional Actions
Once the VM exists, you can trigger advanced operations through the same vm_actions endpoint:
yb-api Helper Script
The yb-api script is a built-in command-line wrapper available on every VergeOS node via SSH. It simplifies API calls by handling authentication, headers, URL construction, query encoding, and upload handling for you.
Basic Syntax
Common Options
--get
Retrieve resources
--post='JSON'
Create a resource with JSON payload
--put='JSON'
Update a resource with JSON payload
--delete
Delete a resource
--server=IP
Target a specific VergeOS system
--user=NAME
Authenticate as a specific user
--fields='...'
Select fields to return
--filter='...'
OData filter expression
Usage Examples
The yb-api script is ideal for quick ad-hoc queries and scripting directly on VergeOS nodes. For remote automation from workstations, use the vrg CLI or the Python/PowerShell SDKs.
vrg CLI
The vrg command-line tool provides a full-featured remote management interface for VergeOS, built in Python with over 200 commands covering VMs, networks, storage, tenants, and system administration.
Installation
The vrg CLI is distributed through several channels — pick whichever fits your environment. None of these are OS-gated; pipx is the recommended path on every supported OS.
A standalone binary (no Python required) is also published for Linux x86_64, macOS ARM64, and Windows x86_64 — useful for Windows hosts without a Python toolchain.
Key Capabilities
VM Management
Create, list, start, stop, snapshot, clone, and delete virtual machines with simple commands.
Network Operations
Manage virtual networks, firewall rules, DHCP settings, and VPN configurations.
Storage Control
Administer NAS volumes, CIFS/NFS shares, and monitor vSAN tiers.
Tenant Management
Provision tenants, allocate resources, and manage multi-tenant environments.
The vrg CLI wraps the same REST API documented above, providing tab completion, formatted output, and a more ergonomic interface for day-to-day operations from your workstation.
API Error Handling
When API calls fail, VergeOS returns standard HTTP status codes with descriptive JSON error bodies:
401
Unauthorized
Invalid credentials or expired token
403
Forbidden
Insufficient permissions for the operation
404
Not Found
Resource does not exist or invalid endpoint
409
Conflict
Resource state conflict (e.g., VM already running)
422
Validation Error
Invalid parameters or missing required fields
429
Rate Limited
Exceeded 1,000 requests/hour limit
500
Server Error
Internal error — check system logs
Best Practices for API Automation
Use API keys for production automation instead of session tokens — they don't expire on inactivity
Apply IP restrictions on API keys to limit where they can be used
Select specific fields (
fields=name,$key,ram) instead offields=mostto reduce payload sizeImplement pagination with
limitandoffsetfor large result setsHandle async operations — actions like clone and snapshot return immediately; poll
machine_statusfor completionStore credentials in environment variables — never hardcode tokens in scripts
Use schema introspection (
/$table) to discover available fields before writing automation
What's Next
Now that you understand the raw API, the following pages cover higher-level tools that wrap this API into language-native interfaces:
Python SDK (pyvergeos) — Pythonic, type-annotated wrapper with resource managers and OData filter builder
PowerShell Module (PSVergeOS) — 200+ cmdlets with pipeline support for Windows-native automation
Last updated
Was this helpful?