---
title: "SSH Monitor erstellen"
description: "Erstellt einen neuen SSH Monitor."
---

`POST /api/ssh-monitors`

## Authentifizierung

Erfordert eine gültige Session.

- Header: `Authorization: Bearer <token>`

## Request Body

```json
{
  "customerId": "11111111-1111-4111-8111-111111111111",
  "name": "Bastion Host",
  "hostname": "ssh.deinkunde.com",
  "port": 22,
  "status": "active",
  "checkInterval": 60,
  "timeoutSeconds": 30,
  "sshConfig": {
    "username": "root",
    "password": "password",
    "privateKey": "-----BEGIN OPENSSH PRIVATE KEY-----..."
  }
}
```

### Felder

- `customerId` (number | string, required)
  - Akzeptiert entweder die interne numerische Kunden-ID oder die öffentliche Kunden-UUID.
- `name` (string, required)
- `hostname` (string, required)
  - Muss ein Hostname sein (kein Protokoll wie `https://`, kein Pfad wie `/ssh`).
- `port` (number | null, optional)
  - Wenn weggelassen oder `null`, nutzt der Worker standardmäßig Port `22`.
- `status` (string, optional)
  - Erlaubt: `active`, `maintenance`, `disabled`, `paused`, `inactive`
- `checkInterval` (number, optional)
- `timeoutSeconds` (number, optional)
- `checkMode` (string, optional)
  - Erlaubt: `protocol`, `tcp`. Standard: `protocol`.
  - Im Modus `tcp` führt der Monitor nur eine reine TCP-Port-Erreichbarkeitsprüfung durch: `sshConfig` ist nicht erforderlich und wird nicht gespeichert. Im Modus `protocol` läuft die vollständige SSH-Login-/Handshake-Prüfung (bisheriges Verhalten).
- `sshConfig` (object, optional)
  - Wird als `config` JSON gespeichert.
  - Erforderlich (username + password oder privateKey), außer `checkMode` ist `tcp`.

### `sshConfig` (vom Worker unterstützte Keys)

- `username` (string)
  - Wenn weggelassen, nutzt der Worker `anonymous`.
- `password` (string)
- `privateKey` (string)

## cURL

```bash
curl -X POST "https://YOUR_DOMAIN/api/ssh-monitors" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "11111111-1111-4111-8111-111111111111",
    "name": "Bastion Host",
    "hostname": "ssh.deinkunde.com",
    "port": 22,
    "status": "active",
    "checkInterval": 60,
    "timeoutSeconds": 30,
    "sshConfig": { "username": "root", "password": "password" }
  }'
```

## Response

```json
{
  "id": 300,
  "organizationId": 1,
  "customerId": 10,
  "name": "Bastion Host",
  "hostname": "ssh.deinkunde.com",
  "port": 22,
  "status": "active",
  "checkInterval": 60,
  "timeoutSeconds": 30,
  "notificationEmail": null,
  "notificationPhoneNumber": null,
  "lastCheckedAt": null,
  "createdAt": "2026-02-26T12:00:00.000Z",
  "updatedAt": "2026-02-26T12:00:00.000Z",
  "config": {
    "username": "root",
    "password": "password"
  },
  "sshConfig": {
    "username": "root",
    "password": "password"
  }
}
```

## Errors

- `400` Ungültiger Hostname oder ungültiger Request Body
- `400` Ungültiger Customer-Identifier
- `401` Unauthorized
- `403` Forbidden (z.B. `readonly` oder global supporter)

