Exchange a Relay enrollment token for a Node key
const url = 'https://switchboard.mux.global/cluster/enroll';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"token":"sbe_Vq3m..."}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://switchboard.mux.global/cluster/enroll \ --header 'Content-Type: application/json' \ --data '{ "token": "sbe_Vq3m..." }'Spends a Relay enrollment token from
POST /v1/organizations/{id}/enrollments and returns the Node, its
Node key, and the values to put in the relay’s relay.toml. Run it
once per relay, by hand or from your provisioning script.
The token is the only credential, and it works once. A second exchange is a 401. Keep the Node key. A relay that loses it has to be enrolled again as a new Node.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
sbe_Vq3m...Responses
Section titled “Responses”Enrolled.
object
object
The oldest Namespace of the Organization that owns the Node. It names the owner. The relay still carries all of the Organization’s Namespaces.
The address Clients, such as a player page, use to reach this
relay, when it differs from url, the address its peers dial. On
a private network, url can be a name no Client can resolve, so
whatever hands relay addresses to your Clients should read this
field instead. It’s fixed at enrollment and omitted when the Node
has none. /cluster/connect never returns it, because that list
is only for peers to dial.
The Node key. It goes in three places: the jwt= of both
URLs below (already filled in), and the file that
[cluster] token points to.
The relay’s [cluster] settings.
object
The relay’s [auth] settings.
object
Example
{ "node": { "source": "poll" }, "node_key": "sbn_9KfQ...", "cluster": { "node": "https://relay1.acme.example:4443/", "connect_api": "https://switchboard.mux.global/cluster/connect?jwt=sbn_9KfQ..." }, "auth": { "url": "https://switchboard.mux.global/auth?jwt=sbn_9KfQ..." }}The request is malformed. The message says how.
object
Example generated
{ "error": "example"}The token is unknown, expired, or already used.
object
Example generated
{ "error": "example"}Another Node took this token’s URL after the token was issued. The token still works once that Node is deleted.
object
Example generated
{ "error": "example"}