---
title: "Create an alert rule"
method: POST
path: "/v1/alert-rules"
---

# Create an alert rule

`POST /v1/alert-rules`

Create a new alert rule. The `account_id` is derived from the `X-API-KEY` header.

## Request body

- AlertRuleCreateRequest — Fields for creating a new alert rule: which metric to watch, the threshold condition, and how long it must hold to fire.
  - `name` string, required — Alert rule name
  - `project_id` string, nullable — Project ID (optional)
  - `metric` 'turn_latency_p50' | 'turn_latency_p95' | 'api_errors' | 'function_errors' | 'call_crashes' | 'call_volume', required — Metric to monitor.
  - `operator` '>' | '<' | '>=' | '<=', required — Comparison operator used by the alert rule.
  - `threshold_value` integer, required — Threshold value
  - `window_duration` '5m' | '10m' | '60m', required — Evaluation window duration. Allowed values: `5m`, `10m`, or `60m`.
  - `enabled` boolean — Whether the alert is enabled

## Response `201`

Alert rule created successfully.

- AlertRuleResponse — An alert rule: its trigger condition, evaluation window, and current state.
  - `id` string, required — Alert rule ID
  - `name` string, required — Alert rule name
  - `project_id` string, nullable — Project ID
  - `metric` 'turn_latency_p50' | 'turn_latency_p95' | 'api_errors' | 'function_errors' | 'call_crashes' | 'call_volume', required — Metric to monitor.
  - `operator` '>' | '<' | '>=' | '<=', required — Comparison operator used by the alert rule.
  - `threshold_value` integer, required — Threshold value
  - `window_duration` '5m' | '10m' | '60m', required — Evaluation window duration. Allowed values: `5m`, `10m`, or `60m`.
  - `enabled` boolean, required — Whether the alert is enabled
  - `current_state` 'ok' | 'alert' | 'no_data' | 'unknown' — Current state of an alert rule.
  - `since` string, date-time, nullable — When the current state started
  - `last_evaluated_at` string, date-time, nullable — Last evaluation timestamp
  - `current_value` integer, nullable — Current metric value
  - `created_at` string, date-time, required — Creation timestamp
  - `updated_at` string, date-time, required — Last update timestamp

## Other responses

- `400` — Validation error.
- `401` — Missing or invalid API key.
- `409` — Resource limit exceeded (e.g. maximum number of webhook endpoints reached).
- `422` — Validation error or malformed resource ID.
- `500` — Internal server error.
- `502` — Monitoring backend sync failure.

---

[API](https://skmtc.net/poly/apis/polyai-agents-api.md) · [All operations](https://skmtc.net/poly/apis/polyai-agents-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/poly/polyai-agents-api/versions/76f3c606e395/schema)
