DocsNotificationsNotification Preferences

Notification Preferences

Every user chooses which notifications to receive: the channels, the minimum severity, the scope (environments and teams), the frequency and the event types. Every delivery is recorded and never sent twice.


Overview

The preferences are personal: every authenticated user, viewers included, reads and edits only their own, from the Notifications card of the settings page (/dashboard/settings). They are created with the defaults the first time they are read.

  • Email notifications (email_enabled): on by default
  • Minimum severity (min_severity): critical, high, medium, low or info; default high
  • Always notify KEV (always_kev): known exploited vulnerabilities are notified below the minimum severity and at once even in digest mode; default on
  • Frequency (mode): Immediate (immediate), Hourly digest (hourly_digest) or Daily digest (daily_digest); default immediate
  • Environments (scope_environments) and teams (scope_teams): lists of ids; default empty
  • Events (event_types): the registered event types; default every type registered when the preferences are created
Settings: profile, password and notification preferences

Scope and Events

An empty scope means every environment / every team: the card shows "All environments" and "All teams". An empty event list is an explicit choice: no event is notified. The event types come from a single registry in the backend (apps/notifications/events.py); registering a new type there makes it selectable in the preferences.

  • finding.created: a new finding at or above the minimum severity, in the scope
  • finding.kev: a finding whose CVE is in the CISA KEV catalog
  • finding.sla_breached: a finding that passed its due date (/docs/security/sla) while still open
  • service.critical: a business service (/docs/discovery/cruscotto) of a notified tier became critical; the tiers come from SERVICE_NOTIFY_TIERS (default tier-1 only)
  • service.recovered: a business service you were notified as critical is healthy again (a recovery without a notified critical is not sent)
  • coverage.source_stalled: a discovery zone, relay, agent scan or vulnerability feed stopped bringing data (/dashboard/coverage), once per stall episode

Note: For the service events the scope applies to the environment and the owner team of the service (a service without environment or team is outside a non-empty scope); the minimum severity does not apply. The stalled sources have no environment or team, so the scope is ignored. A service that flaps between critical and healthy is notified at most once every SERVICE_NOTIFY_COOLDOWN_MINUTES (default 15) per recipient, and its final state is always notified. Preferences created before these events existed do not include them: select them in the card.

Validation

The server validates every save: min_severity and mode must be one of the values above, every environment and team id must exist and every event type must be registered. Lists are deduplicated and sorted before being saved. An invalid value returns 400 with the error under its field and nothing is saved; the card shows the error under the field. An environment or team deleted after being chosen is shown as "Unknown #<id>" and can be unchecked.

API

GET /api/v1/notifications/preferences/ returns the current user's preferences (there is no user id in the URL). PUT and PATCH update only the fields sent; omitted fields are left unchanged. GET /api/v1/notifications/event-types/ lists the registry as {key, label, description}. Every endpoint requires authentication (401 otherwise).

curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"min_severity": "critical", "mode": "daily_digest", "scope_teams": [3, 1]}' \
  https://idp.example.com/api/v1/notifications/preferences/

Example Response

The preferences after the request above:

{
  "email_enabled": true, "min_severity": "critical", "always_kev": true, "mode": "daily_digest",
  "scope_environments": [], "scope_teams": [1, 3],
  "event_types": ["coverage.source_stalled", "finding.created", "finding.kev", "finding.sla_breached",
    "service.critical", "service.recovered"],
  "updated_at": "2026-11-28T10:00:00Z"
}

Delivery Log and Idempotency

Every delivery attempt is recorded in NotificationLog with the user, the channel (email, in_app, ...), the event key (for example cve:CVE-2026-1234, or burst:<time> for a burst summary, /docs/notifications/cve-emails), the status (pending, sent or failed), sent_at and the error of a failed attempt (at most 2000 characters). The same event key is never sent twice to the same user on the same channel: a sent or in-progress (pending) delivery blocks a new one, guaranteed by a unique database constraint, while a failed attempt leaves the way free for a retry. The same event key on another channel is delivered independently. The log is view-only in the Django admin.

Warning: A worker that stops between claiming a delivery and recording its outcome leaves a pending row that blocks that user, channel and event key.