# Konsole: settings

Quelle: https://docs.neode.sk/de/development/api-reference/console-settings/
Zuletzt geändert: 2026-12-03

> 55 Operationen. Server settings: mail, sign-in, addresses, enrollment, sessions.

Diese Routen liegen auf der Konsole, Port 3375. Sie nehmen ein API-Token als `Authorization: Bearer ndt_...`; siehe [API-Tokens](https://docs.neode.sk/de/command-line/api-tokens.md). Die Beschreibungen stehen auf Englisch, wie in der OpenAPI-Beschreibung.

Server settings: mail, sign-in, addresses, enrollment, sessions.

## GET /api/panel/settings/sources

Show where each server setting's value comes from: saved, the environment or the built-in default.

Answers one entry per setting, keyed &lt;area>.&lt;field> with the field named as in that area's own route, like enrollment.mode or client_sessions.expiry_days. Settings whose source can't be read, because the server API does not answer, are left out.

Needs `server.config`. `neodesk settings sources` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes | The entries by setting key |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/advanced/files

List the advanced settings files.

Lists the files the editor offers on this install, with what the file system says of each. Files that only apply to Linux or to Docker are left out elsewhere.

Needs `server.config`. `neodesk settings files` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | array of object | yes |  |
| `data[].id` | string, one of `console-env`, `console-env-local`, `console-session-secret`, `go-blocklist`, `go-audit-log`, `systemd-console`, `systemd-server`, `build-env`, `docker-supervisord`, `docker-compose` |  |  |
| `data[].category` | string, one of `console`, `goserver`, `system` |  |  |
| `data[].path` | string |  |  |
| `data[].exists` | boolean |  |  |
| `data[].readable` | boolean |  |  |
| `data[].writable` | boolean |  |  |
| `data[].canCreate` | boolean |  | Whether saving creates the file when it is missing |
| `data[].size_bytes` | integer |  |  |
| `data[].mtime` | string or null (date-time) |  |  |
| `data[].requiresRestart` | string, one of `console`, `goserver`, `systemd`, `none` |  | What has to restart after a change |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/advanced/files/{id}

Show an advanced settings file.

Files that hold the server's secrets (the env files and the session secret) open for a super admin only; a refusal goes into the audit log.

Needs `server.config`. `neodesk settings file` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string, one of `console-env`, `console-env-local`, `console-session-secret`, `go-blocklist`, `go-audit-log`, `systemd-console`, `systemd-server`, `build-env`, `docker-supervisord`, `docker-compose` | yes | The file's id, as GET /api/settings/advanced/files lists it |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.id` | string | yes |  |
| `data.path` | string | yes |  |
| `data.size_bytes` | integer |  |  |
| `data.mtime` | string (date-time) |  |  |
| `data.requiresRestart` | string, one of `console`, `goserver`, `systemd`, `none` |  | What has to restart after a change |
| `data.content` | string | yes |  |

| Error | When |
|---|---|
| 400 | Not a regular file, too large or not text |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account may not do this, or the file holds the server's secrets and the account is not a super admin |
| 404 | No such file id, or the file does not exist |

## PUT /api/settings/advanced/files/{id}

Replace an advanced settings file (may need a restart).

Backs up the file and replaces it, and logs it in the audit log. Files that hold the server's secrets save for a super admin only. A file the server or the console reads at its start goes into your restart transaction (restartRequired) and is written only once the transaction takes it; POST /api/settings/advanced/restart applies it.

Needs `server.config`. `neodesk settings file-set` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string, one of `console-env`, `console-env-local`, `console-session-secret`, `go-blocklist`, `go-audit-log`, `systemd-console`, `systemd-server`, `build-env`, `docker-supervisord`, `docker-compose` | yes | The file's id, as GET /api/settings/advanced/files lists it |

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `content` | string | yes | The whole new content, at most 512 kB of text |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.id` | string |  |  |
| `data.path` | string |  |  |
| `data.size_bytes` | integer |  |  |
| `data.mtime` | string (date-time) |  |  |
| `data.backupPath` | string or null |  | The backup of the old file, null when the file was created |
| `data.requiresRestart` | string, one of `console`, `goserver`, `systemd`, `none` |  | What has to restart after a change |
| `data.created` | boolean |  |  |
| `data.restartRequired` | [RestartTransaction](https://docs.neode.sk/de/development/api-reference/schemas.md#restarttransaction) or null |  |  |
| `message` | string | yes |  |
| `restartRequired` | [RestartTransaction](https://docs.neode.sk/de/development/api-reference/schemas.md#restarttransaction) or null | yes | Your restart transaction, null when the file needs no restart |

| Error | When |
|---|---|
| 400 | The content is not text, too large, not valid for the file, sets a weak secret or a key only the host may set, or the file is read only |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account may not do this, or the file holds the server's secrets and the account is not a super admin |
| 404 | No such file id, or the file does not exist and can't be created |
| 409 | Another account's change waits for a restart (restart_transaction_owned) |

## GET /api/settings/availability-history

Show whether online history is kept and for how long.

The server API keeps both values; days default to 30.

Needs `server.config`. `neodesk settings availability-history` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.enabled` | boolean | yes |  |
| `data.retention_days` | integer | yes | Days the history is kept |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/availability-history

Set whether online history is kept and for how long.

Every call sets both values: without enabled the history is switched off, and without retention_days it is kept 30 days. When the server API refuses a value, the one it took is put back. Logs the change in the audit log.

Needs `server.config`. `neodesk settings availability-history-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `retention_days` | integer | Days to keep the history; default `30`, at least 1, at most 3650 |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.enabled` | boolean | yes |  |
| `data.retention_days` | integer | yes | Days the history is kept |

| Error | When |
|---|---|
| 400 | retention_days is not a whole number from 1 to 3650 |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 502 | The server API refused the change |

## GET /api/settings/client-sessions

Show how long desktop client sign-ins last.

The server API keeps the values. Defaults: 7 days, renewed, at most 30 days.

Needs `server.config`. `neodesk settings client-sessions` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.expiry_days` | integer | yes | Days a desktop client sign-in lasts; at least 1, at most 365 |
| `data.sliding` | boolean | yes | Whether each use renews the sign-in |
| `data.max_days` | integer | yes | Days a renewed sign-in lasts at most; at least 1, at most 365 |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/client-sessions

Set how long desktop client sign-ins last.

Needs at least one of the fields, and sets all three: a field left out takes its default (7 days, renewed, 30 days at most). With renewal on, max_days can't be below expiry_days. The expiry also goes into the console's .env when it exists and applies to the next client sign-in. When the server API refuses a value, the ones it took are put back. Logs the change in the audit log.

Needs `server.config`. `neodesk settings client-sessions-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `expiry_days` | integer | Days a desktop client sign-in lasts; at least 1, at most 365 |
| `sliding` | boolean | Whether each use renews the sign-in |
| `max_days` | integer | Days a renewed sign-in lasts at most; at least 1, at most 365 |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No field, days out of range, or max_days below expiry_days |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API refused a value |

## GET /api/settings/connection-mode

Show how clients connect: peer to peer or through the relay.

Answers the saved settings, where they live (source) and whether the console can change them there (writable), how the server runs (deployment), and what the running server reports (runtime, null when it does not answer).

Needs `server.config`. `neodesk settings connection-mode` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.mode` | string, one of `p2p_first`, `relay_only` | yes | p2p_first tries a direct connection first, relay_only always uses the relay |
| `data.p2p_fallback_ms` | integer | yes | Milliseconds to try a direct connection before the relay |
| `data.same_nat_relay` | boolean |  | Use the relay when both sides are behind the same NAT |
| `data.allow_shared_nat_initiator` | boolean |  |  |
| `data.logged_in_only_initiator` | boolean |  | Only signed-in clients may start a connection |
| `data.operator_only_outbound` | boolean |  |  |
| `data.source` | string, one of `go-api`, `systemd`, `docker`, `defaults` | yes |  |
| `data.writable` | boolean | yes |  |
| `data.deployment` | string | yes | How the server runs, like systemd or docker |
| `data.runtime` | object or null | yes | The connection settings the running server reports, null when it does not answer |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/connection-mode

Set how clients connect (may need a restart).

In a container, or without a systemd unit or compose file, the server API takes the settings at once. Otherwise the change goes into your restart transaction (restartRequired in the answer) and the unit or compose file is written; POST /api/settings/connection-mode/restart applies it. Logs the change in the audit log.

Needs `server.config`. `neodesk settings connection-mode-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `mode` | string, one of `p2p_first`, `relay_only` | p2p_first tries a direct connection first, relay_only always uses the relay |
| `p2p_fallback_ms` | integer | Default 2000; at least 0, at most 30000 |
| `same_nat_relay` | boolean |  |
| `allow_shared_nat_initiator` | boolean |  |
| `logged_in_only_initiator` | boolean |  |
| `operator_only_outbound` | boolean |  |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.source` | string, one of `go-api`, `systemd`, `docker` | yes |  |
| `data.settings` | object | yes |  |
| `data.settings.mode` | string, one of `p2p_first`, `relay_only` |  | p2p_first tries a direct connection first, relay_only always uses the relay |
| `data.settings.p2p_fallback_ms` | integer |  | Milliseconds to try a direct connection before the relay |
| `data.settings.same_nat_relay` | boolean |  | Use the relay when both sides are behind the same NAT |
| `data.settings.allow_shared_nat_initiator` | boolean |  |  |
| `data.settings.logged_in_only_initiator` | boolean |  | Only signed-in clients may start a connection |
| `data.settings.operator_only_outbound` | boolean |  |  |
| `data.path` | string |  | The file written, for systemd and docker |
| `data.vars` | object |  | The variables written to it |
| `data.method` | string |  | For systemd: privileged_dropin or unit_direct |
| `data.restartRequired` | [RestartTransaction](https://docs.neode.sk/de/development/api-reference/schemas.md#restarttransaction) or null |  | Your restart transaction, null when the server took the settings at once |
| `data.dockerMode` | boolean |  |  |
| `message` | string | yes |  |

| Error | When |
|---|---|
| 400 | p2p_fallback_ms is not a whole number from 0 to 30000, the settings can't be changed here, or the compose file has no server service |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | Another account's change waits for a restart (restart_transaction_owned) |

## POST /api/settings/connection-mode/restart

Restart to apply a new connection mode.

Confirms your pending restart transaction, whatever it holds, as POST /api/settings/restart/confirm does, and logs it in the audit log. Takes no body.

Needs `server.config`. `neodesk settings connection-mode-restart` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [RestartTransaction](https://docs.neode.sk/de/development/api-reference/schemas.md#restarttransaction) | yes |
| `message` | string | yes |

| Error | When |
|---|---|
| 400 | You have no pending transaction |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | The transaction is not pending or failed |

## GET /api/settings/console-allow-from

Show the networks that may sign in to the console.

allow_from is the list in force, empty for every network; source says what decides it: setting (Settings, Sign-in), env (CONSOLE_ALLOW_FROM in the server's environment, env_value) or none. saved is the list saved in the settings, your_address the address the server sees you at.

Needs `server.config`. `neodesk settings console-allow-from` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.allow_from` | array of string | yes | The addresses and ranges in force: CONSOLE_ALLOW_FROM's when it is set, else the saved ones; empty lets every network sign in |
| `data.source` | string, one of `setting`, `env`, `none` | yes | What decides the list |
| `data.env_value` | string or null | yes | CONSOLE_ALLOW_FROM as set, null when it is not |
| `data.env_error` | string |  | Only when set: why CONSOLE_ALLOW_FROM can't be read, so only this machine may sign in |
| `data.saved` | array of string | yes | The list saved in the settings, which counts once CONSOLE_ALLOW_FROM is gone |
| `data.your_address` | string | yes | The address the console sees this request come from |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## PUT /api/settings/console-allow-from

Set the networks that may sign in to the console.

It applies at once: console sessions from outside the new list end at their next request. API tokens are not affected. The audit entry has the old and the new list.

Needs `server.config`. `neodesk settings console-allow-from-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `allow_from` | string or array of string or null | yes | IPv4 and IPv6 addresses and CIDR ranges, as text separated by commas or new lines or as a list, at most 1000; empty or null lets every network sign in |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No allow_from in the body; allow_from is not text or a list of texts, an entry is not an address or range, or there are more than 1000 (code invalid_entry); or the list leaves out the address of this request (code would_lock_out) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | CONSOLE_ALLOW_FROM in the server's environment sets the list (code set_in_environment) |
| 500 | Something failed on the server |

## GET /api/settings/console-sessions

Show whether an account may be signed in on several browsers at once.

single_session is the switch One session per account; source says what decides the limit: the switch, the default, or SESSION_MAX_PER_USER (env_value) in the server's environment.

Needs `server.config`. `neodesk settings console-sessions` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.single_session` | boolean | yes | Whether One session per account is on |
| `data.limit` | integer | yes | How many browser sessions an account may have at once |
| `data.source` | string, one of `env`, `setting`, `default` | yes | What decides the limit: env when SESSION_MAX_PER_USER is set, which then decides over the switch |
| `data.env_value` | string or null | yes | SESSION_MAX_PER_USER as set, null when it is not |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/console-sessions

Turn One session per account on or off.

true gives every account one session, so a new sign-in ends the account's other one. It applies from the next sign-in; sessions open now stay. Logs the change in the audit log.

Needs `server.config`. `neodesk settings console-sessions-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `single_session` | boolean | yes | Anything but true turns it off |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No single_session in the body |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/device-scope

Show whether new accounts see every device or only those given to them.

restricted hides devices nobody was given from accounts that are not administrators; open shows them. Without a saved value, DEVICE_SCOPE_DEFAULT decides.

Needs `server.config`. `neodesk settings device-scope` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.mode` | string, one of `open`, `restricted` | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/device-scope

Set whether new accounts see every device.

Logs the change in the audit log.

Needs `server.config`. `neodesk settings device-scope-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `mode` | string, one of `open`, `restricted` | yes | In any letter case; empty means open |

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.mode` | string, one of `open`, `restricted` | yes |

| Error | When |
|---|---|
| 400 | No mode, or one that is not open or restricted |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/email/identity

Show the sender name and the footer details of the console's mails.

Not wrapped in success and data.

Needs `server.config`. `neodesk settings mail-identity` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `identity` | object | yes |  |
| `identity.from_name` | string |  | The From name; empty is NeoDesk, or "&lt;name> via NeoDesk" for a renamed server |
| `identity.organisation` | string |  | Who runs the server, like Acme IT |
| `identity.support_email` | string |  | Where people get help; replies go there too |
| `identity.support_url` | string |  |  |
| `default_from_name` | string | yes | The From name used while from_name is empty |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/email/identity

Set the sender name and who runs this server, for the mails' footer.

Logs the change in the audit log. Not wrapped in success and data.

Needs `server.config`. `neodesk settings mail-identity-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `from_name` | string | The From name; empty is NeoDesk, or "&lt;name> via NeoDesk" for a renamed server |
| `organisation` | string | Who runs the server, like Acme IT |
| `support_email` | string | Where people get help; replies go there too |
| `support_url` | string |  |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `identity` | object | yes |  |
| `identity.from_name` | string |  | The From name; empty is NeoDesk, or "&lt;name> via NeoDesk" for a renamed server |
| `identity.organisation` | string |  | Who runs the server, like Acme IT |
| `identity.support_email` | string |  | Where people get help; replies go there too |
| `identity.support_url` | string |  |  |
| `default_from_name` | string | yes | The From name used while from_name is empty |

| Error | When |
|---|---|
| 400 | The body is not valid (code invalid_body), or a field is too long or not a valid address or URL |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/email/previews

List the mails the console sends, for previews.

The mails' titles are in the request's language. Not wrapped in success and data.

Needs `server.config`. `neodesk settings mails` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `kinds` | array of object | yes |  |
| `kinds[].kind` | string, one of `invite`, `support`, `account-invite`, `reset`, `reset-self`, `email-confirm`, `email-notice`, `expiry`, `inactive`, `scheduled-report`, `security-signin`, `security-password`, `security-two-factor`, `security-email`, `security-alert-new-device`, `security-alert-join-request`, `security-alert-failed-signin`, `impersonation`, `chat`, `alert`, `help`, `test` | yes |  |
| `kinds[].title` | string | yes |  |
| `languages` | array of object | yes |  |
| `languages[].code` | string | yes |  |
| `languages[].name` | string | yes | The name in the language itself |
| `default_language` | string | yes | The request's language |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/email/previews/{kind}/send

Send one of the console's mails to your own address, with made-up facts.

Builds the mail with sample facts and the branding of now, sends it to the address of your own account and logs it in the audit log.

Needs `server.config`. `neodesk settings mail-send-me` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `kind` | path | string, one of `invite`, `support`, `account-invite`, `reset`, `reset-self`, `email-confirm`, `email-notice`, `expiry`, `inactive`, `security-signin`, `security-password`, `security-two-factor`, `security-email`, `impersonation`, `chat`, `alert`, `help`, `test` | yes | The mail, as GET /api/settings/email/previews lists it |

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `lang` | string | The language of the mail; the request's language when the console doesn't have it |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `to` | string | yes | The address the mail went to |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | No such mail (code not_found) |
| 409 | Your account has no address (code no_address), or no mail server is set (code smtp_not_configured) |
| 502 | The mail server did not take the mail (code mail_failed) |

## GET /api/settings/email/smtp

Show the mail server settings (the password is masked).

Answers configured false and nothing else while no mail server is set. The password is never in the answer. Not wrapped in success and data.

Needs `server.config`. `neodesk settings smtp` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `configured` | boolean | false while no mail server is set |
| `host` | string |  |
| `port` | integer | Default 587 |
| `secure` | boolean | TLS from the start |
| `user` | string |  |
| `pass` | string | ******** in place of a saved password |
| `from` | string | The sender, an address alone or with a name |
| `alert_email` | string | Addresses for alert mails, separated by commas |
| `tlsVerify` | boolean | Whether the server's certificate is checked |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/email/smtp

Set the mail server the console sends mail with.

A member left out keeps its saved value; host and from are required when none is saved. A missing or masked (********) password keeps the saved one, but only while host, port and user stay and the certificate check stays on; else the password must be given. Logs the change in the audit log.

Needs `server.config`. `neodesk settings smtp-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `host` | string | yes |  |
| `port` | integer |  | Default 587; default `587`, at least 1, at most 65535 |
| `secure` | boolean |  | default `false` |
| `user` | string |  |  |
| `pass` | string |  | Empty or ******** keeps the saved password where allowed |
| `from` | string | yes | One address, alone or with a name, at most 998 characters |
| `alert_email` | string |  | Plain addresses separated by commas |
| `tlsVerify` | boolean |  |  |

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |

| Error | When |
|---|---|
| 400 | A field is missing or not valid |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The settings could not be saved |

## POST /api/settings/email/smtp/test

Test the saved mail server settings: connect and sign in.

Connects to the mail server with the saved settings and signs in, without sending a mail. A failed test answers 200 with success false. Takes no body.

Needs `server.config`. `neodesk settings smtp-test` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | boolean | yes |  |
| `error` | string or null | yes | Why the test failed, null when it worked |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/email/unsubscribed

List the addresses that turned a notification mail off.

Not wrapped in success and data.

Needs `server.config`. `neodesk settings mail-unsubscribed` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `unsubscribed` | object | yes | The addresses per kind of notification mail |
| `unsubscribed.chat` | array of string |  |  |
| `unsubscribed.alert` | array of string |  |  |
| `unsubscribed.help` | array of string |  |  |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/email/unsubscribed/resubscribe

Send a kind of notification mail to an address again.

The address gets that kind of mail again. Logs the change in the audit log. Answers the new list, not wrapped in success and data.

Needs `server.config`. `neodesk settings mail-resubscribe` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `kind` | string, one of `chat`, `alert`, `help` | yes | chat: someone waits in the chat; alert: an alert rule fired; help: a device asked for help |
| `address` | string | yes |  |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `unsubscribed` | object | yes | The addresses per kind of notification mail |
| `unsubscribed.chat` | array of string |  |  |
| `unsubscribed.alert` | array of string |  |  |
| `unsubscribed.help` | array of string |  |  |

| Error | When |
|---|---|
| 400 | No address (code invalid_body), or an unknown kind (code invalid_kind) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/enrollment

Show how new devices join: open, managed or locked.

The mode comes from the server API.

Needs `server.config`. `neodesk settings enrollment` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.mode` | string, one of `open`, `managed`, `locked` | yes | open lets every device join, managed holds new devices for approval, locked lets none join |
| `data.require_approval` | boolean | yes | True when the mode is managed |
| `data.rich_approve` | boolean | yes | Whether the approval dialog shows the device's details |
| `data.tag_picker` | boolean | yes | Whether the approval dialog offers tags |
| `data.pending_count` | integer | yes | Devices that wait for approval |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/enrollment

Set how new devices join.

Every field is optional. require_approval true sets managed; false sets open unless another mode than managed is given. Logs the change in the audit log.

Needs `server.config and enrollment.manage`. `neodesk settings enrollment-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `mode` | string, one of `open`, `managed`, `locked` | open lets every device join, managed holds new devices for approval, locked lets none join |
| `require_approval` | boolean |  |
| `rich_approve` | boolean |  |
| `tag_picker` | boolean |  |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.mode` | string, one of `open`, `managed`, `locked` | yes | open lets every device join, managed holds new devices for approval, locked lets none join |
| `data.require_approval` | boolean | yes | True when the mode is managed |
| `data.rich_approve` | boolean | yes | Whether the approval dialog shows the device's details |
| `data.tag_picker` | boolean | yes | Whether the approval dialog offers tags |

| Error | When |
|---|---|
| 400 | The mode is not open, managed or locked |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API refused the mode |

## GET /api/settings/impersonation

Show whether people get a mail when an admin views NeoDesk as them.

notice_mail is the switch in Settings, Sign-in. It is on unless it was turned off.

Needs `server.config`. `neodesk settings impersonation` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.notice_mail` | boolean | yes | Whether a person gets a mail when an admin views NeoDesk as them |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/impersonation

Turn the mail about Sign in as on or off.

Logs the change in the audit log.

Needs `server.config`. `neodesk settings impersonation-set` calls it.

Request body, `application/json`:

| Field | Type | Required |
|---|---|---|
| `notice_mail` | boolean | yes |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.notice_mail` | boolean | yes | Whether a person gets a mail when an admin views NeoDesk as them |

| Error | When |
|---|---|
| 400 | notice_mail is not true or false (code invalid_value) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/inactive-accounts

Show the rule that disables accounts that don't sign in.

Accounts that haven't signed in for days are disabled, after a notice mail notice_days before. 0 means the rule is off, which it is until an admin turns it on.

Needs `server.config`. `neodesk settings inactive-accounts` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.days` | integer | yes | The days without sign-in, 0 when off |
| `data.notice_days` | integer | yes | Days before that the person gets a notice (7) |
| `data.min_days` | integer | yes | The fewest days allowed (14) |
| `data.max_days` | integer | yes | The most days allowed (3650) |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/inactive-accounts

Disable accounts that haven't signed in for a number of days, or turn that off with 0.

The server API keeps the value. Logs the change in the audit log.

Needs `server.config`. `neodesk settings inactive-accounts-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `days` | integer | yes | 0 turns the rule off, else 14 to 3650 days; at least 0, at most 3650 |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No days, or not 0 or a whole number from 14 to 3650 |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API refused the value |

## GET /api/settings/ldap

Show the LDAP sign-in settings.

The server API keeps the settings and masks the bind password. Not wrapped in success and data.

Needs `server.config`. `neodesk settings ldap` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `host` | string | Like ldap.example.com |
| `port` | integer | 389, or 636 with use_tls; 0 or left out takes those; at least 0, at most 65535 |
| `use_tls` | boolean | LDAPS |
| `start_tls` | boolean | STARTTLS on the plain port |
| `skip_tls_verify` | boolean |  |
| `bind_dn` | string | The service account that searches |
| `bind_password` | string | Masked as eight bullets in answers |
| `base_dn` | string | Like dc=example,dc=com |
| `user_filter` | string | Like (sAMAccountName={{username}}) |
| `user_attr_id` | string |  |
| `user_attr_email` | string |  |
| `user_attr_name` | string |  |
| `group_base_dn` | string | Empty searches base_dn |
| `group_filter` | string |  |
| `group_attr_name` | string |  |
| `default_role` | string | The role of a person no group maps |
| `group_role_map` | string | JSON mapping group DNs to roles |
| `direct_bind` | boolean | Bind with direct_bind_dn instead of searching |
| `direct_bind_dn` | string | Like uid={{username}},ou=users,dc=example,dc=com |
| `conn_timeout_seconds` | integer | Default 10; at least 0, at most 120 |
| `allow_signup` | boolean | A person the directory accepts gets an account |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API did not answer |

## PUT /api/settings/ldap

Set the LDAP sign-in settings (give them as --data JSON).

Passes the settings on to the server API, which changes only the settings the body names: a setting left out keeps its stored value. A missing or masked bind password keeps the stored one; an empty one clears it. Switched on, the settings must be usable for a sign-in. Logs the change in the audit log.

Needs `server.config`. `neodesk settings ldap-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `host` | string | Like ldap.example.com |
| `port` | integer | 389, or 636 with use_tls; 0 or left out takes those; at least 0, at most 65535 |
| `use_tls` | boolean | LDAPS |
| `start_tls` | boolean | STARTTLS on the plain port |
| `skip_tls_verify` | boolean |  |
| `bind_dn` | string | The service account that searches |
| `bind_password` | string | Masked as eight bullets in answers |
| `base_dn` | string | Like dc=example,dc=com |
| `user_filter` | string | Like (sAMAccountName={{username}}) |
| `user_attr_id` | string |  |
| `user_attr_email` | string |  |
| `user_attr_name` | string |  |
| `group_base_dn` | string | Empty searches base_dn |
| `group_filter` | string |  |
| `group_attr_name` | string |  |
| `default_role` | string | The role of a person no group maps |
| `group_role_map` | string | JSON mapping group DNs to roles |
| `direct_bind` | boolean | Bind with direct_bind_dn instead of searching |
| `direct_bind_dn` | string | Like uid={{username}},ou=users,dc=example,dc=com |
| `conn_timeout_seconds` | integer | Default 10; at least 0, at most 120 |
| `allow_signup` | boolean | A person the directory accepts gets an account |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No setting, or settings the server API refuses, with the field |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/ldap/test

Test the LDAP settings.

The server API connects and binds with the settings of the body; a masked or empty password stands for the stored one. A failed test answers 200 with success false.

Needs `server.config`. `neodesk settings ldap-test` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `host` | string | Like ldap.example.com |
| `port` | integer | 389, or 636 with use_tls; 0 or left out takes those; at least 0, at most 65535 |
| `use_tls` | boolean | LDAPS |
| `start_tls` | boolean | STARTTLS on the plain port |
| `skip_tls_verify` | boolean |  |
| `bind_dn` | string | The service account that searches |
| `bind_password` | string | Masked as eight bullets in answers |
| `base_dn` | string | Like dc=example,dc=com |
| `user_filter` | string | Like (sAMAccountName={{username}}) |
| `user_attr_id` | string |  |
| `user_attr_email` | string |  |
| `user_attr_name` | string |  |
| `group_base_dn` | string | Empty searches base_dn |
| `group_filter` | string |  |
| `group_attr_name` | string |  |
| `default_role` | string | The role of a person no group maps |
| `group_role_map` | string | JSON mapping group DNs to roles |
| `direct_bind` | boolean | Bind with direct_bind_dn instead of searching |
| `direct_bind_dn` | string | Like uid={{username}},ou=users,dc=example,dc=com |
| `conn_timeout_seconds` | integer | Default 10; at least 0, at most 120 |
| `allow_signup` | boolean | A person the directory accepts gets an account |

**200**: Done (`application/json`)

Object or object.

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/management/capabilities

Show what this install lets the console change.

Needs `server.config`. `neodesk settings capabilities` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [ManagementCapabilities](https://docs.neode.sk/de/development/api-reference/schemas.md#managementcapabilities) | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/management/config

Show the server settings the console may change.

Answers the keys the console may set, the values the env file has for them (secrets masked) and the env file's path.

Needs `server.config`. `neodesk settings server-config` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.keys` | array of string | yes | The keys the console may set |
| `data.values` | object | yes | The values the env file sets, by key, secrets masked |
| `data.envPath` | string | yes |  |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The env file could not be read |

## PUT /api/settings/management/config

Change server settings from the allowed list (some need a restart).

Checks the keys against the allowed list and writes them to the env file with a backup. The change goes into your restart transaction (pendingRestart): confirm it with POST /api/settings/restart/confirm. With dryRun the changes are only checked and answered, secrets masked. Logs the change in the audit log.

Needs `server.config`. `neodesk settings server-config-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `changes` | object | yes | The new values by key, as text, numbers or true and false |
| `dryRun` | boolean |  | Only check the changes |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object or object | yes |  |
| `message` | string |  | Only without dryRun |

| Error | When |
|---|---|
| 400 | A key that is not allowed, or a value the key does not take |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | The env file can't be written (code CONFIG_CAPABILITY_BLOCKED), or another account's change waits for a restart (restart_transaction_owned) |

## GET /api/settings/metrics

Show the Prometheus metrics settings the server started with and where /metrics answers.

The metrics settings are environment variables the server reads at its start, so they can't be changed here. METRICS_TOKEN shows only whether it is set.

Needs `server.config`. `neodesk settings metrics` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.available` | boolean | yes | false when the console runs without the server in its process |
| `data.enabled` | boolean | yes |  |
| `data.settings` | array of object | yes |  |
| `data.settings[].key` | string | yes |  |
| `data.settings[].env_var` | string | yes |  |
| `data.settings[].value` |  | yes |  |
| `data.settings[].default` |  | yes |  |
| `data.settings[].value_source` | string, one of `environment`, `default` | yes |  |
| `data.endpoints` | array of object | yes | Where /metrics answers; empty while metrics are off |
| `data.endpoints[].target` | string, one of `server`, `console` | yes |  |
| `data.endpoints[].port` | integer |  |  |
| `data.endpoints[].address` | string |  | A separate listener of the server |
| `data.endpoints[].https` | boolean |  |  |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/oidc

Show the single sign-on (OIDC) settings.

The server API keeps the settings and masks the client secret. Not wrapped in success and data.

Needs `server.config`. `neodesk settings oidc` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `prefer_sso` | boolean | Start single sign-on at once on the sign-in page |
| `display_name` | string | The button label, like Google |
| `issuer_url` | string |  |
| `client_id` | string |  |
| `client_secret` | string | Masked in answers |
| `redirect_url` | string | The callback address the provider sends people back to; required when enabled |
| `panel_url` | string |  |
| `scopes` | string | Separated by spaces; default openid profile email |
| `use_pkce` | boolean |  |
| `auto_discovery` | boolean | Read the endpoints from .well-known/openid-configuration |
| `authorization_url` | string |  |
| `token_url` | string |  |
| `userinfo_url` | string |  |
| `claim_username` | string |  |
| `claim_email` | string |  |
| `claim_name` | string |  |
| `claim_groups` | string |  |
| `default_role` | string |  |
| `group_role_map` | string | GroupName=role pairs separated by \| |
| `allow_signup` | boolean |  |
| `allowed_private_cidrs` | string | Private networks the provider may be in |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API did not answer |

## PUT /api/settings/oidc

Set the single sign-on (OIDC) settings (give them as --data JSON).

Passes the settings on to the server API, which changes only the settings the body names: a setting left out keeps its stored value. A missing or masked client_secret keeps the stored one; an empty one clears it. Switched on, it needs a redirect_url with the path of the callback, and settings a sign-in can use. Logs the change in the audit log.

Needs `server.config`. `neodesk settings oidc-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean |  |
| `prefer_sso` | boolean | Start single sign-on at once on the sign-in page |
| `display_name` | string | The button label, like Google |
| `issuer_url` | string |  |
| `client_id` | string |  |
| `client_secret` | string | Masked in answers |
| `redirect_url` | string | The callback address the provider sends people back to; required when enabled |
| `panel_url` | string |  |
| `scopes` | string | Separated by spaces; default openid profile email |
| `use_pkce` | boolean |  |
| `auto_discovery` | boolean | Read the endpoints from .well-known/openid-configuration |
| `authorization_url` | string |  |
| `token_url` | string |  |
| `userinfo_url` | string |  |
| `claim_username` | string |  |
| `claim_email` | string |  |
| `claim_name` | string |  |
| `claim_groups` | string |  |
| `default_role` | string |  |
| `group_role_map` | string | GroupName=role pairs separated by \| |
| `allow_signup` | boolean |  |
| `allowed_private_cidrs` | string | Private networks the provider may be in |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No setting, a redirect URL that is not valid, or settings the server API refuses |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/settings/oidc/test

Test the single sign-on provider's address.

The server API fetches the discovery document of the issuer. A failed test answers 200 with success false.

Needs `server.config`. `neodesk settings oidc-test` calls it.

Request body, `application/json`:

| Field | Type | Required |
|---|---|---|
| `issuer_url` | string | yes |
| `allowed_private_cidrs` | string |  |

**200**: Done (`application/json`)

Object or object.

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/settings/passkeys

Show whether passkeys sign in without a password, and which roles must use one.

The server API keeps both settings.

Needs `server.config`. `neodesk settings passkeys` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.signin` | boolean | yes | Sign in with a passkey alone, without a user name or password; on unless it was turned off |
| `data.required_roles` | array of string | yes | The roles whose accounts must sign in with a passkey or security key |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/passkeys

Turn sign-in with a passkey alone on or off, or set the roles that must use a passkey.

Give one or both fields. signin false keeps passkeys as a second factor after the password. A role in required_roles must sign in with a passkey or security key; its accounts without one add one at their next sign-in. Logs the change in the audit log.

Needs `server.config`. `neodesk settings passkeys-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `signin` | boolean | Whether a passkey may sign in without the password |
| `required_roles` | array of string | The roles that must use a passkey: super_admin, server_admin, global_admin, operator, viewer, guest_issuer or a custom role's stable name; an empty list for none. Repeats are dropped |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | Neither field is in the body, signin is not true or false, or required_roles is not a list of roles that exist (code invalid_value) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API did not save the settings |

## GET /api/settings/password-signin

Show whether password sign-in is on, and whether you may turn it off.

why says what is missing when may_turn_off is false: role (only a super admin), no_sso (SAML or OIDC is off) or no_test (no single sign-on worked in your session in the last 30 minutes).

Needs `server.config`. `neodesk settings password-signin` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.off` | boolean | yes | Whether password sign-in is off for everyone |
| `data.may_turn_off` | boolean | yes | Whether the caller may turn it off now |
| `data.why` | string, one of `role`, `no_sso`, `no_test` |  | Only when may_turn_off is false: why not |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## PUT /api/settings/password-signin

Turn password sign-in back on, or off for everyone.

Turning it off needs a super admin with SAML or OIDC on and a single sign-on that worked in their own session (a SAML test in the last 30 minutes, or a session that signed in through the identity provider), so with an API token it is refused. A change writes an audit entry and mails the super admins; the state it is in already answers 200 and changes nothing. If the identity provider is down while it is off, neodesk-server password-sign-in on on the server turns it back on.

Needs `server.config`. `neodesk settings password-signin-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `off` | boolean | yes | true turns password sign-in off for everyone, false turns it back on |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No off in the body, or off is not true or false (code invalid_value) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | The caller may not turn it off now: code password_signin_role (not a super admin), password_signin_no_sso (SAML or OIDC is off) or password_signin_no_test (no single sign-on worked in the caller's session) |
| 500 | Something failed on the server |

## GET /api/settings/public-endpoints

Show the public addresses clients are given.

An empty address follows the host the client reaches the server on.

Needs `server.config`. `neodesk settings addresses` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.public_server_id` | string | yes | The ID server host clients are given |
| `data.public_relay_server` | string | yes | The relay, host and port |
| `data.public_api_url` | string | yes | The API address |
| `data.env_override_active` | boolean | yes | True when at least one address is set |
| `data.env_locked` | array of string | yes | The addresses the server's environment sets at every start, which can't be changed here |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/public-endpoints

Set the public addresses clients are given.

Needs at least one of the addresses. Saves them in the data folder and in the console's .env, and logs the change in the audit log.

Needs `server.config`. `neodesk settings addresses-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `public_server_id` | string | The ID server host clients are given |
| `public_relay_server` | string | The relay, host and port |
| `public_api_url` | string | The API address |

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.public_server_id` | string | yes | The ID server host clients are given |
| `data.public_relay_server` | string | yes | The relay, host and port |
| `data.public_api_url` | string | yes | The API address |
| `data.env_override_active` | boolean | yes | True when at least one address is set |
| `data.env_locked` | array of string | yes | The addresses the server's environment sets at every start, which can't be changed here |
| `message` | string | yes |  |

| Error | When |
|---|---|
| 400 | None of the addresses, or a host or API address that is not valid |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 409 | The server's environment sets this address |

## GET /api/settings/saml

Show the SAML single sign-on settings, the identity provider and the console's addresses for it.

The console's address is panel_url of the OIDC settings when set, else the console's address for mails, else the address of the request.

Needs `server.config`. `neodesk settings saml` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [SettingsSaml](https://docs.neode.sk/de/development/api-reference/schemas.md#settingssaml) | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## PUT /api/settings/saml

Set the SAML single sign-on settings and import the identity provider's metadata.

Give the fields to change; the others keep their value. metadata_xml takes a metadata file's text, metadata_url fetches the metadata now (http or https, not this machine or a cloud metadata address, no redirects, in 10 seconds); with both, metadata_xml wins. Both given empty remove the metadata and turn SAML off. SAML can be on only with metadata, and assertions must be signed by the identity provider. Logs the change in the audit log.

Needs `server.config`. `neodesk settings saml-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `enabled` | boolean | Sign in with SAML; needs metadata |
| `display_name` | string | The name on the sign-in button; at most 100 characters |
| `metadata_url` | string | The identity provider's metadata address, fetched now; at most 2000 characters |
| `metadata_xml` | string | The identity provider's metadata as XML; at most 1048576 characters |
| `attr_username` | string | The attribute with the username; empty for the NameID; at most 300 characters |
| `attr_email` | string | at most 300 characters |
| `attr_name` | string | at most 300 characters |
| `attr_groups` | string | at most 300 characters |
| `default_role` | string | The role of a person without a matching group: any role but pro; at most 40 characters |
| `group_role_map` | string | Groups to roles, as Group=role\|Group=role; at most 10000 characters |
| `allow_signup` | boolean | Make an account at a person's first sign-in |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | No field of the settings is in the body, a value has the wrong type or is too long, default_role is not a role (code invalid_value), the metadata does not pass or could not be fetched (code metadata_invalid), or enabled is true without metadata (code metadata_required) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## GET /api/settings/saml/test

Show your last SAML test sign-in: whether it passed, and the attributes the identity provider sent.

The test itself runs in the browser: Test sign-in in Settings, Single sign-on, SAML (GET /api/auth/saml/test). A result is kept for an hour; data is null without one.

Needs `server.config`. `neodesk settings saml-test` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object or null | yes |  |
| `data.ok` | boolean | yes | Whether the sign-in passed |
| `data.error` | string |  | Only when it failed: why |
| `data.at` | string (date-time) | yes | When it ran (UTC) |
| `data.identity` | object |  | Only when the identity provider's answer was read: who signed in |
| `data.identity.name_id` | string |  |  |
| `data.identity.username` | string |  |  |
| `data.identity.email` | string |  |  |
| `data.identity.display_name` | string |  |  |
| `data.identity.groups` | array of string or null |  |  |
| `data.identity.role` | string |  | The role the sign-in would give |
| `data.identity.role_from_map` | boolean |  | Whether the role came from the group map |
| `data.identity.attributes` | object or null |  | Every attribute the identity provider sent, with its values |
| `data.identity.issuer` | string |  |  |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## GET /api/settings/security-notices

Show which security notices people get by mail.

Mails a person gets about their own account. A notice never saved is on.

Needs `server.config`. `neodesk settings security-notices` calls it.

**200**: Done (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.new_signin` | boolean | yes | Mail about a sign-in from a new device |
| `data.password_changed` | boolean | yes |  |
| `data.two_factor_changed` | boolean | yes |  |
| `data.email_changed` | boolean | yes |  |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## PUT /api/settings/security-notices

Turn security notices by mail on or off.

Give any of the notices, each true or false; the others stay as they are. Logs the change in the audit log.

Needs `server.config`. `neodesk settings security-notices-set` calls it.

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `new_signin` | boolean | Mail about a sign-in from a new device |
| `password_changed` | boolean |  |
| `two_factor_changed` | boolean |  |
| `email_changed` | boolean |  |

**200**: Done (`application/json`)

[ConsoleSuccess](https://docs.neode.sk/de/development/api-reference/schemas.md#consolesuccess).

| Error | When |
|---|---|
| 400 | None of the notices, or a value that is not true or false |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | The server API refused a value |

## GET /api/settings/server-key-check

Show whether devices need the server's key to connect.

The server API keeps the setting. While enforced is false, devices_without_key counts the devices that connected without the key since counting_since.

Needs `server.config`. `neodesk settings server-key-check` calls it.

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [SettingsServerKeyCheck](https://docs.neode.sk/de/development/api-reference/schemas.md#settingsserverkeycheck) | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |

## PUT /api/settings/server-key-check

Require the server's key from connecting devices, or stop requiring it.

Passes the setting on to the server API and answers with the check as the server applied it. Logs the change in the audit log.

Needs `server.config`. `neodesk settings server-key-check-set` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `enforced` | boolean | yes | true refuses devices that connect without the server's key |

**200**: The check as the server applied it (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [SettingsServerKeyCheck](https://docs.neode.sk/de/development/api-reference/schemas.md#settingsserverkeycheck) | yes |

| Error | When |
|---|---|
| 400 | No enforced in the body, or enforced is not true or false |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 500 | Something failed on the server |
