Skip to content

Create join key

POST
/v1/join-keys
curl --request POST \
--url https://api.defined.net/v1/join-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "ci-runner", "networkID": "network-KAOWMXZHZWCVMGGFKM22XEGYLE", "roleID": "role-PZEDBXHCEXKAKJPZ6XOQTIAJA4", "tags": [ "env:ci" ], "autoAssignCIDRs": [ "100.100.0.0/22" ], "expiresAt": "2027-01-01T00:00:00Z" }'

Create a join key: a reusable enrollment code that any number of machines can enroll with, each joining as a new host with the key’s network, role, and tags. Enroll a machine by passing the returned token to dnclient enroll -code.

The token is only returned by this request, so store it somewhere safe.

Returns ERR_LIMIT_EXCEEDED if the organization has reached its join key limit.

Token scope required: join-keys:create

Media typeapplication/json
object
name
required

Identifies the key, and names hosts that enroll without reporting a usable hostname. Must be a DNS label: lowercase letters, digits, and hyphens, not starting or ending with a hyphen. Must be unique within the organization.

string
>= 1 characters <= 54 characters /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/
networkID
required

Network that hosts enrolled with this key join. Can’t be changed later.

string
roleID

Role assigned to hosts enrolled with this key. Can’t be changed later.

string | null
tags

Tags assigned to hosts enrolled with this key. Can’t be changed later.

Array<string> | null
autoAssignCIDRs

Prefixes from which hosts enrolled with this key are assigned addresses. Each must exactly match the network’s IPv4 CIDR or IPv6 prefix. On a network with an IPv6 prefix, that prefix is always included even if omitted here, so list the IPv4 CIDR to also give enrolled hosts an IPv4 address. Can’t be changed later.

Array<string> | null
<= 2 items
ephemeral

Makes every host enrolled with this key ephemeral: deleted automatically once it stops checking in, usually within 1-2 hours. Suited to short-lived machines like CI runners and containers. Blocked hosts are never deleted this way. Can’t be changed later.

boolean
expiresAt

When the key stops enrolling hosts. Must be in the future. Omit for a key that does not expire.

string | null format: date-time

Example

{
"name": "ci-runner",
"networkID": "network-KAOWMXZHZWCVMGGFKM22XEGYLE",
"roleID": "role-PZEDBXHCEXKAKJPZ6XOQTIAJA4",
"tags": [
"env:ci"
],
"autoAssignCIDRs": [
"100.100.0.0/22"
],
"expiresAt": "2027-01-01T00:00:00Z"
}

Successful operation

Media typeapplication/json
object
data
required
object
id
required
string
organizationID
required
string
name
required

Identifies the key. Hosts that enroll without reporting a usable hostname are named after it, followed by a random suffix.

string
networkID
required

Network that hosts enrolled with this key join.

string
roleID
required

Role assigned to hosts enrolled with this key.

string | null
tags
required

Tags assigned to hosts enrolled with this key.

Array<string>
autoAssignCIDRs
required

Prefixes from which hosts enrolled with this key are assigned addresses. Includes the network’s IPv6 prefix whenever the network has one.

Array<string> | null
ephemeral

Whether hosts enrolled with this key are ephemeral: deleted automatically once they stop checking in. Blocked hosts are never deleted this way.

boolean
expiresAt
required

When the key stops enrolling hosts. null means the key does not expire.

string | null format: date-time
createdAt
required
string format: date-time
modifiedAt
required
string format: date-time
token
required

The token machines enroll with. Only returned when the key is created.

string

Example

{
"data": {
"id": "dnjoin-P3RCTXN5LVFGBMJNYF2QHKWDOA",
"organizationID": "org-F63A24JGCLJV3ZEUTLCBISGETA",
"name": "ci-runner",
"networkID": "network-KAOWMXZHZWCVMGGFKM22XEGYLE",
"roleID": "role-PZEDBXHCEXKAKJPZ6XOQTIAJA4",
"tags": [
"env:ci"
],
"autoAssignCIDRs": [
"100.100.0.0/22",
"fdef:c0:c0:1::/80"
],
"expiresAt": "2027-01-01T00:00:00Z",
"createdAt": "2026-10-29T15:00:00Z",
"modifiedAt": "2026-10-29T15:00:00Z",
"token": "dnjoin-P3RCTXN5LVFGBMJNYF2QHKWDOA-6YQKZ3VNB2XGJ4MEPLRT7WCSAHDUF5IO3QXBKZNYV2MJ4RLEHGTA"
}
}

Validation error

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Examples

A join key already exists with the name.

{
"errors": [
{
"code": "ERR_DUPLICATE_VALUE",
"message": "value already exists",
"path": "name"
}
]
}

The API key is missing, invalid or expired.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Example

{
"errors": [
{
"code": "ERR_UNAUTHORIZED",
"message": "unauthorized"
}
]
}

The API key lacks a required scope.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Examples

ExamplemissingScope

The API key lacks a required scope.

{
"errors": [
{
"code": "ERR_FORBIDDEN",
"message": "api key must support the following scopes: hosts:read"
}
]
}

The organization has exceeded its API request rate limit. Retry the request after a short delay.

Media typeapplication/json
object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any

Example

{
"errors": [
{
"code": "ERR_TOO_MANY_REQUESTS",
"message": "too many requests"
}
]
}