---
title: "Preview Alerts"
method: POST
path: "/api/v1/sdk/alerts/preview"
tags: ["public-api", "public-alerts"]
---

# Preview Alerts

`POST /api/v1/sdk/alerts/preview`

## Request

- Base URL: `http://localhost:8000`
- URL: `http://localhost:8000/api/v1/sdk/alerts/preview`
- Auth: none declared

Preview which alerts match given filter criteria.

Analyzes historical alerts to show how many would match the specified
filters. Useful for tuning alert rules or understanding alert patterns.

**SDK Usage:**
```python
from anomalyarmor import Client
client = Client()

result = client.alerts.preview(
    event_types=["freshness_stale"],
    severities=["critical"],
    lookback_hours=24,
)

print(f"Matching alerts: {result.alerts_would_match}")
print(f"By severity: {result.alerts_by_severity}")
```

## Headers

- `Authorization` string

## Request body

- AlertPreviewRequest: Request to preview alert rule matches.
  - `asset_id` string, nullable: Scope to specific asset (UUID or name)
  - `event_types` string[], nullable: Event types to match (freshness_sla_violation, schema_change, etc.)
  - `severities` string[], nullable: Severity levels to match (info, warning, critical)
  - `lookback_hours` integer: Hours of alert history to analyze

## Response `200`

Successful Response

- StandardResponse: Standard API response wrapper.
  - `success` boolean, required
  - `data` unknown
  - `message` string, nullable
  - `error` string, nullable
  - `meta` object, nullable

## Other responses

- `422`: Validation Error

---

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