const url = 'https://api.defined.net/v1/hosts/host-24NVITKMNU3CYCEDNFWKAOBX7I/enrollment-code';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"lifetimeSeconds":86400}'};
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://api.defined.net/v1/hosts/host-24NVITKMNU3CYCEDNFWKAOBX7I/enrollment-code \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "lifetimeSeconds": 86400 }'Obtain a code that can be used with the dnclient enroll command on a host, lighthouse, or relay to enroll it into your Managed Nebula network.
It is not possible to enroll a host that is blocked, it must first be unblocked using the unblock endpoint.
Token scope required: hosts:enroll
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
host-24NVITKMNU3CYCEDNFWKAOBX7IRequest Body
Section titled “Request Body”object
Lifetime of the enrollment code in seconds. Defaults to 86400 (24 hours).
Example
86400Responses
Section titled “Responses”Successful operation
object
object
Secret code to be used in dnclient enroll to allow the host/lighthouse/relay to join your Managed Nebula network.
The number of seconds the code is valid after being issued.
Example
{ "data": { "code": "H8NEbm99QvupjqW1PsdVR9DNSiFmoQtJXyGTQxerlSU", "lifetimeSeconds": 86400 }}Validation error
object
object
A static name for the error type
A short human readable description of the error
Describes the variable missing or malformed
The query parameter the error relates to, such as filter.targetType
Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.
object
The maximum number of resources allowed
The kind of resource the limit applies to
Examples
lifetimeSeconds is out of range.
{ "errors": [ { "code": "ERR_INVALID_VALUE", "message": "must be between 60 and 604800", "path": "lifetimeSeconds" } ]}The host is blocked.
{ "errors": [ { "code": "ERR_HOST_BLOCKED", "message": "cannot create enrollment code for blocked host - unblock the host to continue" } ]}The host was enrolled through an endpoint OIDC provider.
{ "errors": [ { "code": "ERR_NO_ENROLLMENT_CODE_FOR_ENDPOINT_HOST", "message": "cannot create enrollment code for an OIDC-enrolled host" } ]}The API key is missing, invalid or expired.
object
object
A static name for the error type
A short human readable description of the error
Describes the variable missing or malformed
The query parameter the error relates to, such as filter.targetType
Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.
object
The maximum number of resources allowed
The kind of resource the limit applies to
Example
{ "errors": [ { "code": "ERR_UNAUTHORIZED", "message": "unauthorized" } ]}The API key lacks a required scope.
object
object
A static name for the error type
A short human readable description of the error
Describes the variable missing or malformed
The query parameter the error relates to, such as filter.targetType
Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.
object
The maximum number of resources allowed
The kind of resource the limit applies to
Examples
The API key lacks a required scope.
{ "errors": [ { "code": "ERR_FORBIDDEN", "message": "api key must support the following scopes: hosts:read" } ]}Host not found
object
object
A static name for the error type
A short human readable description of the error
Describes the variable missing or malformed
The query parameter the error relates to, such as filter.targetType
Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.
object
The maximum number of resources allowed
The kind of resource the limit applies to
Example
{ "errors": [ { "code": "ERR_NOT_FOUND", "message": "resource not found" } ]}The organization has exceeded its API request rate limit. Retry the request after a short delay.
object
object
A static name for the error type
A short human readable description of the error
Describes the variable missing or malformed
The query parameter the error relates to, such as filter.targetType
Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.
object
The maximum number of resources allowed
The kind of resource the limit applies to
Example
{ "errors": [ { "code": "ERR_TOO_MANY_REQUESTS", "message": "too many requests" } ]}