# Server API: connection

Source: https://docs.neode.sk/development/api-reference/server-connection/
Last updated: 2026-12-03

> 2 operations. How devices connect: peer to peer first or always through the relay, and who may start a connection.

These routes are on the server API, port 21114 (21121 in Docker). They take an API key in `X-API-Key` or a sign-in token; see [The HTTP API](https://docs.neode.sk/development/api.md#signing-in).

How devices connect: peer to peer first or always through the relay, and who may start a connection.

## GET /api/connection/config

Show the connection policy.

On the server API, port 21114. Needs `server.config`.

**200**: The policy (`application/json`)

[ConnectionSettings](https://docs.neode.sk/development/api-reference/schemas.md#connectionsettings).

| Error | When |
|---|---|
| 401 | No credential, or one that is not valid |
| 403 | The credential's role lacks the permission |
| 503 | The connection configuration is not available |

## PUT /api/connection/config

Change the connection policy.

Saves the policy in the database and applies it at once, without a restart. The change is written in the audit log.

On the server API, port 21114. Needs `server.config`.

Request body, `application/json`:

Only these fields; any other field, a null boolean or a second JSON value is refused.

| Field | Type | Required | What it is |
|---|---|---|---|
| `mode` | string, one of `p2p_first`, `relay_only` | yes |  |
| `p2p_fallback_ms` | integer | yes | at least 0, at most 30000 |
| `same_nat_relay` | boolean |  | keeps its value when missing |
| `allow_shared_nat_initiator` | boolean |  | keeps its value when missing |
| `logged_in_only_initiator` | boolean |  | keeps its value when missing |
| `operator_only_outbound` | boolean |  | keeps its value when missing |

**200**: Saved and applied (`application/json`)

| Field | Type |
|---|---|
| `config` | [ConnectionSettings](https://docs.neode.sk/development/api-reference/schemas.md#connectionsettings) |

| Error | When |
|---|---|
| 400 | The body has an unknown field or a bad value, or mode or p2p_fallback_ms is missing |
| 401 | No credential, or one that is not valid |
| 403 | The credential's role lacks the permission |
| 503 | The connection configuration is not available |
