Create Alert Rule
POST /alertsRequest body — AlertRuleCreate
Section titled “Request body — AlertRuleCreate”| Field | Type | Notes | |
|---|---|---|---|
name | string | required | min length 1 max length 200 |
metric | error_rate | success_rate | failure_count | run_count | avg_latency_ms | p95_latency_ms | cost | token_total | queue_depth | suspension_age | queued_without_workers | provider_credit_remaining | providers_unreachable | required | — |
comparator | gt | gte | lt | lte | required | — |
threshold | number | required | — |
scope | workspace | organization | platform | optional | Default "workspace". |
agent_id | string (uuid) | null | optional | — |
window_seconds | integer | optional | Default 300. min 60 max 86400 |
min_samples | integer | optional | Default 5. min 1 max 10000 |
severity | info | warning | critical | optional | Default "warning". |
cooldown_seconds | integer | optional | Default 300. min 60 max 86400 |
notify_log | boolean | optional | Default true. |
notify_webhook_url | string | null | optional | — |
notify_secret | string | null | optional | min length 16 max length 200 |
is_active | boolean | optional | Default true. |
Responses
Section titled “Responses”| Status | Description | Body |
|---|---|---|
201 | Successful Response | AlertRuleView |
422 | Validation Error | HTTPValidationError |
Example
Section titled “Example”The body shows the fields the schema always carries. Which combination is legal is a service rule the schema cannot express, so read the description above before copying this.
curl -X POST https://your-deployment.example.com/alerts \ -H "Authorization: Bearer $COBRE_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "metric": "error_rate", "comparator": "gt", "threshold": 0 }'Response — AlertRuleView
Section titled “Response — AlertRuleView”| Field | Type | Notes | |
|---|---|---|---|
id | string (uuid) | required | — |
scope | workspace | organization | platform | required | — |
name | string | required | — |
metric | error_rate | success_rate | failure_count | run_count | avg_latency_ms | p95_latency_ms | cost | token_total | queue_depth | suspension_age | queued_without_workers | provider_credit_remaining | providers_unreachable | required | — |
comparator | gt | gte | lt | lte | required | — |
threshold | number | required | — |
agent_id | string (uuid) | null | required, nullable | — |
window_seconds | integer | required | — |
min_samples | integer | required | — |
severity | info | warning | critical | required | — |
cooldown_seconds | integer | required | — |
notify_log | boolean | required | — |
notify_webhook_url | string | null | required, nullable | — |
is_active | boolean | required | — |
last_evaluated_at | string (date-time) | null | required, nullable | — |
last_value | number | null | required, nullable | — |
created_at | string (date-time) | required | — |
updated_at | string (date-time) | required | — |