---
title: "Test Alert Preferences"
method: POST
path: "/api/alert-preferences/test"
tags: ["Alerts"]
---

# Test Alert Preferences

`POST /api/alert-preferences/test`

## Request

- Base URL: `https://api.kolens.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.kolens.ai/api/alert-preferences/test`
- Auth: HTTP bearer

Fire a synthetic alert through every enabled channel.

Returns the per-channel success/error map so the settings UI can
show the user what worked and what didn't. The synthetic alert is
NOT persisted — this is a dry-run probe, not a real signal.

``channel`` lets the settings UI fire ONE channel at a time —
clicking "Test email" should not also POST to the user's webhook
(which would noise up their Slack channel for no reason). Implemented
by temporarily disabling the other channel on the in-memory prefs
row before calling ``deliver_alert`` and restoring afterwards, so
the dispatcher logic stays untouched and the saved row is unchanged.

UX: when no preferences row exists yet, we upsert one from the
body (treating Test as Save+Test). This lets the user paste a
webhook URL and immediately click Test without first hitting
Save — the previous "save preferences first?" 404 was a confusing
dead end.

## Query parameters

- `channel` string, nullable: Restrict the probe to a single channel. Omit to test all enabled channels.

## Headers

- `x-kolens-user-id` string, nullable

## Request body

- AlertPreferenceIn: Patch shape for PUT — every field optional. We diff vs the row we already have so partial updates from the settings form don't accidentally clear a sibling field.
  - `email_enabled` boolean, nullable
  - `email_to` string, nullable
  - `webhook_enabled` boolean, nullable
  - `webhook_url` string, nullable
  - `webhook_secret` string, nullable
  - `muted_types` string[], nullable
  - `rate_per_hour` integer, nullable
  - `preferred_locale` string, nullable: BCP-47 tag from the supported set: en | zh-CN | ja
  - `rising_score_threshold` number, nullable
  - `rising_follower_pct` number, nullable
  - `rising_follower_delta` integer, nullable
  - `rising_view_growth_pct` number, nullable
  - `rising_lookback_days` integer, nullable

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kolens/apis/kolens-api.md) · [All operations](https://skmtc.dev/kolens/apis/kolens-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kolens/apis/kolens-api/revisions/5d6865ab0a24?raw)
