Create a Relay enrollment token
const url = 'https://app.caprid.com/v1/organizations/4/enrollments';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"url":"https://relay1.internal.acme.example:4443/","region":"iad","gateway":true,"client_url":"https://live.acme.example/"}'};
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://app.caprid.com/v1/organizations/4/enrollments \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://relay1.internal.acme.example:4443/", "region": "iad", "gateway": true, "client_url": "https://live.acme.example/" }'Issues a one-time token that a relay you run exchanges for its Node key,
with POST /cluster/enroll. You decide everything about the Node
here: its URL, its Region, whether it can be a Gateway, and its Client
URL. The relay can’t change any of it later.
The token is shown once. It expires after expires_in seconds, or
when it’s used, whichever comes first.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The Organization’s id, from GET /v1/organizations.
Example
4Request Bodyrequired
Section titled “Request Bodyrequired”object
The URL peers will dial this relay on, and Clients too
unless client_url names another. It needs a publicly
trusted certificate for its host.
Which of your Regions the Node joins. Relays in the same
Region all peer with each other. Region names belong to
you, so your iad is unrelated to anyone else’s. Can’t
contain /.
Whether this Node may be elected its Region’s Gateway, which carries the Region’s traffic to other Regions.
The Client URL, which is where Clients, such as a player
page, reach this relay when that isn’t url. Use it when url
is a name only your private network resolves, and Clients
come in through a public hostname or a load balancer.
Switchboard doesn’t route anything with it. It reports the
value on the Node, for whatever hands relay addresses to
your Clients.
It has to start with http:// or https:// and can’t
contain a username or password. Switchboard trims it and
stores it as you send it. Leave it out, or send "", for
none. The relay can’t change it. If the relay’s
connect_api URL carries client=, that value has to
match.
Seconds until the token expires. 0 means the default. It always expires.
Example
{ "url": "https://relay1.internal.acme.example:4443/", "region": "iad", "gateway": true, "client_url": "https://live.acme.example/"}Responses
Section titled “Responses”The pending enrollment, with its token.
object
Identifies the enrollment for revoking it. Not the token.
The Organization’s oldest Namespace, kept from before
Organizations. The Node belongs to the whole Organization and
carries all of its Namespaces. null when the Organization has no
Namespaces.
The URL as you sent it.
The URL in the normalized form Switchboard uses to tell Nodes apart.
The Client URL the Node will have. Omitted when it has none.
The first 6 characters of the token after sbe_.
The Relay enrollment token. Shown only in this response.
Example
{ "token": "sbe_Vq3mK8nR5tWb2xYc7dLp0sHf4jGu9eAz1oQi6vTk3wM"}The request is malformed or a field is invalid. The message says which.
object
Example
{ "error": "the requested grants exceed the key's scope"}No valid credential. Missing, expired and revoked credentials all get the same response, and so does an API key whose trial has lapsed. An Agent token from before a claim gets a 401 too, once the claim has made the trial a person’s, with a message saying to get a new token.
object
Example
{ "error": "the requested grants exceed the key's scope"}Headers
Section titled “Headers”Example
Bearer realm="switchboard"Sent with an API key limited to some Namespaces, to a Namespace outside its limit, or to a route that acts on the Organization as a whole. A limited key can never create API keys.
object
Example
{ "error": "this API key is limited to the Namespaces acme-staging, and acme isn't one of them"}No such thing, or not yours. Another customer’s Organization or Namespace is a 404 too, so nobody can tell which ones exist.
object
Example
{ "error": "the requested grants exceed the key's scope"}A Node already exists at this URL. Delete it first.
object
Example
{ "error": "the requested grants exceed the key's scope"}