vg, the Valgrid CLI
vg is the client command-line tool for interacting with the Valgrid API. It allows users to manage namespaces, teams, users, zones, DNS records and agents, retrieve information, and perform various operations related to Valgrid.
It allows users to perform operations such as creating, updating, and deleting namespaces, as well as retrieving information about existing namespaces. It provides a convenient way to interact with the Valgrid API from the command line, making it easier to manage and automate tasks related to namespaces. It can output results in different formats, including JSON, Markdown, and HTML, allowing users to choose the format that best suits their needs.
Environment variables for configuration
vg uses the following environment values:
| Environment Variable | Description |
|---|---|
| VALGRID_API_KEY | Your Valgrid API key. |
| VALGRID_API_URL | The URL of the Valgrid API (default: "https://api.valgrid.io"). |
| VALGRID_API_VERSION | The version of the Valgrid API to use (default: "v1"). |
| VALGRID_CREDENTIALS_FILE | Where vg login saves its token (default: valgrid/credentials.json in your configuration directory). |
The easiest way to authenticate is vg login (see Signing in). VALGRID_API_KEY, when set, is used instead of the token vg login saved. The VALGRID_API_URL and VALGRID_API_VERSION environment variables can be used to specify a custom API endpoint or version if needed.
Signing in
vg login signs you in with your email address and saves an API token for you:
❯ vg login --host acme.app.valgrid.io --email ada@acme.example
If ada@acme.example has an account on acme.app.valgrid.io, a sign-in code is on its way.
Code from the email: K7QM-2XPD
Signed in. Token 019a4c22-1b2c-7d3e-8f4a-5b6c7d8e9f01 saved to /home/ada/.config/valgrid/credentials.json, valid until 2027-01-04.
--host is your tenant's address, the one you sign in to in the browser. The code in the email works once and for 15 minutes. The saved token has every permission of your role and expires after 30 days; run vg login again to get a new one. The file is readable only by you.
vg logout deletes the saved token, on the server and on your computer.
Aliases
| Full command | Alias |
|---|---|
| vg create namespace | vg cr ns |
| vg update namespace | vg up ns |
| vg delete namespace | vg del ns |
| vg get namespace | vg g ns |
| vg list namespaces | vg ls ns |
| vg create team | vg cr team |
| vg update team | vg up team |
| vg delete team | vg del team |
| vg get team | vg g team |
| vg list teams | vg ls teams |
| vg create user | vg cr user |
| vg update user | vg up user |
| vg delete user | vg del user |
| vg get user | vg g user |
| vg list users | vg ls users |
| vg create zone | vg cr zone |
| vg update zone | vg up zone |
| vg delete zone | vg del zone |
| vg get zone | vg g zone |
| vg list zones | vg ls zones |
| vg create rrset | vg cr rrset |
| vg update rrset | vg up rrset |
| vg delete rrset | vg del rrset |
| vg get rrset | vg g rrset |
| vg list rrsets | vg ls rrsets |
| vg get config | vg g cfg |
| vg register agent (or create agent) | vg reg agent |
| vg update agent | vg up agent |
| vg delete agent | vg del agent |
| vg get agent | vg g agent |
| vg list agents | vg ls agents |
Help
vg provides a comprehensive help system to guide users through its commands and usage.
Main help
❯ vg --help
vg is a CLI tool for interacting with Valgrid API.
Usage:
vg [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
create Create a new resource
delete Delete a single resource
get Get a single resource
help Help about any command
list List all items
lookup Look up the records of a name
register Register a new agent
update Update an existing resource
version Get the version of the application
Flags:
-h, --help help for vg
-o, --output string Output format. One of: text|json|markdown|html (default "text")
Use "vg [command] --help" for more information about a command.
Example command help: create
❯ vg cr namespace --help
Create a new namespace in the current context
Usage:
vg create namespace [flags]
Aliases:
namespace, ns
Flags:
-d, --description string Namespace description.
-f, --file string File to read for content. Filename or '-' for stdin.
-h, --help help for namespace
-n, --name string Namespace name.
Global Flags:
-o, --output string Output format. One of: text|json|markdown|html (default "text")
Examples
Creating a Namespace
Using file with flag -f <filename.json> or stdin with a flag -f -, you can create multiple namespaces at once. The file or stdin should contain a JSON array of namespace objects.
❯ vg cr namespace -f payload.json
┌──────────────────────────────────────┬──────────────┬─────────────┬────────────────┬──────────────────────┐
│ NAMESPACE ID │ NAME │ DESCRIPTION │ CONFIG VERSION │ UPDATED AT │
├──────────────────────────────────────┼──────────────┼─────────────┼────────────────┼──────────────────────┤
│ 01a1b61c-c2f8-752c-83dc-43a40f8d0c87 │ ns from file │ my new ns │ 0 │ 2026-11-07T13:05:00Z │
└──────────────────────────────────────┴──────────────┴─────────────┴────────────────┴──────────────────────┘
❯ vg cr ns --name "new ns 6" -o markdown
| NAMESPACE ID | NAME | DESCRIPTION | CONFIG VERSION | UPDATED AT |
|:-------------------------------------|:---------|:------------|:---------------|:---------------------|
| 01a1b61e-b122-71e0-a603-e9fc01d2e6b8 | new ns 6 | | 0 | 2026-11-07T13:07:07Z |
Getting a Namespace
❯ vg get namespace 01a1a04a-fe08-7582-88d2-d4e59962f30e
┌──────────────────────────────────────┬─────────┬───────────────────┬────────────────┬─────────────────────────────┐
│ NAMESPACE ID │ NAME │ DESCRIPTION │ CONFIG VERSION │ UPDATED AT │
├──────────────────────────────────────┼─────────┼───────────────────┼────────────────┼─────────────────────────────┤
│ 01a1a04a-fe08-7582-88d2-d4e59962f30e │ Default │ Default namespace │ 0 │ 2026-11-03T07:23:51.688398Z │
└──────────────────────────────────────┴─────────┴───────────────────┴────────────────┴─────────────────────────────┘
Listing Namespaces
❯ vg list namespaces
┌──────────────────────────────────────┬────────────────┬───────────────────┬────────────────┬─────────────────────────────┐
│ NAMESPACE ID │ NAME │ DESCRIPTION │ CONFIG VERSION │ UPDATED AT │
├──────────────────────────────────────┼────────────────┼───────────────────┼────────────────┼─────────────────────────────┤
│ 01a1a04a-fe08-7582-88d2-d4e59962f30e │ Default │ Default namespace │ 0 │ 2026-11-03T07:23:51.688398Z │
│ 01a1a04a-fe0a-782d-99d5-3d1b62f6c3b5 │ Test Namespace │ Test Namespace │ 0 │ 2026-11-03T07:23:51.690839Z │
└──────────────────────────────────────┴────────────────┴───────────────────┴────────────────┴─────────────────────────────┘
Updating a Namespace
❯ vg up ns 01a1b53f-b769-7da8-a09f-4e0c2f110faf --name "dev k8s cluster"
┌──────────────────────────────────────┬─────────────────┬────────────────────────────┬────────────────┬──────────────────────┐
│ NAMESPACE ID │ NAME │ DESCRIPTION │ CONFIG VERSION │ UPDATED AT │
├──────────────────────────────────────┼─────────────────┼────────────────────────────┼────────────────┼──────────────────────┤
│ 01a1b53f-b769-7da8-a09f-4e0c2f110faf │ dev k8s cluster │ test-namespace-description │ 0 │ 2026-11-07T13:13:03Z │
└──────────────────────────────────────┴─────────────────┴────────────────────────────┴────────────────┴──────────────────────┘
JSON Output
❯ vg ls ns -o json
[
{
"namespace_id": "01a1a04a-fe08-7582-88d2-d4e59962f30e",
"name": "Default",
"description": "Default namespace",
"config_version": 0,
"updated_at": "2026-11-03T07:23:51.688398Z"
},
{
"namespace_id": "01a1a04a-fe0a-782d-99d5-3d1b62f6c3b5",
"name": "Test Namespace",
"description": "Test Namespace",
"config_version": 0,
"updated_at": "2026-11-03T07:23:51.690839Z"
}
]
Markdown Output
❯ vg ls ns -o markdown
| NAMESPACE ID | NAME | DESCRIPTION | CONFIG VERSION | UPDATED AT |
|:-------------------------------------|:---------------|:------------------|:---------------|:----------------------------|
| 01a1a04a-fe08-7582-88d2-d4e59962f30e | Default | Default namespace | 0 | 2026-11-03T07:23:51.688398Z |
| 01a1a04a-fe0a-782d-99d5-3d1b62f6c3b5 | Test Namespace | Test Namespace | 0 | 2026-11-03T07:23:51.690839Z |
Teams
Teams have a name and an optional email address. The commands work like the namespace ones: create team, get team, list teams, update team and delete team, with the same -f file/stdin input and output formats.
❯ vg cr team --name "platform" --email platform@example.com
❯ vg ls teams
❯ vg up team 01a1b61c-c2f8-752c-83dc-43a40f8d0c87 --email ops@example.com
❯ vg del team 01a1b61c-c2f8-752c-83dc-43a40f8d0c87
update team only changes the fields you give, so --email alone keeps the name. --email "" clears the email.
Users
Users have a first name, a last name, an email address, an optional avatar URL, a team and a role (owner or member). The commands work like the team ones: create user, get user, list users, update user and delete user, with the same -f file/stdin input and output formats. Without --team, a new user joins the Default team, and without --role the user is a member.
❯ vg cr user --first-name Ada --last-name Lovelace --email ada@example.com
❯ vg ls users
❯ vg up user 01a1b61c-d4e2-7a10-9c3e-5b2f7a8e1d44 --team 01a1b61c-c2f8-752c-83dc-43a40f8d0c87
❯ vg del user 01a1b61c-d4e2-7a10-9c3e-5b2f7a8e1d44
update user only changes the fields you give. --team moves the user to another team, --role owner or --role member changes the role, and --avatar-url "" clears the avatar URL. Deleting a user also stops their API keys from working, and you can't delete your own user.
Zones and RRsets
A zone belongs to a namespace. The RRset commands take the zone ID first. list zones --name and list rrsets --name/--type show only matching items; repeat a flag to match any of several values. --record can be given several times, and on update rrset it replaces every record of the RRset. Use -f for SOA values or several resources at once.
❯ vg cr zone --name example.internal --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d
❯ vg ls zones --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d
❯ vg up zone 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90 -f - <<< '{"soa":{"refresh":1800}}'
❯ vg cr rrset 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90 --name www --type A --record 192.0.2.1 --record 192.0.2.2
❯ vg ls rrsets 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90
❯ vg ls rrsets 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90 --name www --type A
❯ vg ls zones --name example.internal
❯ vg up rrset 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90 019a4c20-1c2d-7e3f-9a4b-5c6d7e8f9a01 --ttl 60 --record 192.0.2.3
❯ vg del rrset 019a4c1f-0b1c-7d2e-8f3a-4b5c6d7e8f90 019a4c20-1c2d-7e3f-9a4b-5c6d7e8f9a01
Looking up a name
lookup finds the records of a fully qualified name, the way dig would, but in the Valgrid API instead of a DNS server. It matches the name to the most specific zone in each of your namespaces (so api.dev.example.internal is looked up in dev.example.internal when that zone exists), and shows the RRsets with their zone and the name relative to it. Give --namespace-id to look in one namespace only.
❯ vg lookup www.example.internal
┌──────────────────────┬──────┬─────┬────────────────────────┬──────────────────┬───────────────┬──────────────────────────────────────┐
│ NAME │ TYPE │ TTL │ RECORDS │ ZONE │ RELATIVE NAME │ NAMESPACE ID │
├──────────────────────┼──────┼─────┼────────────────────────┼──────────────────┼───────────────┼──────────────────────────────────────┤
│ www.example.internal │ A │ 300 │ 192.0.2.1 │ example.internal │ www │ 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d │
│ │ │ │ 192.0.2.2 │ │ │ │
│ www.example.internal │ AAAA │ 300 │ 2001:db8::1 (disabled) │ example.internal │ www │ 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d │
└──────────────────────┴──────┴─────┴────────────────────────┴──────────────────┴───────────────┴──────────────────────────────────────┘
❯ vg lookup example.internal MX
❯ vg lookup www.example.internal A --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d -o json
The optional type is one of A, AAAA, CAA, CNAME, MX, NS, PTR, SRV, TXT or ANY (the default), in any letter case. Like DNS:
- A
CNAMEat the name is shown whatever type you ask for. Its target isn't looked up. - When the name has no records and no names below it, the closest wildcard RRset answers, such as
*.appsforweb.apps.example.internal. - Letter case and a trailing dot don't matter.
Unlike DNS, disabled records are shown, marked (disabled). With -o json each result also has the zone_id and rrset_id, for update rrset and delete rrset. When nothing matches, lookup says whether no zone or no record was found, and exits with status 1. It needs the zone:read permission.
Agents
Register one agent for each DNS server that runs valgrid-agent. register agent (the same as create agent) prints the agent and its credential, vga_<agent_id>.<secret>, on the last line. The credential is shown only once and can't be retrieved later, so store it right away. --credential-file <path> writes it to a new file, readable only by you, instead of printing it; an existing file is never overwritten.
❯ vg reg agent --name dns-1 --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d --credential-file agent-token
❯ vg reg agent --name dns-2 --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d -o json
❯ vg ls agents --namespace-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d
❯ vg up agent 019a4c21-3d4e-7f5a-8b6c-7d8e9f0a1b23 --name dns-primary
❯ vg del agent 019a4c21-3d4e-7f5a-8b6c-7d8e9f0a1b23
With -o json the credential is the credential field. -f registers one agent or an array of them from a file or stdin, such as [{"namespace_id":"<namespace_id>","name":"dns-1"}]. Agent names must be unique within the namespace, ignoring letter case. get agent and list agents never show the credential; Last Checked At shows when the agent last fetched its configuration.
Deleting an agent revokes its credential immediately. To replace a lost credential, delete the agent and register it again. Registering, renaming and deleting need the agent:write permission; listing and getting need agent:read.
API tokens
create token prints the token and its credential, vg_<token_id>.<secret>, on the last line. The credential is shown only once and can't be retrieved later, so store it right away. --credential-file <path> writes it to a new file, readable only by you, instead of printing it; an existing file is never overwritten.
❯ vg create token --permission zone:read,zone:write --description "CI pipeline"
❯ vg create token -p config:read --expires-in 2160h --credential-file ./token
❯ vg ls tokens --user-id 019a4c1e-2a5f-7b8e-9c3d-1e2f3a4b5c6d
❯ vg get token 019a4c22-1b2c-7d3e-8f4a-5b6c7d8e9f01
❯ vg up token 019a4c22-1b2c-7d3e-8f4a-5b6c7d8e9f01 --description "Deploy pipeline"
❯ vg del token 019a4c22-1b2c-7d3e-8f4a-5b6c7d8e9f01
--permission (-p) can be repeated or take a comma-separated list, and is required. A new token can only have permissions your own token has. It expires after 30 days unless --expires-in (such as 720h) or --expires-at (an RFC 3339 time) is given, at most one year ahead. A token always belongs to your own user. get token and list tokens never show the credential.
Deleting a token revokes it immediately. Permissions and expiry can't be changed: create a new token and delete the old one. Creating, updating and deleting need the token:write permission; listing and getting need token:read.
Namespace config
get config prints the DNS configuration that agents serve for a namespace: its config version, and every zone with its SOA and enabled records. Disabled records, and RRsets without an enabled record, are left out. It needs the config:read permission.
❯ vg get config 01a21992-fc5b-766b-8e0d-b8bae638e84d
┌──────────────────────────────────────┬────────────────┬───────┐
│ NAMESPACE ID │ CONFIG VERSION │ ZONES │
├──────────────────────────────────────┼────────────────┼───────┤
│ 01a21992-fc5b-766b-8e0d-b8bae638e84d │ 4 │ 1 │
└──────────────────────────────────────┴────────────────┴───────┘
┌──────────────────┬──────┬──────┬──────┬────────────────────────────────────────────────────────────────────────┐
│ ZONE │ NAME │ TYPE │ TTL │ RECORDS │
├──────────────────┼──────┼──────┼──────┼────────────────────────────────────────────────────────────────────────┤
│ example.internal │ @ │ SOA │ 3600 │ ns1.example.internal hostmaster.example.internal 4 3600 600 604800 300 │
│ example.internal │ api │ A │ 300 │ 192.0.2.10 │
│ example.internal │ www │ A │ 300 │ 192.0.2.1 │
│ │ │ │ │ 192.0.2.2 │
└──────────────────┴──────┴──────┴──────┴────────────────────────────────────────────────────────────────────────┘
With -o json it prints the API's response as is (indented), which is what an agent receives.
--known-version <n> asks the way an agent revalidates (If-None-Match: "<n>"). When n is still the current version, it prints Config version <n> is current (not modified), or {"config_version": n, "not_modified": true} with -o json, and exits 0. Otherwise it prints the newer configuration.
Handling API Errors
When an API error occurs, vg will display the error code, message, and request ID, plus any extra details the API returns about the error. This information can be useful for troubleshooting and reporting issues to the Valgrid support team.
❯ vg delete namespace 01a1ba77-e053-71bd-878c-d967b285d6d2 --yes -o json
{
"error": {
"code": "NAMESPACE_NOT_FOUND",
"message": "Namespace not found",
"request_id": "89c5cd60-44e2-4e84-90ab-0382f5b2f37f"
}
}