# Enroll a node

`POST /api/v1/nodes/enroll`

Called by the node software with a join token when a new node starts for the first time: stores the node's public keys and uses the token up. Needs no sign-in; the join token is the credential. The installer does this for you.

Sign-in: none.

Section: Nodes. Operation id in openapi.json: `enroll_node`.

## Request body

Required: yes.

`application/json`: EnrollInput

| Field | Type | Required | Description |
|---|---|---|---|
| `agentVersion` | string | yes |  |
| `sealPublicKey` | string | yes | X25519 public key for sealed secrets, 64 lowercase hex characters. |
| `signPublicKey` | string | yes | Ed25519 verifying key, 64 lowercase hex characters. |
| `token` | string | yes |  |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 201

The enrolled node.

`application/json`: Enrolled

| Field | Type | Required | Description |
|---|---|---|---|
| `gatewayUrl` | string | yes |  |
| `nodeId` | string (uuid) | yes |  |
| `scope` | NodeScope | yes |  |

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 404

Not Found.

- `node.join_token_not_found`: join token does not exist

### 409

Conflict.

- `node.key_in_use`: key already belongs to another node
- `quota.private_nodes_reached`: the workspace has as many private nodes as its plan allows

### 410

Gone.

- `node.join_token_expired`: join token is older than 24 hours
- `node.join_token_used`: join token was already used

### 413

Payload Too Large.

- `request.too_large`: the body is larger than 256 KiB

### 422

Unprocessable Entity.

- `field.required`, `field.too_long`, `field.invalid`: a field breaks a rule; `errors` points at it
- `node.invalid_public_key`: key is not 32 bytes in hex, or the keys are identical

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
