---
title: "Create SMTP Monitor"
description: "Creates a new SMTP monitor."
---

`POST /api/smtp-monitors`

## Authentication

Requires a valid 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"
    }
  }
}
```

### Fields

- `customerId` (number | string, required)
  - Accepts either the internal numeric customer ID or the public customer UUID.
- `name` (string, required)
- `hostname` (string, required)
  - Must be a hostname only (no protocol like `https://`, no path like `/smtp`).
- `port` (number | null, optional)
  - If omitted or `null`, the worker defaults to `465` when `smtpConfig.secure=true`, otherwise `25`.
- `status` (string, optional)
  - Allowed: `active`, `maintenance`, `disabled`, `paused`, `inactive`
- `checkInterval` (number, optional)
- `timeoutSeconds` (number, optional)
- `checkMode` (string, optional)
  - Allowed: `protocol`, `tcp`. Defaults to `protocol`.
  - In `tcp` mode the monitor performs a bare TCP port-reachability check: `smtpConfig` is not required and is not stored. In `protocol` mode the full SMTP protocol/auth check runs (existing behavior).
- `smtpConfig` (object, optional)
  - Stored as the monitor's `config` JSON.

### `smtpConfig` (worker-supported keys)

The SMTP worker coerces/uses these keys:

- `secure` (boolean, default `false`)
- `ignoreTls` (boolean, default `false`)
- `requireTls` (boolean, default `false`)
- `auth.user` and `auth.pass` (strings)
  - Credentials are only used when *both* `user` and `pass` are provided.

## 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` Invalid hostname or invalid request body
- `400` Invalid Customer identifier
- `401` Unauthorized
- `403` Forbidden (e.g. `readonly` or global supporter)

