Alert Rules API
Alert rules watch your traffic and notify one or more notification channels when a condition fires.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/alert-rules | List alert rules |
| GET | /api/alert-rules/{id} | Get an alert rule |
| POST | /api/alert-rules | Create an alert rule |
| PATCH | /api/alert-rules/{id} | Update an alert rule |
| POST | /api/alert-rules/{id}/test | Send a test notification |
| DELETE | /api/alert-rules/{id} | Delete an alert rule |
Trigger Types
Each rule has a triggerType and a matching triggerConfig:
| Trigger | Fires when | Key config |
|---|---|---|
source_silence | A source receives no events for a period | sourceId?, silenceMinutes (1–1440) |
failure_rate | Delivery failure % exceeds a threshold | destinationId?, thresholdPercent (1–100), windowMinutes (5–1440) |
latency_threshold | Average delivery latency exceeds a threshold | destinationId?, thresholdMs (100–300000), windowMinutes (5–1440) |
volume_spike | Event volume exceeds a max | sourceId?, maxEvents, windowMinutes (1–1440) |
volume_drop | Event volume drops below a min | sourceId?, minEvents, windowMinutes (5–1440) |
anomaly_volume | Volume deviates from its baseline (z-score) | sourceId, direction (spike/drop/both), zThreshold (2–10), windowMinutes (10–360) |
schema_drift | A source payload schema changes | sourceId, alertOn.{addedFields,removedFields,typeChanges} |
Omitting sourceId/destinationId (where optional) applies the rule across all sources/destinations.
Alert Rule Object
{
"id": "alr_abc123",
"name": "Prod API failure rate",
"triggerType": "failure_rate",
"triggerConfig": {
"type": "failure_rate",
"destinationId": "dst_api123",
"thresholdPercent": 25,
"windowMinutes": 15
},
"notificationChannels": ["nch_slack1"],
"channelConfig": { "cooldownMinutes": 30 },
"isActive": true,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}Create Alert Rule
POST /api/alert-rulesRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Display name (1–100 chars) |
| triggerType | string | Yes | One of the trigger types above |
| triggerConfig | object | Yes | Config for the trigger (its type must match triggerType) |
| notificationChannels | string[] | Yes | Notification channel IDs (at least one) |
| cooldownMinutes | number | No | Minimum minutes between alerts (1–1440, default 30) |
Example
curl -X POST https://api.hookbase.app/api/alert-rules \
-H "Authorization: Bearer whr_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Prod API failure rate",
"triggerType": "failure_rate",
"triggerConfig": {
"type": "failure_rate",
"destinationId": "dst_api123",
"thresholdPercent": 25,
"windowMinutes": 15
},
"notificationChannels": ["nch_slack1"],
"cooldownMinutes": 30
}'Update Alert Rule
PATCH /api/alert-rules/{id}All fields optional: name, triggerConfig, notificationChannels, cooldownMinutes, isActive.
Test Alert Rule
Send a test notification to the rule's channels to confirm they're wired up correctly.
POST /api/alert-rules/{id}/testInfo
Some triggers (e.g. anomaly_volume, schema_drift) require a higher plan tier. Creating a rule with a gated trigger returns 403.