API user guide
This guide covers the namespace, team and user operations currently available to API
customers. The current API version is v1. The
OpenAPI contract
describes the available routes.
To run DNS servers in your network that serve your zones, see the deployment guide.
Before you start
Create an API token with the permissions you need (see
API tokens). The token must be valid and unexpired. The quickest
way to get your first one is vg login (see Signing in).
The API base URL is https://api.valgrid.io. Versioned endpoints use the /v1
prefix, for example https://api.valgrid.io/v1/namespaces.
Signing in
Sign up for Valgrid at https://app.valgrid.io/signup with your organization's
name, a short name for its address (the slug) and your own name and email.
Valgrid emails you a link; opening it creates your organization at
https://<slug>.app.valgrid.io and signs you in there as its owner.
After that, sign in at https://<slug>.app.valgrid.io/login: enter your email
address and Valgrid emails you a sign-in link and a code. The link and the code
work once and expire after 15 minutes. A browser session ends after 12 hours
without use, or 7 days after you signed in. People you add as users get an email
pointing to the same page.
To get an API token on the command line, run
vg login --host <slug>.app.valgrid.io --email <your email> and type the code
from the email. vg saves a token with every permission of your role, valid for
30 days.
Check availability
The ping endpoint does not require a token:
curl --fail-with-body https://api.valgrid.io/ping
It returns {"message":"pong"} when the API is responding.
Authenticate
Send your token in the Authorization header using the bearer scheme. The
examples below build this header from your environment variable so the token is
not written directly into the command:
export VALGRID_API_URL='https://api.valgrid.io'
export VALGRID_API_KEY='<your API token>'
Each example has a curl tab and a vg tab.
vg reads the same VALGRID_API_URL and VALGRID_API_KEY variables
and prints a table by default; add -o json for the API's JSON. Its delete
commands ask for confirmation, which --yes skips.
Tokens have the format vg_<public UUID>.<secret>. Send the complete value;
the UUID alone cannot authenticate. Tokens are shown only when created, so
create a new one if you lose one. Legacy UUID-only tokens must be replaced.
Keep the token private. The API determines the tenant from the token, so do not
send an X-Tenant-Id header. An invalid or expired token receives HTTP 401; a valid token
without the required operation permission receives HTTP 403. A valid token
whose tenant has been disabled receives HTTP 403 with code TENANT_DISABLED.
List namespaces
Requires the namespace:read permission:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/namespaces"
vg list namespaces
The response is a JSON array of namespaces belonging to the token's tenant. Each namespace has these fields:
| Field | Type | Description |
|---|---|---|
namespace_id |
UUID | Namespace identifier. |
name |
string | Name, unique within the tenant. |
description |
string | Optional description; empty when not set. |
config_version |
integer | Current configuration version, starting at 0. Valgrid sets it; requests cannot change it. |
updated_at |
date-time | Time of the last change. |
Get, create, and update return a single namespace with the same fields.
Get a namespace
Requires the namespace:read permission. Use a namespace_id from the list or
create response:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/namespaces/<namespace_id>"
vg get namespace <namespace_id>
Success returns HTTP 200 and the namespace as JSON. A malformed ID returns
400; an unknown namespace or one belonging to another tenant returns 404.
Create a namespace
Requires the namespace:write permission. Provide a non-empty name; the
description is optional:
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"name":"staging","description":"Staging DNS"}' \
"${VALGRID_API_URL}/v1/namespaces"
vg create namespace --name staging --description "Staging DNS"
Success returns HTTP 201 and the created namespace as JSON, including its
namespace_id. Names must be unique within the tenant among namespaces that
have not been deleted, ignoring letter case. A missing name, invalid request body, or duplicate name
returns HTTP 400.
Update a namespace
Requires the namespace:write permission. The update route accepts a JSON
object containing the namespace fields to change, name and/or description.
Names must remain unique within the tenant:
curl --fail-with-body \
-X PATCH \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"name":"staging-v2","description":"Updated staging DNS"}' \
"${VALGRID_API_URL}/v1/namespaces/<namespace_id>"
vg update namespace <namespace_id> --name staging-v2 --description "Updated staging DNS"
Success returns HTTP 200 and the updated namespace as JSON. Invalid JSON or a
malformed ID returns 400; a duplicate name also returns 400. A namespace
that does not exist for the authenticated tenant returns 404.
Delete a namespace
Requires the namespace:write permission. Use the namespace_id from the
create response or namespace list:
curl --fail-with-body \
-X DELETE \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/namespaces/<namespace_id>"
vg delete namespace <namespace_id>
Success returns HTTP 200 with an empty body. The operation soft-deletes the
namespace and its associated DNS records, RRsets, zones, agents, and
configurations. A malformed ID returns 400. An unknown ID, or a namespace
outside the token's tenant, returns 404. The protected Default namespace
cannot be deleted; attempts return 400 with code NAMESPACE_DELETE_PROTECTED.
Teams
Teams group the users of your tenant. Every tenant has a Default team, which
cannot be renamed or deleted. Team operations require the team:read
permission to list and get, and team:write to create, update, and delete.
Each team has these fields:
| Field | Type | Description |
|---|---|---|
team_id |
UUID | Team identifier. |
name |
string | Name, unique within the tenant, ignoring letter case. |
email |
string | Optional contact email address; empty when not set. |
updated_at |
date-time | Time of the last change. |
List teams (a JSON array, newest first, paged with limit and after as
described in Validations) or get one team by ID:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/teams"
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/teams/<team_id>"
vg list teams
vg get team <team_id>
Create a team with a non-empty name and an optional email. Success returns
HTTP 201 and the created team:
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"name":"platform","email":"platform@example.com"}' \
"${VALGRID_API_URL}/v1/teams"
vg create team --name platform --email platform@example.com
Update a team by sending the fields to change, name and/or email. Send
"email":"" to clear the email. Success returns HTTP 200 and the updated
team:
curl --fail-with-body \
-X PATCH \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"name":"platform-dns"}' \
"${VALGRID_API_URL}/v1/teams/<team_id>"
vg update team <team_id> --name platform-dns
Delete a team by ID. Success returns HTTP 200 with an empty body. A team that
still has users cannot be deleted:
curl --fail-with-body \
-X DELETE \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/teams/<team_id>"
vg delete team <team_id>
A malformed ID, invalid request body, invalid field value, or duplicate name
returns HTTP 400. An unknown team, or one belonging to another tenant, returns
404. See Validations for the field rules.
Users
Users are the members of your tenant. Each user belongs to one team and has a
role. User operations require the user:read permission to list and get, and
user:write to create, update, and delete.
A user's role decides what the user can do:
| Role | Can do |
|---|---|
owner |
Everything: every permission. |
member |
Read only: every :read permission. |
The role also limits the user's API tokens. A member's token can only read, even if it was created with write permissions, and changing a user's role changes what their existing tokens can do straight away. Your tenant always keeps at least one owner.
Each user has these fields:
| Field | Type | Description |
|---|---|---|
user_id |
UUID | User identifier. |
team_id |
UUID | The team the user belongs to. |
first_name |
string | First name. |
last_name |
string | Last name. |
email |
string | Email address, unique within the tenant, ignoring letter case. |
role |
string | owner or member. |
avatar_url |
string | Optional avatar image URL; empty when not set. |
updated_at |
date-time | Time of the last change. |
List users (a JSON array, newest first, paged with limit and after as
described in Validations) or get one user by ID:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/users"
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/users/<user_id>"
vg list users
vg get user <user_id>
Create a user with first_name, last_name and email, and optionally
avatar_url, team_id and role. Without team_id, the user joins the
Default team, and without role the user is a member. Success returns HTTP 201 and the created user:
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"first_name":"Ada","last_name":"Lovelace","email":"ada@example.com"}' \
"${VALGRID_API_URL}/v1/users"
vg create user --first-name Ada --last-name Lovelace --email ada@example.com
Update a user by sending only the fields to change. Send a team_id to move
the user to another team, role to change their role, and "avatar_url":""
to clear the avatar. Changing the role of your tenant's last owner returns
HTTP 400 with USER_LAST_OWNER. Success
returns HTTP 200 and the updated user:
curl --fail-with-body \
-X PATCH \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"team_id":"<team_id>"}' \
"${VALGRID_API_URL}/v1/users/<user_id>"
vg update user <user_id> --team <team_id>
Delete a user by ID. Success returns HTTP 200 with an empty body, and the
user's API tokens stop working. You cannot delete your own user:
curl --fail-with-body \
-X DELETE \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/users/<user_id>"
vg delete user <user_id>
A malformed ID, invalid request body, invalid field value, unknown team, or
duplicate email returns HTTP 400. An unknown user, or one belonging to another
tenant, returns 404. See Validations for the field rules.
Zones and records
A zone is a DNS domain, such as example.internal, in one of your namespaces.
Its records are grouped into RRsets: every record of one type at one name.
Zone and RRset operations require the zone:read permission to list and get,
and zone:write to create, update, and delete. Every change to a zone or its
records increases the namespace's config_version and the zone's SOA
serial, which is how DNS agents notice that the configuration changed.
Create a zone with the namespace it belongs to and its name. The SOA values are
optional. Success returns HTTP 201 and the created zone:
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"namespace_id":"<namespace_id>","name":"example.internal","soa":{"refresh":1800}}' \
"${VALGRID_API_URL}/v1/zones"
vg create zone -f - <<'EOF'
{"namespace_id":"<namespace_id>","name":"example.internal","soa":{"refresh":1800}}
EOF
List zones (newest first, paged like namespaces; add
?namespace_id=<namespace_id> for one namespace), get one by ID, update its
description or soa values with PATCH, and delete it with DELETE, which
also deletes its records:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/zones?namespace_id=<namespace_id>"
vg list zones --namespace-id <namespace_id>
Add records by creating an RRset in the zone. The name is relative to the zone
(@ is the zone itself) and the TTL defaults to 300 seconds:
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"name":"www","type":"A","ttl":300,"records":[{"content":"192.0.2.1"},{"content":"192.0.2.2"}]}' \
"${VALGRID_API_URL}/v1/zones/<zone_id>/rrsets"
vg create rrset <zone_id> --name www --type A --ttl 300 \
--record 192.0.2.1 --record 192.0.2.2
To change records, send the full new list with PATCH; it replaces the
existing records. Set "disabled":true on a record to keep it without serving
it:
curl --fail-with-body \
-X PATCH \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"records":[{"content":"192.0.2.1"},{"content":"192.0.2.3"}]}' \
"${VALGRID_API_URL}/v1/zones/<zone_id>/rrsets/<rrset_id>"
vg update rrset <zone_id> <rrset_id> --record 192.0.2.1 --record 192.0.2.3
GET /v1/zones/<zone_id>/rrsets lists the zone's RRsets with their records,
and DELETE /v1/zones/<zone_id>/rrsets/<rrset_id> removes one.
Both list endpoints take filters. GET /v1/zones?name=example.internal lists
only zones with that name, and GET /v1/zones/<zone_id>/rrsets?name=www&type=A
only that zone's www A RRset. Repeat name or type to match any of
several values, up to 128 each. RRset names are relative to the zone (@ is
the zone itself). Filters stay in the Link URL of the next page:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/zones/<zone_id>/rrsets?name=www&type=A&type=AAAA"
vg list rrsets <zone_id> --name www --type A --type AAAA
To find a name's records without knowing its zone, use
vg lookup. See
Validations for the accepted names, types and record formats.
Namespace DNS configuration
DNS agents read the DNS configuration of a namespace: every zone with its SOA
values and RRsets. Only enabled records are included, and an RRset with no
enabled records is left out. Use an agent credential (see
Agents), which can read only its own namespace's configuration. An
API token with the config:read permission can read it too.
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/namespaces/<namespace_id>/config"
vg get config <namespace_id> -o json
{
"namespace_id": "<namespace_id>",
"config_version": 4,
"zones": [
{
"name": "example.internal",
"soa": {"primary_ns": "ns1.example.internal", "hostmaster": "hostmaster.example.internal", "serial": 4, "refresh": 3600, "retry": 600, "expire": 604800, "minimum": 300, "ttl": 3600},
"rrsets": [
{"name": "www", "type": "A", "ttl": 300, "records": ["192.0.2.1", "192.0.2.2"]}
]
}
]
}
The ETag response header holds the configuration version. Send it back in
If-None-Match to get HTTP 304 with no body while the configuration has not
changed:
curl --fail-with-body \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'If-None-Match: "4"' \
"${VALGRID_API_URL}/v1/namespaces/<namespace_id>/config"
vg get config <namespace_id> --known-version 4
An unknown namespace, or one belonging to another tenant, returns 404.
Agents
Register each DNS agent for the namespace it serves. Registering an agent
returns its credential, which you configure on the agent. The credential is
shown only once, so store it in your secret manager right away. It can only
read that namespace's DNS configuration; every other request made with it is
refused. Managing agents requires the agent:read permission to list and get,
and agent:write to register, rename, and delete.
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"namespace_id":"<namespace_id>","name":"dns-1"}' \
"${VALGRID_API_URL}/v1/agents"
vg register agent --name dns-1 --namespace-id <namespace_id> -o json
{
"agent_id": "<agent_id>",
"namespace_id": "<namespace_id>",
"name": "dns-1",
"last_checked_at": null,
"updated_at": "2026-11-26T12:00:00Z",
"credential": "vga_<agent_id>.<secret>"
}
Agent names must be unique within the namespace, ignoring letter case.
last_checked_at shows when the agent last fetched its configuration.
GET /v1/agents?namespace_id=<namespace_id> lists a namespace's agents, and
PATCH /v1/agents/<agent_id> with {"name":"..."} renames one.
To revoke an agent's credential, delete the agent. Deleting a namespace deletes its agents too.
curl --fail-with-body \
-X DELETE \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/agents/<agent_id>"
vg delete agent <agent_id>
API tokens
Create a token for each script, pipeline or person that calls the API, with
only the permissions it needs. Creating a token returns its credential, which
is shown only once, so store it in your secret manager right away. You can give
a new token only permissions that your own token has and that your
role allows. Managing tokens requires
the token:read permission to list and get, and token:write to create,
update, and delete.
The permissions are namespace:read, namespace:write, team:read,
team:write, user:read, user:write, zone:read, zone:write,
config:read, agent:read, agent:write, token:read and token:write.
curl --fail-with-body \
-X POST \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
-H 'Content-Type: application/json' \
-d '{"description":"CI pipeline","permissions":["zone:read","zone:write"]}' \
"${VALGRID_API_URL}/v1/tokens"
vg create token --permission zone:read,zone:write --description "CI pipeline" -o json
{
"token_id": "<token_id>",
"user_id": "<user_id>",
"description": "CI pipeline",
"permissions": ["zone:read", "zone:write"],
"expires_at": "2027-01-04T12:00:00Z",
"revoked": false,
"last_used_at": null,
"updated_at": "2026-12-05T12:00:00Z",
"credential": "vg_<token_id>.<secret>"
}
A token expires after 30 days unless you set expires_at (at most one year
ahead). It always belongs to your own user: you can't create a token for
another user. last_used_at shows when the token was last used.
GET /v1/tokens?user_id=<user_id> lists a user's tokens, and
PATCH /v1/tokens/<token_id> with {"description":"..."} changes a token's
description. Permissions and expiry can't be changed: create a new token and
delete the old one.
To revoke a token, delete it. It stops working immediately. A token can delete itself. Deleting a user deletes the user's tokens too.
curl --fail-with-body \
-X DELETE \
-H "$(printf '%s %s %s' 'Authorization:' 'Bearer' "$VALGRID_API_KEY")" \
"${VALGRID_API_URL}/v1/tokens/<token_id>"
vg delete token <token_id>
Errors and limits
API error responses include an error object with a code, message, and
request_id. The same request ID is available in the X-Request-ID response
header. For example, an expired token returns HTTP 401:
{
"error": {
"code": "AUTHORIZATION_TOKEN_EXPIRED",
"message": "Unauthorized (token has expired)",
"request_id": "4ac91f83-8e6e-419d-9a45-d4c312a22e17"
}
}
The API allows 60 requests per client IP per minute. When the limit is exceeded,
it returns HTTP 429, a Retry-After header whose value is seconds, and the
standard error body with code RATE_LIMIT_EXCEEDED.
Request bodies are limited to 1 MiB. A larger body returns HTTP 413 with code
REQUEST_BODY_TOO_LARGE.
Match on code, not message: codes are stable, while messages may be
reworded. The OpenAPI specification lists every code. Namespace errors include
NAMESPACE_ID_INVALID (400, the ID is not a valid UUID),
NAMESPACE_NAME_CONFLICT (400, the name is already used in the tenant),
NAMESPACE_NOT_FOUND (404), and NAMESPACE_DELETE_PROTECTED (400, the
Default namespace). Team errors include TEAM_ID_INVALID (400),
TEAM_NAME_CONFLICT (400), TEAM_NOT_FOUND (404), and
TEAM_DELETE_PROTECTED (400, the Default team or a team that still has
users). User errors include USER_ID_INVALID (400),
USER_EMAIL_CONFLICT (400), USER_NOT_FOUND (404), and
USER_DELETE_PROTECTED (400, your own user). Zone errors include
ZONE_ID_INVALID (400), ZONE_NAME_CONFLICT (400, the name is already used in the namespace), and ZONE_NOT_FOUND
(404). RRset errors include RRSET_ID_INVALID (400), RRSET_CONFLICT
(400, the name and type already exist, or a CNAME would share its name with
other records), and RRSET_NOT_FOUND (404).
The API currently supports ping, and list, get, create, update, and delete for namespaces, teams, users, zones, RRsets and agents. Other resource operations shown in project design documents are not available as API routes yet.