---
title: "IMAP/POP Monitor erstellen"
description: "Erstellt einen neuen IMAP/POP Monitor."
---

`POST /api/imap-pop-monitors`

## Authentifizierung

Erfordert eine gültige Session.

- Header: `Authorization: Bearer <token>`

## Request Body

```json
{
  "customerId": "11111111-1111-4111-8111-111111111111",
  "name": "Mailbox Access",
  "hostname": "mail.deinkunde.com",
  "port": 993,
  "status": "active",
  "checkInterval": 30,
  "timeoutSeconds": 30,
  "imapPopConfig": {
    "protocol": "imap",
    "user": "monitor@deinkunde.com",
    "password": "password",
    "tls": true,
    "tlsOptions": { "rejectUnauthorized": true }
  }
}
```

### 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 `/imap`).
- `port` (number | null, optional)
  - Wenn weggelassen oder `null`, wählt der Worker einen Default-Port abhängig von `imapPopConfig.protocol` und `imapPopConfig.tls`.
- `status` (string, optional)
  - Erlaubt: `active`, `maintenance`, `disabled`, `paused`, `inactive`
  - Hinweis: `paused` / `inactive` werden zu `disabled` normalisiert.
- `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: `imapPopConfig` ist nicht erforderlich und wird nicht gespeichert. Im Modus `protocol` läuft die vollständige IMAP/POP-Login-Prüfung (bisheriges Verhalten).
  - **`port` ist erforderlich, wenn `checkMode` `tcp` ist**. Ohne `port` schlägt der Request mit `400` / `data.code: "portRequiredForTcp"` fehl.
- `imapPopConfig` (object, optional)
  - Wird als `config` JSON gespeichert.
  - Erforderlich (`user` + `password`), außer `checkMode` ist `tcp`.

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

- `protocol` (`imap` | `pop3`)
  - Default: `imap`
- `user` (string)
- `password` (string)
- `tls` (boolean)
  - Default: `false`
- `tlsOptions.rejectUnauthorized` (boolean)
  - Wird von der IMAP Worker-Library genutzt; POP3 ignoriert diese Option aktuell.

### Default-Ports (Worker-Verhalten)

Wenn `port` weggelassen oder `null` ist:

- IMAP:
  - TLS (`tls: true`): `993`
  - Non-TLS (`tls: false`): `143`
- POP3:
  - TLS (`tls: true`): `995`
  - Non-TLS (`tls: false`): `110`

## cURL

```bash
curl -X POST "https://YOUR_DOMAIN/api/imap-pop-monitors" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "11111111-1111-4111-8111-111111111111",
    "name": "Mailbox Access",
    "hostname": "mail.deinkunde.com",
    "port": 993,
    "status": "active",
    "checkInterval": 30,
    "timeoutSeconds": 30,
    "imapPopConfig": { "protocol": "imap", "user": "monitor@deinkunde.com", "password": "password", "tls": true }
  }'
```

## Response

```json
{
  "id": 500,
  "organizationId": 1,
  "customerId": 10,
  "name": "Mailbox Access",
  "hostname": "mail.deinkunde.com",
  "port": 993,
  "checkInterval": 30,
  "timeoutSeconds": 30,
  "status": "active",
  "notificationPhoneNumber": null,
  "notificationEmail": null,
  "lastCheckedAt": null,
  "createdAt": "2026-02-26T12:00:00.000Z",
  "updatedAt": "2026-02-26T12:00:00.000Z",
  "config": {
    "protocol": "imap",
    "user": "monitor@deinkunde.com",
    "password": "password",
    "tls": true
  },
  "imapPopConfig": {
    "protocol": "imap",
    "user": "monitor@deinkunde.com",
    "password": "password",
    "tls": true
  }
}
```

## 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)
- `404` Customer not found

