Skip to content
TriedDocs
Account

Create alert

Create an alert rule that watches a metric and notifies you when it crosses a threshold.

POSThttps://api.tried.com.au/alerts

Creates an alert rule. The scheduler checks each enabled rule every frequency_minutes. When the value crosses the threshold the rule moves to triggered and sends an alert_triggered notification; when it recovers it moves back to ok and sends alert_resolved. A workspace can have up to 10 rules.

Request#

Field Type Required Description
name string Yes 1 to 120 characters.
metric string Yes One of the names from List alert metrics.
threshold number Yes Value to compare against. Rates are percentages (0 to 100), latency is ms, cost is dollars.
threshold_type string No absolute (default) compares the metric value. relative compares the percent change against the window before it. concurrency_used always uses the current value.
comparator string No >, >=, < or <=. Default >.
window_minutes integer No Rolling window, 1 to 10080 (7 days). Default 60.
frequency_minutes integer No How often the scheduler checks the rule, 1 to 1440. Default 5.
agent_ids string[] No Only count calls from these agents. Default [] (all agents).
emails string[] No Up to 20 email addresses to notify. Default [].
webhook_url string or null No URL for alert_triggered and alert_resolved webhooks. Default null, which falls back to the workspace webhook URL.
enabled boolean No Disabled rules are skipped by the scheduler. Default true.

Example request#

curl -X POST https://api.tried.com.au/alerts \
  -H "Authorization: Bearer $TRIED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "High p90 latency",
    "metric": "e2e_latency_p90",
    "comparator": ">",
    "threshold": 1500,
    "window_minutes": 60,
    "agent_ids": [
      "agent_4b7e2c9a1f3d5e8b0c6a2d1f"
    ],
    "emails": [
      "ops@example.com"
    ],
    "webhook_url": "https://example.com/hooks/alerts"
  }'
const res = await fetch("https://api.tried.com.au/alerts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "High p90 latency",
    "metric": "e2e_latency_p90",
    "comparator": ">",
    "threshold": 1500,
    "window_minutes": 60,
    "agent_ids": [
      "agent_4b7e2c9a1f3d5e8b0c6a2d1f"
    ],
    "emails": [
      "ops@example.com"
    ],
    "webhook_url": "https://example.com/hooks/alerts"
  }),
});
const alert = await res.json();
import os, requests

res = requests.post(
    "https://api.tried.com.au/alerts",
    headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
    json={
        "name": "High p90 latency",
        "metric": "e2e_latency_p90",
        "comparator": ">",
        "threshold": 1500,
        "window_minutes": 60,
        "agent_ids": [
            "agent_4b7e2c9a1f3d5e8b0c6a2d1f",
        ],
        "emails": [
            "ops@example.com",
        ],
        "webhook_url": "https://example.com/hooks/alerts",
    },
)
alert = res.json()

Response#

201 Created

{
  "alert_id": "alert_3f9a1c7e2b8d4a6f0e1c5b92",
  "name": "High p90 latency",
  "metric": "e2e_latency_p90",
  "threshold_type": "absolute",
  "comparator": ">",
  "threshold": 1500,
  "window_minutes": 60,
  "frequency_minutes": 5,
  "agent_ids": [
    "agent_4b7e2c9a1f3d5e8b0c6a2d1f"
  ],
  "emails": [
    "ops@example.com"
  ],
  "webhook_url": "https://example.com/hooks/alerts",
  "enabled": true,
  "state": "ok",
  "last_value": null,
  "last_checked_timestamp": null,
  "created_timestamp": 1792395000000
}
Field Type Description
alert_id string Alert ID, prefixed alert_.
state string ok or triggered. Changes only when the rule is evaluated (by the scheduler or Evaluate alert).
last_value number or null Value from the last evaluation. For a relative rule this is the percent change against the previous window. null until the first evaluation.
last_checked_timestamp integer or null Unix ms of the last evaluation.
created_timestamp integer Unix ms when the rule was created.

The other fields echo the rule settings. See Create alert for what each one means.

Note

Webhook notifications are signed and go to webhook_url, or to the workspace webhook URL when it is null. Email goes out over SMTP when SMTP_URL is set; without it the message is only logged.

Errors#

Status When
400 Body validation failed (for example metric: Invalid enum value...), or the workspace already has 10 rules: A workspace can have at most 10 alert rules.
401 Missing or invalid API key.
403 The key's IP allowlist or scopes reject the request. This route needs the analytics scope. Dashboard users with the member role get The member role is read-only.
429 Rate limit exceeded. See Rate limits.

See Errors for the body format.

Retell compatibility#

Retell's public API reference has no alerting endpoints, so this route has no Retell SDK equivalent.