Console API and API tokens
Scripts and automation use the console API with an API token. A token belongs to one xnet. It can do only what its scopes allow.
Make a token
Section titled “Make a token”- In the console, open Keys & settings.
- Under API tokens, select Create token.
- Give it a name, select its scopes, and select when it expires (30 to 365 days; 90 by default).
- Copy the token. The console shows it only once.
Only an Owner or an Admin of the xnet can make or revoke tokens. A token cannot make or revoke tokens.
Use a token
Section titled “Use a token”Send it as a bearer token:
curl -H "Authorization: Bearer $ZQX_API_TOKEN" https://console.zqxnet.com/api/v1/saas/machinesEach token starts with zqx_api_. Keep it secret, as you keep a password.
Scopes
Section titled “Scopes”The table shows what each scope allows.
| Scope | Endpoints |
|---|---|
devices:read |
GET /api/v1/saas/machines, GET /api/v1/saas/services |
devices:write |
POST /api/v1/saas/machines/{controller}/{device}/revoke, POST /api/v1/saas/machines/{controller}/{device}/labels, POST /api/v1/saas/machines/{controller}/{device}/name, and the login expiry actions login-expiry, extend-login and log-out |
devices:approve |
POST /api/v1/saas/machines/{controller}/{device}/approve, POST /api/v1/saas/machines/{controller}/{device}/reject |
keys:read |
GET /api/v1/saas/keys |
keys:write |
POST /api/v1/saas/keys, POST /api/v1/saas/keys/{id}/revoke |
rules:read |
GET /api/v1/saas/acls, POST /api/v1/saas/acls/parse, GET /api/v1/saas/teams |
rules:write |
POST /api/v1/saas/acls, POST /api/v1/saas/teams, PUT and DELETE /api/v1/saas/teams/{name} |
settings:read |
GET /api/v1/saas/settings, GET /api/v1/saas/fabric, GET /api/v1/saas/dns, POST /api/v1/saas/dns/check |
settings:write |
POST /api/v1/saas/settings, PUT /api/v1/saas/dns |
audit:read |
GET /api/v1/saas/audit-log, GET /api/v1/saas/audit-log/export |
- All other endpoints refuse tokens. This includes the endpoints that manage tokens, members, licences and support access.
- Existing tokens do not get new scopes. To read the audit log with a token made before
audit:read, make a new token. - Give each token only the scopes it needs. For example, a CI job that makes a key for each runner needs only
keys:write.
Check access rules before saving them
Section titled “Check access rules before saving them”POST /api/v1/saas/acls/parse checks a policy with the same parser that enforces it, and changes nothing. It needs rules:read.
curl -s -X POST https://console.zqxnet.com/api/v1/saas/acls/parse \ -H "Authorization: Bearer $ZQX_API_TOKEN" -H 'Content-Type: application/json' \ -d '{"policy": "allow src:autogroup:member+os:managed dst:app:web port:443 proto:tcp\n"}'- A policy that parses returns each rule’s parts:
action,person(none,member,admin,owneroruser),user,src_node,src_labels,dst_node,dst_labels,dst_host,dst_self(autogroup:self),port(text:443,22,80or8000-8099;nullfor any),proto, itsnote(the#lines above it) and its canonicaltext. - A policy that doesn’t parse returns status 400 and
error, which names the line, for exampleLine 2: 'port' isn't part of a rule….
A team names a set of the xnet’s people. Access rules name it with team:<name> (access rules). Only an Owner or an Admin changes teams.
| Request | Body | Does |
|---|---|---|
GET /api/v1/saas/teams |
Lists the teams: name, note, members (user_id, email, name) and rules (how many rules name it) |
|
POST /api/v1/saas/teams |
{"name": "eng", "note": "…", "members": ["<user_id>", …]} |
Creates a team (201) |
PUT /api/v1/saas/teams/{name} |
{"note": "…", "members": [...]} |
Replaces the note and the members. The name can’t change. |
DELETE /api/v1/saas/teams/{name} |
Deletes a team. Refused (400) while a rule names it. |
- A name is 1 to 32 lower-case letters, digits and hyphens.
- Members are people of the xnet, by
user_id(fromGET /api/v1/saas/xnets/{id}/members). A person who leaves the xnet leaves its teams.
Change a node’s labels
Section titled “Change a node’s labels”POST /api/v1/saas/machines/{controller}/{device}/name with {"name": "db-1"} renames a node. The name stays until it is cleared: {"name": null} lets the node use its own hostname again. Without a rename, a node’s name follows its OS hostname.
POST /api/v1/saas/machines/{controller}/{device}/labels with {"labels": ["ops:env=prod", "zqx:relay"]} replaces the node’s labels. An empty list removes them. Keys take labels the same way: POST /api/v1/saas/keys with {"labels": [...]}. A key with no labels is single-use and lasts 7 days at most: a reusable key, or one with expires_hours above 168, needs at least one label (400 with the reason).
- A label is
namespace:keyornamespace:key=value, in lower case. The CLI reference gives the characters and the lengths. - The API refuses upper case, a reserved namespace, two values for one key, and more than 32 labels. The error message says what to fix.
- Namespaces that start with
zqxare reserved. Inzqx, only the labels of ZQX’s catalog are allowed. Today that iszqx:relay: the node relays for its xnet. - A provider’s labels (
zqx-<name>:…) are never set through this API. - No access rule is needed first: a label is a fact, and the rules decide access.
- The node and its peers get the change at once. The node keeps it when it reconnects.
- The node list (
GET /api/v1/saas/machines) shows each node’s labels, and itsversionandosas it reported them. Nodes older than v0.9.5 report no version.
Login expiry
Section titled “Login expiry”A person’s login on a node lasts the xnet’s login lifetime. Then the node is logged out: it keeps the access of its labels, and the person logs in again on it. Labels never expire.
- The lifetime:
POST /api/v1/saas/settingswith{"login_lifetime_days": 180}: 1 to 365 days, 180 by default;0means logins do not expire.GETshowslogin_lifetime_days,nullwhen logins do not expire. A change applies at each node’s next login. - The node list shows
login_expires_at(Unix seconds;nullfor a node with no person, with expiry off, or with a login that does not expire) andexpiry_disabled. - Turn expiry off or on for one node:
POST /api/v1/saas/machines/{controller}/{device}/login-expirywith{"disabled": true}or{"disabled": false}. Off: the person’s login on that node does not expire. The setting stays across logins. - Extend 1 day:
POST /api/v1/saas/machines/{controller}/{device}/extend-login. It adds a day to the later of the expiry and now. A node with no person, or a login that does not expire, gets400. - Log out:
POST /api/v1/saas/machines/{controller}/{device}/log-outdetaches the person at once, aszqx logouton the node. The answer has"logged_out": falsewhen the node had no person. For a lost or stolen node, remove it instead (revoke): its browser can still be logged in to ZQX. - These three need
devices:write, and an Owner or Admin in the console. - The audit log records
device.expiry_disabled,device.expiry_enabled,device.expiry_extendedanddevice.logged_outwith who acted;device.login_expiredwhen a login ends at its expiry;device.logged_inwhen a person logs in on a node that has joined; anddevice.logged_out(by the node, or when its person leaves the xnet).
Node expiry
Section titled “Node expiry”An option of the xnet, off by default. When it is on, every node, labelled ones too, must be renewed by an Owner or Admin within the period. It confirms on a schedule that each node still belongs in the xnet.
- The period:
POST /api/v1/saas/settingswith{"device_expiry_days": 90}: 30 to 365 days;0turns it off.GETshowsdevice_expiry_days,nullwhen off. Turning it on gives each node the period from now, so nothing expires at once. - The node list shows
device_expires_at(Unix seconds;nullwhen off or exempt),device_expiry_exemptanddevice_expired. - Renew:
POST /api/v1/saas/machines/renewwith{"node_ids": ["<node>", …]}. Each node gets the period from now, and an expired node gets its access back at once. With nonode_ids, it renews every node that expires within 14 days or has expired. It needsdevices:approve. - Exempt one node:
POST /api/v1/saas/machines/{controller}/{device}/expiry-exemptwith{"exempt": true}.{"exempt": false}ends the exemption and gives the node the period from now. It needsdevices:write. - At the expiry the node has no access, from its labels or its person, until it is renewed. It stays in the list, with its address. Each node refuses its streams by itself (
0x07), also when the controller cannot be reached. - A login does not renew a node. Only a renewal does.
- The audit log records
device.renewed,device.expiry_exemptanddevice.expiry_not_exemptwith who acted,device.expiredat the expiry, andsettings.updatefor the period.
Node approval
Section titled “Node approval”When an xnet needs approval for new nodes, a node that joins with a valid key waits, with no access.
- The node list shows a waiting node with
"approval": "pending",pending_sinceandpending_expires_at(Unix seconds). - Approve:
POST /api/v1/saas/machines/{controller}/{device}/approve. The node then joins by itself. - Reject:
POST /api/v1/saas/machines/{controller}/{device}/reject. The node is removed, and needs a new key. - Both need
devices:approve. Give an approval script only this scope. - Settings:
POST /api/v1/saas/settingswith{"approval_required": true, "pending_timeout_secs": 604800}. The wait is from 1 hour to 30 days, 7 days by default. A node not approved in time is removed. - Identify nodes:
POST /api/v1/saas/settingswith{"identify_within_secs": 259200}. A node with no label and no person loses access after this time: from 1 hour to 30 days, 72 hours by default. It cannot be turned off. The node list showsidentity_deadline(Unix seconds;nullfor a node with a label or a person) andneeds_identity(trueafter the deadline). A label or a login gives the access back. The audit log recordsdevice.needs_identityanddevice.identified. - Keys:
POST /api/v1/saas/keyswith"pre_approved": truemakes a key whose nodes skip approval, for servers and CI runners. - The audit log records each approval and rejection, with who made it: a person, or a token.
DNS settings
Section titled “DNS settings”GET /api/v1/saas/dns gives the xnet’s DNS settings, and for each nameserver node its name and fabric IP:
{ "settings": { "nameservers": [{ "kind": "https", "url": "https://dns.example/dns-query", "bootstrap": ["192.0.2.10"] }], "use_for_all_names": true, "strict": false, "routes": [ { "domain": "corp.example.com", "nameservers": [{ "kind": "device", "node_id": "3f9a…" }] }, { "domain": "lan", "nameservers": [] } ], "search_domains": ["corp.example.com"] }, "devices": { "3f9a…": { "name": "dns-1", "ip": "100.70.1.2" } }}PUT /api/v1/saas/dnsreplaces the whole document. A document that breaks a rule changes nothing: 400, with the item and the rule.POST /api/v1/saas/dns/checkchecks a document without saving it. It givesfindings: nodes that the access rules keep from a nameserver node, and nodes with DNS settings turned off.- Nameserver kinds:
address(ip, optionalport),https(url, optionalbootstrapaddresses),tls(name,ip, optionalport),device(node_id, optionalport). - A route with no nameservers sends its domain to each node’s own DNS.
| Limit or rule | Value |
|---|---|
| Nameservers | 8 at most |
| Split DNS routes | 64 at most, 8 nameservers each at most, one route for each domain |
| Search domains | 16 at most |
| Domains | Lower-case letters, digits, hyphens and dots. Not the xnet’s own domain, not zqxnode.com, not .local. |
| Nameserver addresses | Not 100.100.100.53, loopback, link-local, multicast or unspecified addresses |
| “Use for all names” | Needs at least one nameserver. Strict mode needs “use for all names”. |
Errors
Section titled “Errors”| Status | Meaning |
|---|---|
401 |
The token is unknown, revoked or expired. |
403 |
The token does not have the scope for this endpoint, or tokens cannot use it. The message names the scope that is needed. |
409 |
Approve: the node is not waiting for approval. |
Revoke a token
Section titled “Revoke a token”In Keys & settings, under API tokens, select Revoke. The token stops working at once.
When an xnet is deleted, its tokens are deleted too.
Audit log
Section titled “Audit log”The audit log shows who changed what in the xnet. It also shows what ZQX operations did on the xnet.
- Who can read it: an Owner, an Admin or an Auditor in the console (Audit log), or a token with
audit:read. A Member cannot read it, because it shows other members’ emails. - What it keeps: the last 90 days, on every plan.
- What it records: successful changes, refused logins, and ZQX staff actions on the xnet. Reads are not recorded. The console shows when each token was last used.
- What it never records: key values, token values, traffic and traffic keys.
Read a page
Section titled “Read a page”GET /api/v1/saas/audit-log returns the newest entries first, 100 to a page.
| Parameter | Meaning |
|---|---|
limit |
Entries on the page, 1 to 1000 (100 by default) |
before |
An entry ID (aud_…): the next page starts after it. Use next_before from the last page. |
since, until |
Unix seconds: the time range |
action |
An action, for example device.remove, or a group, for example device |
actor |
A person’s email, a user ID or a token ID |
Each entry has these fields:
| Field | Meaning |
|---|---|
id |
The entry ID |
time |
Unix seconds, UTC |
actor_kind |
member, api_token, zqx_staff or system |
actor_id |
A user ID, a token ID, or a pseudonym for a ZQX staff member |
actor |
Who acted, in words: an email and a role, a token, “ZQX operations” or “ZQX” |
action |
What was done, for example rules.update |
target |
What it was done to |
summary |
What happened, in plain words |
ticket_id |
The support ticket, for ZQX staff actions |
change |
The change, when there is one. For rules.update: the rules before and after. |
When a person asks for erasure, their email goes from the log. Their entries then show “deleted user (user_…)”.
Download
Section titled “Download”GET /api/v1/saas/audit-log/export?format=csv or format=json returns every entry that matches the same filters. Times are in UTC (time_utc).
Actions
Section titled “Actions”| Action | When |
|---|---|
device.approve, device.reject |
A waiting node is approved or rejected |
device.enrol |
A node joins the xnet: with a key (shown as “ZQX”), or by node login (shown as its owner). The controller reports it; the entry can come some seconds after the join. |
device.owner |
A node that joined with a key gets an owner |
device.leave |
A node leaves by itself: it logs out, or it expires (an ephemeral node that stays offline, or a wait for approval that ends) |
device.remove |
A node is removed |
device.labels |
A node’s labels change |
device.rename |
An admin renames a node, or lets it use its hostname again |
rules.update |
The access rules change |
key.create, key.revoke |
A key is made or revoked |
settings.update |
The xnet’s settings change |
dns.update |
The xnet’s DNS settings change |
api_token.create, api_token.revoke |
An API token is made or revoked |
member.add |
A member is added |
member.remove |
An Owner or an Admin removes a member (with the nodes removed and kept) |
member.remove_completed |
The controller completes a removal that waited for it |
support_access.on, support_access.off |
A member turns ZQX support access on or off |
sign_in, sign_in.refused |
A member logs in to the console, or the login is refused |
step_up |
A member logs in again to confirm a destructive action |
xnet.create, xnet.enter, xnet.delete |
The xnet is made, a member switches to it, or it is deleted |
support.*, failover.*, security.*, billing.* |
ZQX staff actions on the xnet |
Invitations
Section titled “Invitations”A person joins an xnet only by accepting an invitation. ZQX sends no email: the console shows the invitation’s link, and you send it. In the console, the Members page does each step below. It also has Approve new members (member_approval). Keys & settings has Login from another computer (remote_sign_in).
| For one email | An invite link | |
|---|---|---|
| Who can accept | The person who logs in with that email | Anyone with the link; or only people of one email domain |
| Role | The role you choose (only an Owner invites an Owner) | Member |
| Life | 30 days | 7 days by default (1 to 90) |
| Uses | One | 10 by default |
| After the accept | A member at once | Waits until an Owner or an Admin approves |
POST /api/v1/saas/xnets/{id}/inviteswith{ "email": "ann@example.com", "role": "Admin" }, or{ "max_uses": 20, "domain": "example.com" }for a link. The answer haslink, once: ZQX keeps only a hash of it.GET /api/v1/saas/xnets/{id}/inviteslists them (with no link).DELETE /api/v1/saas/xnets/{id}/invites/{invite_id}revokes one.GET /api/v1/saas/xnets/{id}/member-requestslists the people who wait.POST /api/v1/saas/xnets/{id}/member-requests/{user_id}/approveor/rejectdecides. An approval needs a free seat.- Only an Owner or an Admin, logged in as a person, uses these routes. API tokens can’t invite.
- Once the login host is live,
POST /api/v1/saas/xnets/{id}/memberswith an email makes an invitation for that email, and answers with its link.
Members
Section titled “Members”GET /api/v1/saas/xnets/{id}/memberslists the members:user_id,email,name,role. An Owner, an Admin or an Auditor of the xnet.DELETE /api/v1/saas/xnets/{id}/members/{user_id}removes a member. In the console: Members, People, Remove.- Who: an Owner removes anyone else; an Admin removes anyone who is not an Owner. Nobody removes themselves, and the last Owner stays.
- The person leaves the xnet at once. Their open invitations to it are revoked; they come back only with a new invitation.
- Their nodes keep only their labels: each admitted node stays, without the person. A node with labels keeps the access of its labels. A node with no labels loses access after the xnet’s identify time (Identify nodes within), unless it gets a label or a login. A node that still waits for approval is removed.
- Their sessions on this xnet move to their other xnet. If this xnet was their only one, their account is deleted.
- The answer has
devices_removed(waiting nodes),devices_kept,account_deletedandwaiting_for_controller. When the xnet’s controller is not connected, the node part waits and completes when it connects again (auditmember.remove_completed).
- The invited person opens the link, logs in, and clicks Accept or Decline. Open invitations for the person’s email also show on the node page of a login, and on the login host’s own page.
- Audit entries:
member.invite_create,member.invite_accept,member.invite_decline,member.invite_revoke,member.approve,member.reject.
Domain join
Section titled “Domain join”An Owner can let people with an email of the company’s domain ask to join the xnet. It is off until an Owner turns it on.
GET /api/v1/saas/xnets/{id}/domainshows the domain the xnet holds, the domain your login offers, and the DNS record of the xnet.POST /api/v1/saas/xnets/{id}/domain/claimturns domain join on for the domain of your own login. This needs a Google Workspace account of that domain, a domain that is not shared by many people (for examplegmail.com), and no other xnet that holds it. The first claim wins.- The DNS record confirms the claim, or takes the domain back from another xnet: add
_zqx-verify.<domain>with the TXT value that theGETshows, thenPOST /api/v1/saas/xnets/{id}/domain/verifywith{ "domain": "acme.com" }. A domain moves to your xnet only while the other xnet’s record is not in DNS. A record that answers for every name (a wildcard) does not count. DELETE /api/v1/saas/xnets/{id}/domainturns domain join off.- People of the domain see the xnet, with its Owner, on the login pages, and click Join. Until the record confirms the domain, the page says that the company did not confirm the xnet. They wait for an Owner or an Admin to approve them (
member-requests), unless member approval is off. - An unconfirmed claim with no login of an Owner of the domain for 90 days stops offering the xnet, until an Owner logs in again.
Login settings
Section titled “Login settings”GET and PUT /api/v1/saas/xnets/{id}/login-settings (an Owner or an Admin):
| Setting | Values | Default |
|---|---|---|
remote_sign_in |
allowed, needs_approval, off |
needs_approval with two or more members, allowed with one |
member_approval |
true, false |
true: people from an invite link or the domain wait for an approval |
- Remote login is a login confirmed in a browser on another computer than the node.
needs_approvalmakes the node wait for an Owner or an Admin.offrefuses it: people log in on the node itself. - A change writes the audit entry
settings.update. - In the console,
member_approvalis Members, Approve new members, andremote_sign_inis Keys & settings, Login from another computer. Each Save sends the other setting with its stored value, so one page never changes the other’s setting.
Plan and licences
Section titled “Plan and licences”GET /api/v1/saas/plan (an Owner or an Admin; tokens are refused) gives what the console’s Plan & licences page shows, for the whole organisation, whatever xnet is selected:
| Field | Holds |
|---|---|
as_of |
When the counts were taken |
plan |
tier, org_id, org_name |
users |
used, max (0: no limit) |
hosted |
max xnets on ZQX; for each hosted xnet its xnet_id, name and nodes: used and inactive (not seen for 30 days; both null when its controller did not answer), max |
own |
available, max_controllers, controllers (controller_id, name, connected, last_seen_secs), xnets (used, max) |
licences |
license_id, kind (organisation, own_controller, controller), tier, issued_at_secs, expires_at_secs, renews, in_renewal_window, controller |
It never holds a licence’s signature or token. GET /api/v1/saas/licenses lists the organisation’s licences in the same way, whatever xnet is selected.
Support access
Section titled “Support access”GET and POST /api/v1/saas/support-access need an Owner or an Admin. The support PIN lets ZQX staff in, so other roles cannot read it.
For ZQX v0.25.1. Each page describes this release.