---
title: "Set alert rule"
method: POST
path: "/platform/deployments/custom/{deployment_id}/alert-rules"
---

# Set alert rule

`POST /platform/deployments/custom/{deployment_id}/alert-rules`

## Request

- Base URL: `https://api.imprezahost.com/v1`
- URL: `https://api.imprezahost.com/v1/platform/deployments/custom/{deployment_id}/alert-rules`
- Auth: API key in header `X-API-Key` and API key in header `X-API-Secret`

Create or update an alert rule on an application. metric "down" fires when the app is not running (threshold is 1); "restart_loop" fires when restarts grow past threshold within the window; "memory_pct" fires when memory stays above threshold percent of its cgroup limit for the window. duration_minutes (1-60) is the consecutive-minutes window. An open rule fires once and closes with a note when the condition clears. Pass rule_id to update an existing rule. Requires deploy scope. Since 25 September 2026 the metrics also include "cpu_pct" (percent 1-10000, 100 = one full core, evaluated on the report against the sample-weighted bucket average), "agent_offline" and "backup_failed" (both threshold 1, evaluated by the platform's minute cron tick with a daily fallback — an offline agent cannot report itself). The failover metrics "standby_stale" and "drill_failed" ride the pair of a standby (its primary application): standby_stale fires when the pair's scheduled sync is at least max(30, duration_minutes) minutes past due and no drill is running (threshold is 1); drill_failed fires while the pair's latest finished drill ended failed, closing when a later drill verifies (threshold is 1). Both are created automatically, enabled, on the pair's first verified sync; evidence carries only state, ages and closed failure codes — never a location, address or app data; with failover disabled they resolve and never open.

## Path parameters

- `deployment_id` string, required: The application (dpl_...).

## Request body

- object
  - `rule_id` string: Existing rule to update (arl_...). Omit to create.
  - `metric` 'down' | 'restart_loop' | 'memory_pct' | 'cpu_pct' | 'agent_offline' | 'backup_failed' | 'ingress_not_enforced' | 'uptime' | 'shield_blocked' | 'shield_rate_limited' | 'standby_stale' | 'drill_failed', required
  - `threshold` number, required: 1 for down, agent_offline, backup_failed, ingress_not_enforced, uptime, standby_stale and drill_failed; restart count for restart_loop; percent 1-100 for memory_pct; percent 1-10000 for cpu_pct (100 = one full core).
  - `duration_minutes` number: Consecutive minutes the condition must hold (1-60, default 3). Shield spike metrics use five UTC minute buckets: duration_minutes must be 5 (default 5); integer threshold 1-1000000 is exceeded by distinct blocked or rate-limited request counts. No visitor identity is recorded.
  - `enabled` boolean: Default true.

## Response `200`

API response envelope. For apply operations acceptance is queued, not verified completion.

## Other responses

- `400`: Invalid input or confirmation
- `403`: Missing permission or unsupported capability
- `404`: Owned resource not found
- `409`: Review expired, conflict or unavailable operation

---

[API](https://skmtc.dev/imprezahost/apis/impreza-host-public-api.md) · [All operations](https://skmtc.dev/imprezahost/apis/impreza-host-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/imprezahost/apis/impreza-host-public-api/revisions/db86511f604f?raw)
