API tokens
Make a token for CI or a script that can do only what you choose, on the places you choose, and rotate or revoke it safely.
An API token lets a script, a CI job or the CLI call the Wardn API as you without your password. Each token carries a ceiling: the permissions it may use, and the places it may use them on. This is least privilege for automation: a deploy job gets to sync one environment and nothing else, so a leaked token costs little.
A token acts for the person who made it and can never do more than that person can. If the owner's access shrinks, so does the token's; if the owner gains access later, the token does not. The token's own ceiling applies on top.
Open Settings › API Tokens. Only Owners and Admins manage tokens (token:manage); anyone else sees "Only owners and admins manage API tokens" and can ask one of them for a token or for the access to make their own.
Create a token
Choose New token. Under Details, give it a Name (up to 64 characters, named after what uses it, such as "GitHub Actions deploy") and a description (up to 280).
Under Access, add rows of permissions on places. A row is a list of permissions and a list of places; a token has up to 50 rows. A place can be the organization, an environment, a cluster or a deployment, and it includes everything inside it, including clusters added later. The dialog offers only the permissions you hold on the places you pick.
Under Details, set Expires to 30 days, 90 days, a year, or never. Under Limits, optionally set a Rate limit in requests per minute (1 to 100,000) to keep a leaked or runaway token from flooding Wardn.
Choose Create token. The secret is shown once: Copy your token now. It is stored only as a hash, begins with wrd_, and cannot be shown again; if you lose it, rotate it.
Use it as a bearer token:
export WARDN_API_URL=https://wardn.example.com
export WARDN_TOKEN=wrd_...
curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" "$WARDN_API_URL/api/v1/environments"
wardn whoami
wardn can-i deployment:sync --scope environment --on "$ENVIRONMENT_ID"wardn reads the same WARDN_API_URL and WARDN_TOKEN, so wardn can-i is a quick way to check what a token may do. Deploy from CI with an API token is the full setup.
What a token can hold
- Any permission you hold on the place, except those listed here. The ceiling is checked against your own access every time, so a row you could not give is refused with
403 token.beyond_you. - Not
token:manage. A token cannot make, list, rotate or revoke tokens, so a leaked token cannot make more of itself (token.by_token). - A terminal only if the row names
pod:exec. A token never gets one from deploying, and a wildcard such as*or*:readnever reaches it. See Terminal. - A token cannot be edited after it is created. To change what it can do, create a new token and revoke the old one.
Prop
Type
The web app makes the secret, so create tokens in the web app. The API lists and inspects them:
api() { curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' "$@"; }
api "$WARDN_API_URL/api/v1/api-tokens" # every token, newest first, revoked and expired too
api "$WARDN_API_URL/api/v1/api-tokens/$TOKEN_ID"
api "$WARDN_API_URL/api/v1/api-tokens/$TOKEN_ID/usage" # calls in the last 30 days
api "$WARDN_API_URL/api/v1/api-tokens/$TOKEN_ID/calls?outcome=denied"See what a token does
A token's page shows its Access, its Limits, Usage and Recent calls.
| Outcome | Meaning |
|---|---|
allowed | The call was allowed. |
denied | Outside what the token or its owner may do. |
limited | Over the token's rate limit. |
failed | Allowed, but did not succeed, such as a bad request. |
Usage counts the last 30 days: total, allowed, denied and limited, and when it was last used. Recent calls lists each call newest first, allowed or not, and you can filter to denied ones. A denied call is the quickest way to find out which permission a job is missing, and a run of them from an unfamiliar place is the sign of a leak.
Rotate and revoke
Rotate secret makes a new secret, shown once. The current one keeps working for 24 hours so you can move what uses it, then stops. Only the token's owner can rotate it, because the new secret acts as them. A revoked or expired token cannot be rotated.
Revoke token stops every secret of the token at once. It stays in the list as revoked, and it cannot be undone.
api -X POST "$WARDN_API_URL/api/v1/api-tokens/$TOKEN_ID/revoke"Creating, rotating and revoking are recorded in Activity, and every call a token makes is recorded against the token, as above. Revocation, expiry and the owner leaving the organization take effect within seconds.
Always true
The page lists these under Always applies:
- A token never does more than its owner can. If the owner gains access later, the token doesn't.
- Only owners and admins can create tokens, and a token can't make or change tokens.
- The secret is stored as a hash and shown once.
Permissions
| Action | Permission |
|---|---|
| Create, list, inspect, rotate, revoke, see usage and calls | token:manage (Owners, Admins) |