# Create a node join token

`POST /api/v1/workspaces/{workspaceId}/nodes/join-tokens`

A one-time token for 24 hours that a new private node joins the workspace with, and the address of the installer. The token is in this answer only. Workspace owner or admin.

Sign-in: a dashboard session, an API token with `nodes:write` or the `monitorly` CLI's sign-in with `nodes:write`.

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

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `workspaceId` | path | yes | string (uuid) | The workspace's id. |

## Request body

Required: yes.

`application/json`: JoinTokenInput

| Field | Type | Required | Description |
|---|---|---|---|
| `city` | string \| null | no | Only together with `countryCode`. |
| `countryCode` | string \| null | no | Optional: without it the node is located from its address once it connects. ISO 3166-1 alpha-2, upper case; given, it is the node's manual location. |
| `name` | string | yes |  |

Example:

```json
{
  "city": "Amsterdam",
  "countryCode": "NL",
  "name": "ams-1"
}
```

## Responses

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

### 201

The join token.

`application/json`: JoinToken

| Field | Type | Required | Description |
|---|---|---|---|
| `apiUrl` | string | yes | What the runner enrolls against (`--api`). |
| `expiresAt` | string | yes |  |
| `gatewayBaseUrl` | string | yes | The gateway's public HTTP origin; it serves the node installer at `/install.sh`. |
| `token` | string | yes | Shown once; the runner sends it to `POST /api/v1/nodes/enroll`. |

Example:

```json
{
  "apiUrl": "https://app.monitorly.cloud",
  "expiresAt": "2026-11-28T14:20:00Z",
  "gatewayBaseUrl": "https://gw.monitorly.cloud",
  "token": "JOIN_TOKEN"
}
```

### 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.

- `auth.unauthenticated`, `auth.session_expired`: no session, or it ended
- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `auth.forbidden`: your role is too low for this
- `token.scope_missing`: the token lacks the scope this needs; `detail` names it
- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `request.not_found`: it does not exist, or you cannot see it

### 409

Conflict.

- `quota.private_nodes_reached`: the workspace has as many private nodes as its plan allows

### 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_country`: the country code is not an ISO 3166-1 alpha-2 code

### 429

Too Many Requests.

- `token.rate_limited`: more than 10 requests a second with this token
- `session.rate_limited`: more than 5 changes a second from your sessions
- `token.create_limited`: more than 30 resources created within an hour from one token; `Retry-After` in seconds

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