Generate
Generate a new token.
osapi controller token generate [flags]
Examples
osapi controller token generate --subject user123 --roles=read
osapi controller token generate --subject svc@example.com --roles=read \
-p status:read -p health:read
osapi controller token generate --subject team-web --roles=operator \
-t group:web -t web-01
Result
The command prints:
$ osapi controller token generate --subject user123 --roles=read Token: Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMTIzIiwicm9sZXMiOlsicmVhZCJdfQ.Xq3a8Zt0n2Jv5k7XqW1yR4sB6cD9eF0gH2iJ3kL5mN8 Key ID: 2026-11 Subject: user123 Roles: read
With --json, the command prints:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMTIzIiwicm9sZXMiOlsicmVhZCJdfQ.Xq3a8Zt0n2Jv5k7XqW1yR4sB6cD9eF0gH2iJ3kL5mN8",
"kid": "2026-11",
"subject": "user123",
"roles": ["read"]
}
Flags
| Flag | Description | Default |
|---|---|---|
-p, --permissions | Direct permissions, which override the roles; osapi controller role get --name admin lists each one | |
-r, --roles | Roles for the token: built-in, or a custom role of the config (required) | |
-u, --subject | Subject for the token (e.g., user ID or unique identifier) (required) | |
-t, --targets | Hosts the token may act on: hostnames and labels, such as group:web; without it, each host |
Global flags
| Flag | Description | Default |
|---|---|---|
-d, --debug | Enable or disable debug mode | |
-j, --json | Enable JSON output | |
-f, --osapi-file | Path to config file; without one at the default path, osapi runs on the defaults | /etc/osapi/osapi.yaml |
Output tells how the result is printed, and what --json
gives.