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

`POST /api/smtp-monitors`

## Authentifizierung

Erfordert eine gültige Session.

- Header: `Authorization: Bearer <token>`

## Request Body

```json
{
  "customerId": "11111111-1111-4111-8111-111111111111",
  "name": "Outbound SMTP",
  "hostname": "smtp.deinkunde.com",
  "port": 587,
  "status": "active",
  "checkInterval": 60,
  "timeoutSeconds": 30,
  "smtpConfig": {
    "secure": false,
    "ignoreTls": false,
    "requireTls": false,
    "auth": {
      "user": "username",
      "pass": "password"
    }
  }
}
```

### Felder

- `customerId` (number | string, erforderlich)
  - Akzeptiert entweder die interne numerische Kunden-ID oder die öffentliche Kunden-UUID.
- `name` (string, erforderlich)
- `hostname` (string, erforderlich)
  - Muss nur ein Hostname sein (kein Protokoll wie `https://`, kein Pfad wie `/smtp`).
- `port` (number | null, optional)
  - Wenn weggelassen oder `null`, nutzt der Worker standardmäßig `465`, wenn `smtpConfig.secure=true`, sonst `25`.
- `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: `smtpConfig` ist nicht erforderlich und wird nicht gespeichert. Im Modus `protocol` läuft die vollständige SMTP-Protokoll-/Auth-Prüfung (bisheriges Verhalten).
- `smtpConfig` (object, optional)
  - Wird als `config` JSON des Monitors gespeichert.

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

Der SMTP Worker nutzt/normalisiert diese Keys:

- `secure` (boolean, default `false`)
- `ignoreTls` (boolean, default `false`)
- `requireTls` (boolean, default `false`)
- `auth.user` und `auth.pass` (strings)
  - Credentials werden nur verwendet, wenn *beide* `user` und `pass` gesetzt sind.

## cURL

```bash
curl -X POST "https://YOUR_DOMAIN/api/smtp-monitors" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "11111111-1111-4111-8111-111111111111",
    "name": "Outbound SMTP",
    "hostname": "smtp.deinkunde.com",
    "port": 587,
    "status": "active",
    "checkInterval": 60,
    "timeoutSeconds": 30,
    "smtpConfig": {
      "secure": false,
      "ignoreTls": false,
      "requireTls": false,
      "auth": { "user": "username", "pass": "password" }
    }
  }'
```

## Response

```json
{
  "id": 200,
  "organizationId": 1,
  "customerId": 10,
  "name": "Outbound SMTP",
  "hostname": "smtp.deinkunde.com",
  "port": 587,
  "status": "active",
  "checkInterval": 60,
  "timeoutSeconds": 30,
  "notificationEmail": null,
  "notificationPhoneNumber": null,
  "lastCheckedAt": null,
  "createdAt": "2026-01-01T12:00:00.000Z",
  "updatedAt": "2026-01-01T12:00:00.000Z",
  "config": {
    "secure": false,
    "ignoreTls": false,
    "requireTls": false,
    "auth": { "user": "username", "pass": "password" }
  },
  "smtpConfig": {
    "secure": false,
    "ignoreTls": false,
    "requireTls": false,
    "auth": { "user": "username", "pass": "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)

