CreateEnrollmentToken
const url = 'https://example.com/hopbox.admin.v1.ServerService/CreateEnrollmentToken';const options = { method: 'POST', headers: { 'Connect-Protocol-Version': '1', 'Connect-Timeout-Ms': '1000', 'Content-Type': 'application/json' }, body: '{"pool":"example","roles":["example"],"serverId":"example","peerAddress":"example","ttl":"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://example.com/hopbox.admin.v1.ServerService/CreateEnrollmentToken \ --header 'Connect-Protocol-Version: 1' \ --header 'Connect-Timeout-Ms: 1000' \ --header 'Content-Type: application/json' \ --data '{ "pool": "example", "roles": [ "example" ], "serverId": "example", "peerAddress": "example", "ttl": "example" }'CreateEnrollmentToken makes a token with which one new server enrolls into a pool. The token works once and expires after its ttl, 1 hour by default. The response holds the only copy of the token: the install keeps only a hash of its secret. A retry with the same idempotency key makes no second token. It fails with ALREADY_EXISTS, because the install has no copy of the secret.
Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Define the version of the Connect protocol
Define the version of the Connect protocol
Example
1Define the timeout, in ms
Define the timeout, in ms
Example
1000Request Bodyrequired
Section titled “Request Bodyrequired”CreateEnrollmentTokenRequest names the pool of the token.
object
Pool is the name of the pool that the new server joins. Leave it empty for the pool default.
Roles are the roles that the new server can enroll with: node, dns, edge, or more than one. Leave it empty for the role node alone.
Server_id names an enrolled server, a UUID. The token then adds the roles to that server alone, in its pool, and enrolls no new server. Leave it empty for a token of a new server.
Peer_address is the peer address of the server that enrolls with the token: one public IPv4 address on its uplink, such as 203.0.113.5. The enrollment must come from it, and the new server keeps it. Leave it empty for a token without one.
Ttl is how long the token works, at most 24 hours. Leave it absent for 1 hour.
Example generated
{ "pool": "example", "roles": [ "example" ], "serverId": "example", "peerAddress": "example", "ttl": "example"}Responses
Section titled “Responses”Success
CreateEnrollmentTokenResponse holds the new token.
object
Token is the enrollment token, hbxe_
Token_id is the ID of the token, as the audit log names it.
Pool is the name of the pool of the token.
Expire_time is the end of the token.
Ca_hash is the SHA-256, in hex, of the certificate of the install CA. The token holds it too.
Roles are the roles that the new server can enroll with.
Server_id is the enrolled server that the token adds roles to, or empty.
Peer_address is the address from which the enrollment must come, or empty.
Example
{ "expireTime": "2023-01-15T01:30:15.01Z"}default
Section titled “default”Error
Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation
object
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
A list of messages that carry the error details. There is no limit on the number of messages.
Contains an arbitrary serialized message along with a @type that describes the type of the serialized message, with an additional debug field for ConnectRPC error details.
object
A URL that acts as a globally unique identifier for the type of the serialized message. For example: type.googleapis.com/google.rpc.ErrorInfo.
The Protobuf message, serialized as bytes and base64-encoded. The specific message type is identified by the type field.
Deserialized error detail payload. The ‘type’ field indicates the schema. This field is for easier debugging and should not be relied upon for application logic.
object
Example
{ "code": "canceled"}