API Tokens
The dashboard's API is normally reached by the dashboard itself, with a session cookie a browser holds. An API token is the other way in: a long-lived secret a program of your own sends with every request — a script, a status display in the hallway, a nightly export, anything that has no browser to sign in with.
A token belongs to one account, the one that created it. It is not a service account and not a second set of permissions: it is that person, without the browser.
Creating one
Profile → API tokens (/profile/tokens), reached from the account menu
or from the profile's sidebar. Every account may create tokens for itself;
there is nothing to enable and no administrator involved.
The form asks for two things:
- a name, which appears nowhere but this list. It is what you read months later when deciding which of four tokens to revoke, so name it after the program, not after the day.
- an expiry date, optional. Left empty, the token works until it is revoked.
- what it may do: read and write (the default) or read only. A read-only token (its
value starts
selv_ro_) answersGETrequests and nothing else: every write is refused with403 token_read_onlybefore it reaches a route, and so are the places that hand out ways in, whatever the verb: accounts, settings, the profile, enrolment tokens, the command line's sign-in and webhooks. It is the token for monitoring and reports. It is as old as the account's own reach: it never sees more than the account does. One exception: it mayPOSTto/api/mcpand is then offered the read tools only, see MCP Server.
No token, read-write or not, can approve or deny anything held for approval: a job, a patch
run, an update release, a script version, an access request, a remediation rule or a shell grant.
Those routes answer 403 to a token and take a person signed in with a browser, so a program
cannot release what it asked for itself.
An account may have 25 tokens in use at once; revoke one to make another.
The token's value is shown once, immediately after creating it, with a copy button. It is never shown again and cannot be recovered — only the hash of it is stored, so the dashboard itself cannot tell you what it was. Lose it and the answer is to revoke that token and create another.
Tokens the command line issues
Signing in with selvara login creates a token too, but you never see its
value: the command line receives it once you confirm the sign-in in the
browser. It appears in the same list, marked Command line, named after the
program and the computer it runs on, and it expires after 90 days. Revoke it
here to sign that computer out; selvara logout does the same from the
computer's side. Like any token, it cannot create further tokens.
Tokens the desktop app issues
The Remote Connection Manager signs in the same way and is listed as Remote Connection
Manager. Its token is a different kind: it reaches the access entry data, the alerts and the
inbox the app shows, and the app's own lock routes and nothing else (no users, grants,
settings, tokens or releases, and no pages), and every other route answers
403 token_kind_not_allowed. It does not run out
after a fixed time: each day it is used, its expiry moves 90 days ahead, up to 365 days
after it was issued, so a device in daily use never signs in again and an idle one lapses
by itself. See Access Entries for the PIN it asks for.
Using one
The program sends the value as an ordinary bearer token:
Authorization: Bearer selv_…
For example:
curl -H "Authorization: Bearer $SELVARA_TOKEN" \
https://selvara.example.com/api/systems
Every endpoint the interface uses accepts this, except the account's own
/api/profile/*, which takes the session cookie only. The token is checked before the
cookie, so a request that carries one is answered as that token even if a
session cookie happens to be there too. The endpoints, their parameters and
their answers are listed in HTTP API.
Keep the value out of the repository and out of the command line where you can —
an environment variable or a file only the program's user can read. A value that
begins with selv_ in a log is a token that needs revoking.
Following changes as they happen
A program that wants to be told rather than ask again opens the WebSocket at
wss://<your-dashboard>/api/live with the same Authorization header. The
server answers {"t":"ready"}; the program then subscribes, under an id of its
own choosing:
{"t":"sub","sid":"alerts","topic":"alert","after":null}
Every alert transition the token's account may see arrives as
{"t":"msg","sid":"alerts","id":"…","data":{…}}. Passing the last id as
after on a new connection hands over what was missed while it was away, as
long as the server has not restarted in between. The server pings every 25
seconds, and closes the socket with code 4000 when the account's rights change,
4401 when the token stops working, and 1001 when it restarts.
The same socket carries every list the dashboard shows — systems.list,
alerts.counts and the rest — as {"t":"snap","sid":…,"rev":…,"data":…},
pushed again whenever it changes. Their shapes follow the dashboard and change
with it.
What a token may do
Exactly what its owner may do, decided fresh on every request.
The token carries nothing but the account's identity. The role and the customer grants are read from the database each time, the same way they are for a browser (see Users and Permissions). So:
- a token issued by a viewer reads, and is refused every write;
- a token issued by an operator may acknowledge alerts at the customers that account is granted — and stops being able to the moment a grant is withdrawn;
- promoting or demoting the account changes what its tokens may do immediately. There is nothing to reissue.
One thing a token may not do, whatever its account is: change the account's
email address, password or role, or delete an account. Those requests are
refused with 403 unless they come from a signed-in browser, so a leaked token
cannot be used to take over the account it belongs to. The change itself, by
whoever makes it in a browser, appears in the audit log.
A token is therefore not a way to give somebody narrower access than their account has, except that a read-only token keeps a program to reading whatever its account may do: it cannot change anything and never copies a password, an operator's own token included. A switched-off account's tokens stop working with it, and work again when it is switched on.
Expiry and revocation
Revoke is in the list, one button per token, with a confirmation. It takes effect at once: the next request that presents that token is answered as though nobody were signed in.
Revoked and expired tokens stay in the list. That is deliberate — together with last used, the row is what tells you whether the thing was still running somewhere when you pulled it. A token that shows a last use from this morning and a program that has not complained is a program still to be found.
Last used is not written on every single request. It is refreshed at most every few minutes, because a program polling every few seconds would otherwise cost a database write per call to record something nobody reads that often. Read it as "in use around then", not as a request log.
What a token cannot do
Tokens are managed from the browser only. A token cannot create another token and cannot revoke one — those endpoints accept the session cookie and nothing else. For the same reason a token cannot create an account, change a password or e-mail address, or delete an account: an administrator account made with a leaked token would outlive the token's revocation. Without that, revoking a leaked token would achieve very little: whoever held it would already have minted a replacement with an expiry of their own choosing, and the owner's list would be the only place it ever appeared.
A token is also not a sign-in. It authorises API requests; it does not open the interface, and it does not skip two-factor authentication for anyone.
Guessing
The bearer path is rate-limited per client address, so a run of wrong values
from one place stops being answered. Only values the dashboard never issued
count: a token that is known but has expired is answered 401 with
token_expired, a revoked one with token_revoked, and neither is counted, so
several desktop apps behind one office address coming back after a holiday do not
lock each other out. A verification that succeeds clears the counter, which is why
a program polling on a short interval never runs into it.
If a program starts getting 401 answers in bursts, check that it is not sharing an address with something retrying a stale token.