---
title: "Create an alert rule"
method: POST
path: "/v1/platform/alerts/{session_id}"
tags: ["alert_rules"]
---

# Create an alert rule

`POST /v1/platform/alerts/{session_id}`

Creates a new alert rule. The request body must be a JSON-encoded alert rule object that follows the CreateAlertRuleRequest schema.

## Path parameters

- `session_id` string, required

## Request body

- AlertsCreateAlertRuleRequest
  - `actions` AlertsAlertActionBase[], required
    - `alert_rule_id` string
    - `config` object, required
    - `id` string
    - `target` 'pagerduty' | 'webhook' | 'dynatrace', required
  - `rule` AlertsAlertRuleBase, required
    - `aggregation` 'avg' | 'sum' | 'pct', required
    - `attribute` 'latency' | 'error_count' | 'feedback_score' | 'run_latency' | 'run_count' | 'total_cost', required
    - `denominator_filter` string
    - `description` string, required
    - `filter` string
    - `id` string
    - `name` string, required
    - `operator` 'gte' | 'lte' | 'gt' | 'lt', required
    - `threshold` number
    - `threshold_multiplier` number
    - `threshold_window_minutes` integer
    - `type` 'threshold' | 'change', required
    - `window_minutes` integer, required — 1-60 minutes for alert rule

## Response `201`

Alert rule created

- AlertsAlertRuleResponse
  - `actions` AlertsAlertAction[]
    - `alert_rule_id` string
    - `config` object, required
    - `created_at` string
    - `id` string
    - `target` 'pagerduty' | 'webhook' | 'dynatrace', required
    - `updated_at` string
  - `rule` AlertsAlertRule
    - `aggregation` 'avg' | 'sum' | 'pct', required
    - `attribute` 'latency' | 'error_count' | 'feedback_score' | 'run_latency' | 'run_count' | 'total_cost', required
    - `created_at` string
    - `denominator_filter` string
    - `description` string, required
    - `filter` string
    - `id` string
    - `name` string, required
    - `operator` 'gte' | 'lte' | 'gt' | 'lt', required
    - `session_id` string
    - `session_name` string
    - `threshold` number
    - `threshold_multiplier` number
    - `threshold_window_minutes` integer
    - `type` 'threshold' | 'change', required
    - `updated_at` string
    - `window_minutes` integer, required — 1-60 minutes for alert rule

## Other responses

- `400` — Bad request
- `403` — Forbidden
- `429` — Alert Rule Limit Reached
- `500` — Internal server error
- `503` — Service unavailable

---

[API](https://skmtc.net/langchain-ai/apis/langsmith.md) · [All operations](https://skmtc.net/langchain-ai/apis/langsmith/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/langchain-ai/langsmith/revisions/a0acb3a6a101/schema)
