Skip to main content

Create

Make a join token, and print it with the join string.

The token admits an agent at its join, until it expires or its uses are gone. The controller keeps a hash of it, not the token: this command prints the token one time.

By default the agent joins over NATS, and needs to reach NATS only. The join string has the address of NATS (controller.join.url, or else nats.server.url), the bootstrap user, which can only send the join request, and for a tls:// server the fingerprint of its certificate, which the agent pins. The controller gives the agent its own NATS user at the join.

With --transport https, the agent joins over the controller's API: the join string has controller.api.url and the fingerprint of the API's certificate. It needs controller.api.tls.enabled.

osapi controller join token create [flags]

Examples​

osapi controller join token create
osapi controller join token create --expires 24h --uses 10 --labels group=web
osapi controller join token create --transport https

Result​

The command prints:

$ osapi controller join token create
Join token:
  ID:           1a2b3c4d
  Token:        osapi_jt_1a2b3c4d.vC3m9...
  Join string:  tls://nats.example.com:4222?fp=SHA256%3A9f86d08...&ns=osapi&pass=...&token=osapi_jt_1a2b3c4d.vC3m9...&user=join
  Expires:      2026-11-25 13:00:00
  Uses:         1

With --json, the command prints:

{
"id": "1a2b3c4d",
"token": "osapi_jt_1a2b3c4d.vC3m9...",
"join": "tls://nats.example.com:4222?fp=SHA256%3A9f86d08...\u0026ns=osapi\u0026pass=...\u0026token=osapi_jt_1a2b3c4d.vC3m9...\u0026user=join",
"expires_at": "2026-11-25T13:00:00Z",
"uses": 1
}

Flags​

FlagDescriptionDefault
--expiresHow long the token admits agents, as a Go duration such as 1h1h
--labelsLabels that each agent that joins with the token gets, as key=value
--transportHow the agent joins: nats, over the NATS server, or https, over the controller's APInats
--usesHow many agents the token admits1

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath 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.