# Konsole: automation

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

> 21 Operationen. Alert rules, alerts, queued device commands and alert mail.

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.

Alert rules, alerts, queued device commands and alert mail.

## GET /api/automation/alerts

List alerts, the one triggered last first.

Each filter is one text; an empty one does not filter.

Needs `server.config`. `neodesk automation alerts` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `device_id` | query | string |  |
| `severity` | query | string, one of `info`, `warning`, `critical` |  |
| `acknowledged` | query | string, one of `true`, `false` | true for the acknowledged alerts, false for the rest |
| `limit` | query | integer | At most 500; a larger one is 500; default `500`, at least 1 |

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

| Field | Type | Required | What it is |
|---|---|---|---|
| `alerts` | array of object | yes |  |
| `alerts[].id` | integer |  |  |
| `alerts[].rule_id` | integer |  |  |
| `alerts[].rule_name` | string or null |  | The name of the alert's rule |
| `alerts[].device_id` | string or null |  |  |
| `alerts[].severity` | string or null |  |  |
| `alerts[].message` | string |  |  |
| `alerts[].triggered_at` | string (date-time) |  | On SQLite the stored text, on PostgreSQL an ISO time with |
| `alerts[].acknowledged` | integer or boolean |  | 1 or 0 on SQLite, true or false on PostgreSQL |
| `alerts[].acknowledged_by` | string or null |  |  |
| `alerts[].acknowledged_at` | string or null (date-time) |  | On SQLite the stored text, on PostgreSQL an ISO time with |
| `alerts[].created_at` | string or null (date-time) |  | On SQLite the stored text, on PostgreSQL an ISO time with |
| `total` | integer | yes | The number of alerts in the answer |

| Error | When |
|---|---|
| 400 | A filter or the limit 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 |

## POST /api/automation/alerts/{id}/ack

Acknowledge an alert.

Marks the alert as acknowledged by the account, now. An alert acknowledged already keeps its first acknowledgement.

Needs `server.config`. `neodesk automation alert-ack` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The alert's ID, in digits |

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

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

| 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 | There is no such alert |

## GET /api/automation/commands

List commands queued for devices.

Lists the commands of the devices in the account's device scope, the one created last first, each without its result. Each filter is one text; an empty one does not filter.

Needs `device.connect and server.config`. `neodesk automation commands` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `device_id` | query | string |  |
| `status` | query | string | pending, or a status an agent reported |
| `limit` | query | integer | At most 500; a larger one is 500; default `500`, at least 1 |

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

| Field | Type | Required | What it is |
|---|---|---|---|
| `commands` | array of [RemoteCommand](https://docs.neode.sk/de/development/api-reference/schemas.md#remotecommand) | yes |  |
| `total` | integer | yes | The number of commands in the answer |

| Error | When |
|---|---|
| 400 | A filter or the limit 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 |

## POST /api/automation/commands

Queue a command for a device's agent.

The command waits until the device's agent fetches it. The device must be one the server knows and the account's device scope holds.

Needs `device.connect and server.config`. `neodesk automation command-create` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `device_id` | string | yes | The device's ID |
| `payload` | string | yes | The command or script, not blank |
| `command_type` | string, one of `shell`, `powershell`, `script`, `restart_service`, `reboot` |  | shell when not given |

**201**: The command as it is stored (`application/json`)

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

| Error | When |
|---|---|
| 400 | A field is missing or not valid, or the server does not know the device |
| 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 device is outside its device scope |

## GET /api/automation/commands/{id}

Show one command with its result.

A command for a device outside the account's device scope is not found.

Needs `device.connect and server.config`. `neodesk automation command` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The command's ID, in digits |

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

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

| 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 | There is no such command |

## GET /api/automation/rules

List alert rules.

Needs `server.config`. `neodesk automation rules` calls it.

**200**: The rules, the newest first (`application/json`)

| Field | Type | Required |
|---|---|---|
| `rules` | array of [AlertRule](https://docs.neode.sk/de/development/api-reference/schemas.md#alertrule) | yes |
| `total` | integer | 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/automation/rules

Create an alert rule.

Needs `server.config`. `neodesk automation rule-create` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `name` | string | yes | Not blank |
| `description` | string |  |  |
| `condition_type` | string, one of `cpu_usage`, `memory_usage`, `disk_usage`, `offline_duration`, `idle_duration`, `date_field_within`, `custom` | yes |  |
| `condition_op` | string, one of `gt`, `gte`, `lt`, `lte`, `eq`, `neq` |  | gt when not given |
| `condition_value` | number |  | 0 when not given; for date_field_within the days ahead, a whole number from 0 to 3650 |
| `condition_field` | string |  | For date_field_within only, and needed there: the key of a date field. The account must see every date field with the key (restricted ones need device.fields_restricted); a key it doesn't see is refused like one no field has, with the code device_field_alert_field |
| `severity` | string, one of `info`, `warning`, `critical` |  | warning when not given or none of the three |
| `scope_device_id` | string or null |  | The one device the rule watches; null or missing for every device |
| `cooldown_seconds` | integer or null |  | 300 when not given, 0 or null; at least 0, at most 2147483647 |
| `notify_emails` | string or null |  | Plain addresses separated by commas |
| `enabled` | boolean or integer or string |  | Off for false, 0, "0" and "false"; on for anything else |

**201**: The rule as it is stored (`application/json`)

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

| Error | When |
|---|---|
| 400 | The name is blank, or a field has the wrong type or 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/automation/rules/{id}

Show one alert rule.

Needs `server.config`. `neodesk automation rule` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

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

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

| 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 | There is no such rule |

## PATCH /api/automation/rules/{id}

Change an alert rule.

Writes every field of the body that names a field of a rule, null included, with the checks of the create. A cooldown_seconds of 0 or null is stored as 300.

Needs `server.config`. `neodesk automation rule-update` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `name` | string | Not blank |
| `description` | string |  |
| `condition_type` | string, one of `cpu_usage`, `memory_usage`, `disk_usage`, `offline_duration`, `idle_duration`, `date_field_within`, `custom` |  |
| `condition_op` | string, one of `gt`, `gte`, `lt`, `lte`, `eq`, `neq` |  |
| `condition_value` | number | Not null; for date_field_within the days ahead, a whole number from 0 to 3650 |
| `condition_field` | string | For date_field_within only, and needed there: the key of a date field. The account must see every date field with the key (restricted ones need device.fields_restricted); a key it doesn't see is refused like one no field has, with the code device_field_alert_field |
| `severity` | string, one of `info`, `warning`, `critical` |  |
| `scope_device_id` | string or null | The one device the rule watches; null or missing for every device |
| `cooldown_seconds` | integer or null | 300 when not given, 0 or null; at least 0, at most 2147483647 |
| `notify_emails` | string or null | Plain addresses separated by commas |
| `enabled` | boolean or integer or string | Off for false, 0, "0" and "false"; on for anything else |

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

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

| Error | When |
|---|---|
| 400 | A field has the wrong type or 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 |
| 404 | There is no such rule |

## DELETE /api/automation/rules/{id}

Delete an alert rule and its alerts.

Needs `server.config`. `neodesk automation rule-delete` calls it. It cannot be undone.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

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

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

| 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 | There is no such rule |

## GET /api/automation/smtp

Show the mail settings for alerts.

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

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

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

| 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/automation/smtp

Set the mail settings for alerts.

Replaces the SMTP settings. A missing, empty or masked ("********") password keeps the stored one, but only for the same host, port and user and while the certificate check stays on; otherwise the request is refused.

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

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `host` | string | yes | Not blank |
| `port` | integer or string or null |  | 587 when missing or null; a string must be digits; at least 1, at most 65535 |
| `secure` | boolean |  | false when missing |
| `user` | string or null |  |  |
| `pass` | string or null |  | "" removes the password |
| `from` | string | yes | One address, alone or with a name ("NeoDesk &lt;neodesk@example.org>"), at most 998 characters |
| `alert_email` | string or null |  | Plain addresses separated by commas |
| `tlsVerify` | boolean |  | Whether to check the mail server's certificate; left out of the settings when not given |

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

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

| Error | When |
|---|---|
| 400 | A field is missing or not valid, or the stored password can't be kept |
| 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/automation/smtp/test

Test the mail server of the mail settings.

Connects to the mail server and signs in, without sending a mail. A failure answers 200 with success false.

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

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

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | boolean | yes |  |
| `error` | string |  | Why the test failed, only on failure |

| 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/automation/rules/{id}/pause

Pause an alert rule until a time.

It raises no alert until then, and turns itself back on at that time with the audit entry alert_rule_resumed_automatically. Writes alert_rule_paused.

Needs `server.config`. `neodesk automation rule-pause` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

Request body, `application/json`:

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

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

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

| Error | When |
|---|---|
| 400 | No time in the next 366 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 |
| 404 | There is no such rule |

## DELETE /api/automation/rules/{id}/pause

End the pause of an alert rule now.

Writes alert_rule_resumed to the audit log.

Needs `server.config`. `neodesk automation rule-resume` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

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

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

| 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 | There is no such rule |
| 409 | The rule is not paused |

## POST /api/automation/rules/{id}/mute

Mute an alert rule for one device until a time.

Writes alert_rule_muted_for_device to the audit log.

Needs `server.config`. `neodesk automation rule-mute` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

Request body, `application/json`:

[SnoozeBody](https://docs.neode.sk/de/development/api-reference/schemas.md#snoozebody) and object.

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

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

| Error | When |
|---|---|
| 400 | No device, or no time in the next 366 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 |
| 404 | There is no such rule |

## DELETE /api/automation/rules/{id}/mute

End the mute of an alert rule for one device now.

Writes alert_rule_unmuted_for_device to the audit log.

Needs `server.config`. `neodesk automation rule-unmute` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |
| `device_id` | query | string | yes | The device ID |

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

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

| 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 | There is no such rule |
| 409 | The rule is not muted for the device |

## GET /api/automation/snoozes

List the paused and muted alert rules.

The ones that end first first.

Needs `server.config`. `neodesk automation snoozes` calls it.

**200**: The pauses and mutes (`application/json`)

| Field | Type | Required |
|---|---|---|
| `snoozes` | array of [Snooze](https://docs.neode.sk/de/development/api-reference/schemas.md#snooze) | yes |
| `total` | integer |  |

| 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/automation/rules/{id}/quiet-hours

Show the quiet hours of an alert rule.

Needs `server.config`. `neodesk automation rule-quiet-hours` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

**200**: The quiet hours, null for none (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `quiet_hours` | [QuietHours](https://docs.neode.sk/de/development/api-reference/schemas.md#quiethours) or null |  |

| 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 | There is no such rule |

## PUT /api/automation/rules/{id}/quiet-hours

Set the quiet hours of an alert rule.

In those hours the rule's alerts are recorded but not sent; when they end its recipients get one summary by mail and on its channels (alert.summary), unless summary is drop. Alerts of bypass_severity and above are sent at once. Writes alert_rule_quiet_hours_set.

Needs `server.config`. `neodesk automation rule-quiet-hours-set` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `days` | array of string | yes |  |
| `start_time` | string | yes | A wall clock time, HH:MM in 24 hours |
| `end_time` | string | yes | At or before start_time is on the next day |
| `time_zone` | string |  |  |
| `summary` | string, one of `send`, `drop` |  |  |
| `bypass_severity` | string, one of ``, `info`, `warning`, `critical` |  |  |

**200**: The quiet hours (`application/json`)

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

| Error | When |
|---|---|
| 400 | A field is wrong |
| 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 | There is no such rule |

## DELETE /api/automation/rules/{id}/quiet-hours

Remove the quiet hours of an alert rule.

Alerts recorded in them go out in the summary with the next sweep. Writes alert_rule_quiet_hours_removed.

Needs `server.config`. `neodesk automation rule-quiet-hours-remove` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The rule's ID, in digits |

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

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

| 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 rule, or it has no quiet hours |
